Skip to content

Commit

Permalink
feat(editor): move editor to dynamic components
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisha0 committed Nov 3, 2022
1 parent c233e3a commit 0b31c10
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/plugins/async-plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function loadPlugin(selector: string, loadCallback: () => void): void {
if (document.querySelector(selector)) {
loadCallback();
}
}

export const registerAsyncPlugins = () => {
loadPlugin('uip-editor', () => import(/* webpackChunkName: "uip-editor" */ './editor/editor'));
}
2 changes: 2 additions & 0 deletions src/plugins/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ export class UIPEditor extends UIPPlugin {
}
}
}

UIPEditor.register();
6 changes: 3 additions & 3 deletions src/plugins/registration.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {UIPEditor} from './editor/editor';
import {UIPHeader} from './header/header';
import {UIPOptions} from './header/options/options';
import {UIPSnippets} from './header/snippets/snippets';
import {UIPSettings} from './settings/settings';
import {registeredSettings} from '../registration';
import {registerAsyncPlugins} from './async-plugins';

export {UIPEditor, UIPOptions, UIPSettings, UIPSnippets, UIPHeader};
export {UIPOptions, UIPSettings, UIPSnippets, UIPHeader};

export const registerPlugins = () => {
UIPEditor.register();
registerAsyncPlugins();
UIPHeader.register();
UIPOptions.register();
UIPSnippets.register();
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"esModuleInterop": true,
"target": "ES6",
"downlevelIteration": true,
"module": "ES2015",
"module": "ES2020",
"moduleResolution": "Node",
"lib": [
"ES2015",
Expand Down

0 comments on commit 0b31c10

Please sign in to comment.