feat:修改插件挂载方式

This commit is contained in:
下羊 2020-03-27 19:31:03 +08:00
parent 89112cea35
commit 6ae17cf5f1
4 changed files with 34 additions and 21 deletions

View File

@ -11,6 +11,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
import Debug from 'debug';
import { EventEmitter } from 'events';
import store from 'store';
import pluginFactory from './pluginFactory';
import * as editorUtils from './utils';
var registShortCuts = editorUtils.registShortCuts,
transformToPromise = editorUtils.transformToPromise,
@ -76,7 +77,12 @@ var Editor = /*#__PURE__*/function (_EventEmitter) {
_this.locale = void 0;
_this.hooksFuncs = void 0;
_this.config = config;
_this.components = components;
_this.components = {};
Object.entries(components).forEach(function (_ref) {
var key = _ref[0],
value = _ref[1];
_this.components[key] = pluginFactory(value);
});
_this.utils = _extends({}, editorUtils, {}, utils);
instance = _assertThisInitialized(_this);
return _this;
@ -87,11 +93,11 @@ var Editor = /*#__PURE__*/function (_EventEmitter) {
_proto.init = function init() {
var _this2 = this;
var _ref = this.config || {},
hooks = _ref.hooks,
_ref$shortCuts = _ref.shortCuts,
shortCuts = _ref$shortCuts === void 0 ? [] : _ref$shortCuts,
lifeCycles = _ref.lifeCycles;
var _ref2 = this.config || {},
hooks = _ref2.hooks,
_ref2$shortCuts = _ref2.shortCuts,
shortCuts = _ref2$shortCuts === void 0 ? [] : _ref2$shortCuts,
lifeCycles = _ref2.lifeCycles;
this.locale = store.get('lowcode-editor-locale') || 'zh-CN'; // this.messages = this.messagesSet[this.locale];
// this.i18n = generateI18n(this.locale, this.messages);
@ -246,10 +252,10 @@ var Editor = /*#__PURE__*/function (_EventEmitter) {
return;
}
var _ref2 = plugin.props || {},
visible = _ref2.visible,
disabled = _ref2.disabled,
marked = _ref2.marked;
var _ref3 = plugin.props || {},
visible = _ref3.visible,
disabled = _ref3.disabled,
marked = _ref3.marked;
res[plugin.pluginKey] = {
visible: typeof visible === 'boolean' ? visible : true,

View File

@ -11,6 +11,8 @@ import {
PluginSet,
} from './definitions';
import pluginFactory from './pluginFactory';
import * as editorUtils from './utils';
const { registShortCuts, transformToPromise, unRegistShortCuts } = editorUtils;
@ -92,7 +94,10 @@ export default class Editor extends EventEmitter {
constructor(config: EditorConfig, components: PluginClassSet, utils?: Utils) {
super();
this.config = config;
this.components = components;
this.components = {};
Object.entries(components).forEach(([key, value]): void => {
this.components[key] = pluginFactory(value);
});
this.utils = { ...editorUtils, ...utils };
instance = this;
}

View File

@ -10,6 +10,8 @@
"@ali/lowcode-plugin-save": "0.0.1",
"@ali/lowcode-plugin-designer": "0.0.1",
"@ali/lowcode-plugin-components-pane": "0.0.1",
"@ali/lowcode-plugin-outline-tree": "0.0.0",
"@ali/lowcode-plugin-settings": "0.0.0",
"@alifd/next": "^1.x",
"@alife/theme-lowcode-dark": "^0.1.0",
"@alife/theme-lowcode-light": "^0.1.0",

View File

@ -1,19 +1,19 @@
import componentsPane from '@ali/lowcode-plugin-components-pane';
import Settings from '../../../plugin-settings';
import settings from '@ali/lowcode-plugin-settings';
import undoRedo from '@ali/lowcode-plugin-undo-redo';
import Designer from '../plugins/designer';
import designer from '../plugins/designer';
import logo from '@ali/lowcode-plugin-logo';
import save from '@ali/lowcode-plugin-save';
import OutlineTree from '../../../plugin-outline-tree';
import outlineTree from '@ali/lowcode-plugin-outline-tree';
import { PluginFactory } from '@ali/lowcode-editor-core';
export default {
logo: PluginFactory(logo),
save: PluginFactory(save),
designer: PluginFactory(Designer),
settings: PluginFactory(Settings),
outlineTree: PluginFactory(OutlineTree),
undoRedo: PluginFactory(undoRedo),
componentsPane: PluginFactory(componentsPane)
logo,
save,
designer,
settings,
outlineTree,
undoRedo,
componentsPane
};