@tmagic/editor 1.1.0-beta.2 → 1.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tmagic-editor.es.js +23 -38
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +21 -36
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/layouts/sidebar/ComponentListPanel.vue +4 -15
- package/src/services/BaseService.ts +4 -9
- package/src/services/editor.ts +1 -3
- package/src/utils/editor.ts +2 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.0-beta.
|
|
2
|
+
"version": "1.1.0-beta.3",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/core": "^7.18.0",
|
|
45
45
|
"@element-plus/icons-vue": "^2.0.6",
|
|
46
|
-
"@tmagic/core": "1.1.0-beta.
|
|
47
|
-
"@tmagic/form": "1.1.0-beta.
|
|
48
|
-
"@tmagic/schema": "1.1.0-beta.
|
|
49
|
-
"@tmagic/stage": "1.1.0-beta.
|
|
50
|
-
"@tmagic/utils": "1.1.0-beta.
|
|
46
|
+
"@tmagic/core": "1.1.0-beta.3",
|
|
47
|
+
"@tmagic/form": "1.1.0-beta.3",
|
|
48
|
+
"@tmagic/schema": "1.1.0-beta.3",
|
|
49
|
+
"@tmagic/stage": "1.1.0-beta.3",
|
|
50
|
+
"@tmagic/utils": "1.1.0-beta.3",
|
|
51
51
|
"buffer": "^6.0.3",
|
|
52
52
|
"color": "^3.1.3",
|
|
53
53
|
"element-plus": "^2.2.6",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"vue": "^3.2.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@tmagic/form": "1.1.0-beta.
|
|
63
|
+
"@tmagic/form": "1.1.0-beta.3",
|
|
64
64
|
"element-plus": "^2.2.6",
|
|
65
65
|
"monaco-editor": "^0.32.1",
|
|
66
66
|
"vue": "^3.2.0"
|
|
@@ -41,8 +41,7 @@ import { computed, defineComponent, inject, ref } from 'vue';
|
|
|
41
41
|
import serialize from 'serialize-javascript';
|
|
42
42
|
|
|
43
43
|
import type StageCore from '@tmagic/stage';
|
|
44
|
-
import {
|
|
45
|
-
import { addClassName, removeClassNameByClassName } from '@tmagic/utils';
|
|
44
|
+
import { removeClassNameByClassName } from '@tmagic/utils';
|
|
46
45
|
|
|
47
46
|
import MIcon from '@editor/components/Icon.vue';
|
|
48
47
|
import type { ComponentGroup, ComponentItem, Services, StageOptions } from '@editor/type';
|
|
@@ -125,19 +124,9 @@ export default defineComponent({
|
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
if (timeout) return;
|
|
129
|
-
|
|
130
|
-
timeout =
|
|
131
|
-
if (!stageOptions || !stage.value) return;
|
|
132
|
-
const doc = stage.value.renderer.contentWindow?.document;
|
|
133
|
-
const els = stage.value.getElementsFromPoint(e);
|
|
134
|
-
for (const el of els) {
|
|
135
|
-
if (doc && !el.id.startsWith(GHOST_EL_ID_PREFIX) && (await stageOptions.isContainer(el))) {
|
|
136
|
-
addClassName(el, doc, stageOptions?.containerHighlightClassName);
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}, stageOptions?.containerHighlightDuration);
|
|
127
|
+
if (timeout || !stage.value) return;
|
|
128
|
+
|
|
129
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
141
130
|
},
|
|
142
131
|
};
|
|
143
132
|
},
|
|
@@ -36,18 +36,13 @@ const doAction = async (
|
|
|
36
36
|
let beforeArgs = args;
|
|
37
37
|
|
|
38
38
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
39
|
-
|
|
39
|
+
beforeArgs = (await beforeMethod(...beforeArgs)) || [];
|
|
40
40
|
|
|
41
|
-
if (isError(
|
|
41
|
+
if (isError(beforeArgs)) throw beforeArgs;
|
|
42
42
|
|
|
43
|
-
if (!Array.isArray(
|
|
44
|
-
|
|
43
|
+
if (!Array.isArray(beforeArgs)) {
|
|
44
|
+
beforeArgs = [beforeArgs];
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
beforeArgs = beforeArgs.map((v: any, index: number) => {
|
|
48
|
-
if (typeof beforeReturnValue[index] === 'undefined') return v;
|
|
49
|
-
return beforeReturnValue[index];
|
|
50
|
-
});
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
let returnValue: any = await fn(beforeArgs, sourceMethod.bind(scope));
|
package/src/services/editor.ts
CHANGED
|
@@ -40,7 +40,6 @@ import {
|
|
|
40
40
|
isFixed,
|
|
41
41
|
setLayout,
|
|
42
42
|
} from '@editor/utils/editor';
|
|
43
|
-
import { log } from '@editor/utils/logger';
|
|
44
43
|
|
|
45
44
|
import BaseService from './BaseService';
|
|
46
45
|
|
|
@@ -90,7 +89,6 @@ class Editor extends BaseService {
|
|
|
90
89
|
*/
|
|
91
90
|
public set<T = MNode>(name: keyof StoreState, value: T) {
|
|
92
91
|
this.state[name] = value as any;
|
|
93
|
-
log('store set ', name, ' ', value);
|
|
94
92
|
|
|
95
93
|
if (name === 'root') {
|
|
96
94
|
this.state.pageLength = (value as unknown as MApp)?.items?.length || 0;
|
|
@@ -305,7 +303,7 @@ class Editor extends BaseService {
|
|
|
305
303
|
const stage = this.get<StageCore | null>('stage');
|
|
306
304
|
const root = this.get<MApp>('root');
|
|
307
305
|
|
|
308
|
-
await stage?.add({ config: cloneDeep(newNode), root: cloneDeep(root) });
|
|
306
|
+
await stage?.add({ config: cloneDeep(newNode), parent: cloneDeep(parentNode), root: cloneDeep(root) });
|
|
309
307
|
|
|
310
308
|
if (layout === Layout.ABSOLUTE) {
|
|
311
309
|
const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
|
package/src/utils/editor.ts
CHANGED
|
@@ -223,7 +223,8 @@ export const fixNodeLeft = (config: MNode, parent: MContainer, doc?: Document) =
|
|
|
223
223
|
const el = doc.getElementById(`${config.id}`);
|
|
224
224
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
225
225
|
|
|
226
|
-
|
|
226
|
+
const left = Number(config.style?.left) || 0;
|
|
227
|
+
if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
|
|
227
228
|
return parentEl.offsetWidth - el.offsetWidth;
|
|
228
229
|
}
|
|
229
230
|
|