@tmagic/editor 1.0.0-beta.12 → 1.0.0-beta.13
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/coverage/clover.xml +1444 -0
- package/coverage/coverage-final.json +34 -0
- package/coverage/lcov-report/Icon.vue.html +172 -0
- package/coverage/lcov-report/ToolButton.vue.html +655 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/layouts/sidebar/LayerMenu.vue.html +364 -0
- package/coverage/lcov-report/layouts/sidebar/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Editor.vue.html +787 -0
- package/coverage/lcov-report/src/components/Icon.vue.html +172 -0
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +283 -0
- package/coverage/lcov-report/src/components/ToolButton.vue.html +655 -0
- package/coverage/lcov-report/src/components/index.html +146 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +214 -0
- package/coverage/lcov-report/src/layouts/Framework.vue.html +304 -0
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +208 -0
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +316 -0
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +268 -0
- package/coverage/lcov-report/src/layouts/index.html +176 -0
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +292 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +364 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +853 -0
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +343 -0
- package/coverage/lcov-report/src/layouts/sidebar/index.html +161 -0
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +631 -0
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +766 -0
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +421 -0
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +586 -0
- package/coverage/lcov-report/src/layouts/workspace/index.html +161 -0
- package/coverage/lcov-report/src/services/BaseService.ts.html +643 -0
- package/coverage/lcov-report/src/services/componentList.ts.html +229 -0
- package/coverage/lcov-report/src/services/editor.ts.html +1984 -0
- package/coverage/lcov-report/src/services/events.ts.html +331 -0
- package/coverage/lcov-report/src/services/history.ts.html +457 -0
- package/coverage/lcov-report/src/services/index.html +206 -0
- package/coverage/lcov-report/src/services/props.ts.html +418 -0
- package/coverage/lcov-report/src/services/ui.ts.html +514 -0
- package/coverage/lcov-report/src/type.ts.html +850 -0
- package/coverage/lcov-report/src/utils/compose.ts.html +184 -0
- package/coverage/lcov-report/src/utils/config.ts.html +172 -0
- package/coverage/lcov-report/src/utils/editor.ts.html +838 -0
- package/coverage/lcov-report/src/utils/index.html +221 -0
- package/coverage/lcov-report/src/utils/index.ts.html +151 -0
- package/coverage/lcov-report/src/utils/logger.ts.html +226 -0
- package/coverage/lcov-report/src/utils/props.ts.html +739 -0
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +733 -0
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov-report/utils/index.html +116 -0
- package/coverage/lcov-report/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov.info +3407 -0
- package/dist/style.css +3 -2
- package/dist/tmagic-editor.es.js +326 -194
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +328 -197
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +1 -1
- package/dist/types/src/services/editor.d.ts +5 -2
- package/dist/types/src/services/ui.d.ts +1 -0
- package/dist/types/src/utils/editor.d.ts +2 -2
- package/package.json +18 -9
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +3 -3
- package/src/layouts/workspace/Workspace.vue +74 -16
- package/src/services/BaseService.ts +1 -1
- package/src/services/editor.ts +65 -9
- package/src/services/ui.ts +5 -0
- package/src/theme/layer-panel.scss +1 -0
- package/src/utils/editor.ts +6 -2
- package/tsconfig.json +0 -9
- package/vite.config.ts +0 -30
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -342,9 +342,6 @@ const setConfig = (option) => {
|
|
|
342
342
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
343
343
|
|
|
344
344
|
class UndoRedo {
|
|
345
|
-
elementList;
|
|
346
|
-
listCursor;
|
|
347
|
-
listMaxSize;
|
|
348
345
|
constructor(listMaxSize = 200) {
|
|
349
346
|
const minListMaxSize = 2;
|
|
350
347
|
this.elementList = [];
|
|
@@ -435,7 +432,7 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
435
432
|
}
|
|
436
433
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
437
434
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
438
|
-
returnValue = await afterMethod(...beforeArgs
|
|
435
|
+
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
439
436
|
if (isError(returnValue))
|
|
440
437
|
throw returnValue;
|
|
441
438
|
}
|
|
@@ -445,12 +442,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
445
442
|
}
|
|
446
443
|
};
|
|
447
444
|
class BaseService extends EventEmitter$2 {
|
|
448
|
-
pluginOptionsList = {};
|
|
449
|
-
middleware = {};
|
|
450
|
-
taskList = [];
|
|
451
|
-
doingTask = false;
|
|
452
445
|
constructor(methods = [], serialMethods = []) {
|
|
453
446
|
super();
|
|
447
|
+
this.pluginOptionsList = {};
|
|
448
|
+
this.middleware = {};
|
|
449
|
+
this.taskList = [];
|
|
450
|
+
this.doingTask = false;
|
|
454
451
|
methods.forEach((propertyName) => {
|
|
455
452
|
const scope = this;
|
|
456
453
|
const sourceMethod = scope[propertyName];
|
|
@@ -507,14 +504,14 @@ class BaseService extends EventEmitter$2 {
|
|
|
507
504
|
}
|
|
508
505
|
|
|
509
506
|
class History extends BaseService {
|
|
510
|
-
state = reactive({
|
|
511
|
-
pageSteps: {},
|
|
512
|
-
pageId: void 0,
|
|
513
|
-
canRedo: false,
|
|
514
|
-
canUndo: false
|
|
515
|
-
});
|
|
516
507
|
constructor() {
|
|
517
508
|
super([]);
|
|
509
|
+
this.state = reactive({
|
|
510
|
+
pageSteps: {},
|
|
511
|
+
pageId: void 0,
|
|
512
|
+
canRedo: false,
|
|
513
|
+
canUndo: false
|
|
514
|
+
});
|
|
518
515
|
this.on("change", this.setCanUndoRedo);
|
|
519
516
|
}
|
|
520
517
|
changePage(page) {
|
|
@@ -580,12 +577,12 @@ class History extends BaseService {
|
|
|
580
577
|
var historyService = new History();
|
|
581
578
|
|
|
582
579
|
class Props extends BaseService {
|
|
583
|
-
state = reactive({
|
|
584
|
-
propsConfigMap: {},
|
|
585
|
-
propsValueMap: {}
|
|
586
|
-
});
|
|
587
580
|
constructor() {
|
|
588
581
|
super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
|
|
582
|
+
this.state = reactive({
|
|
583
|
+
propsConfigMap: {},
|
|
584
|
+
propsValueMap: {}
|
|
585
|
+
});
|
|
589
586
|
}
|
|
590
587
|
setPropsConfigs(configs) {
|
|
591
588
|
Object.keys(configs).forEach((type) => {
|
|
@@ -808,16 +805,6 @@ const error = (...args) => {
|
|
|
808
805
|
};
|
|
809
806
|
|
|
810
807
|
class Editor$1 extends BaseService {
|
|
811
|
-
isHistoryStateChange = false;
|
|
812
|
-
state = reactive({
|
|
813
|
-
root: null,
|
|
814
|
-
page: null,
|
|
815
|
-
parent: null,
|
|
816
|
-
node: null,
|
|
817
|
-
stage: null,
|
|
818
|
-
highlightNode: null,
|
|
819
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
820
|
-
});
|
|
821
808
|
constructor() {
|
|
822
809
|
super([
|
|
823
810
|
"getLayout",
|
|
@@ -834,6 +821,16 @@ class Editor$1 extends BaseService {
|
|
|
834
821
|
"redo",
|
|
835
822
|
"highlight"
|
|
836
823
|
], ["select", "update", "moveLayer"]);
|
|
824
|
+
this.isHistoryStateChange = false;
|
|
825
|
+
this.state = reactive({
|
|
826
|
+
root: null,
|
|
827
|
+
page: null,
|
|
828
|
+
parent: null,
|
|
829
|
+
node: null,
|
|
830
|
+
stage: null,
|
|
831
|
+
highlightNode: null,
|
|
832
|
+
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
833
|
+
});
|
|
837
834
|
}
|
|
838
835
|
set(name, value) {
|
|
839
836
|
this.state[name] = value;
|
|
@@ -845,7 +842,7 @@ class Editor$1 extends BaseService {
|
|
|
845
842
|
return this.state[name];
|
|
846
843
|
}
|
|
847
844
|
getNodeInfo(id) {
|
|
848
|
-
const root = this.get("root");
|
|
845
|
+
const root = toRaw(this.get("root"));
|
|
849
846
|
if (!root)
|
|
850
847
|
return {};
|
|
851
848
|
if (id === root.id) {
|
|
@@ -876,11 +873,13 @@ class Editor$1 extends BaseService {
|
|
|
876
873
|
const { parent } = this.getNodeInfo(id);
|
|
877
874
|
return parent;
|
|
878
875
|
}
|
|
879
|
-
async getLayout(node) {
|
|
880
|
-
if (node
|
|
881
|
-
return
|
|
876
|
+
async getLayout(parent, node) {
|
|
877
|
+
if (node && typeof node !== "function" && isFixed(node))
|
|
878
|
+
return Layout.FIXED;
|
|
879
|
+
if (parent.layout) {
|
|
880
|
+
return parent.layout;
|
|
882
881
|
}
|
|
883
|
-
if (!
|
|
882
|
+
if (!parent.style?.position) {
|
|
884
883
|
return Layout.RELATIVE;
|
|
885
884
|
}
|
|
886
885
|
return Layout.ABSOLUTE;
|
|
@@ -897,6 +896,28 @@ class Editor$1 extends BaseService {
|
|
|
897
896
|
}
|
|
898
897
|
return node;
|
|
899
898
|
}
|
|
899
|
+
async selectNextNode() {
|
|
900
|
+
const node = toRaw(this.get("node"));
|
|
901
|
+
if (!node || isPage(node) || node.type === NodeType.ROOT)
|
|
902
|
+
return node;
|
|
903
|
+
const parent = toRaw(this.getParentById(node.id));
|
|
904
|
+
if (!parent)
|
|
905
|
+
return node;
|
|
906
|
+
const index = getNodeIndex(node, parent);
|
|
907
|
+
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
908
|
+
await this.select(nextNode);
|
|
909
|
+
this.get("stage")?.select(nextNode.id);
|
|
910
|
+
return nextNode;
|
|
911
|
+
}
|
|
912
|
+
async selectNextPage() {
|
|
913
|
+
const root = toRaw(this.get("root"));
|
|
914
|
+
const page = toRaw(this.get("page"));
|
|
915
|
+
const index = getNodeIndex(page, root);
|
|
916
|
+
const nextPage = root.items[index + 1] || root.items[0];
|
|
917
|
+
await this.select(nextPage);
|
|
918
|
+
this.get("stage")?.select(nextPage.id);
|
|
919
|
+
return nextPage;
|
|
920
|
+
}
|
|
900
921
|
highlight(config2) {
|
|
901
922
|
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
902
923
|
const currentHighlightNode = this.get("highlightNode");
|
|
@@ -904,7 +925,8 @@ class Editor$1 extends BaseService {
|
|
|
904
925
|
return;
|
|
905
926
|
this.set("highlightNode", node);
|
|
906
927
|
}
|
|
907
|
-
async add(
|
|
928
|
+
async add(addNode, parent) {
|
|
929
|
+
const { type, ...config2 } = addNode;
|
|
908
930
|
const curNode = this.get("node");
|
|
909
931
|
let parentNode;
|
|
910
932
|
if (type === NodeType.PAGE) {
|
|
@@ -918,7 +940,7 @@ class Editor$1 extends BaseService {
|
|
|
918
940
|
}
|
|
919
941
|
if (!parentNode)
|
|
920
942
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
921
|
-
const layout = await this.getLayout(parentNode);
|
|
943
|
+
const layout = await this.getLayout(toRaw(parentNode), addNode);
|
|
922
944
|
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
|
|
923
945
|
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
924
946
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
@@ -1046,7 +1068,7 @@ class Editor$1 extends BaseService {
|
|
|
1046
1068
|
async alignCenter(config2) {
|
|
1047
1069
|
const parent = this.get("parent");
|
|
1048
1070
|
const node = this.get("node");
|
|
1049
|
-
const layout = await this.getLayout(parent);
|
|
1071
|
+
const layout = await this.getLayout(toRaw(parent), toRaw(node));
|
|
1050
1072
|
if (layout === Layout.RELATIVE) {
|
|
1051
1073
|
return;
|
|
1052
1074
|
}
|
|
@@ -1083,6 +1105,26 @@ class Editor$1 extends BaseService {
|
|
|
1083
1105
|
await this.changeHistoryState(value);
|
|
1084
1106
|
return value;
|
|
1085
1107
|
}
|
|
1108
|
+
async move(left, top) {
|
|
1109
|
+
const node = toRaw(this.get("node"));
|
|
1110
|
+
if (!node || isPage(node))
|
|
1111
|
+
return;
|
|
1112
|
+
const { style, id } = node;
|
|
1113
|
+
if (!style || style.position !== "absolute")
|
|
1114
|
+
return;
|
|
1115
|
+
if (top && !isNumber(style.top))
|
|
1116
|
+
return;
|
|
1117
|
+
if (left && !isNumber(style.left))
|
|
1118
|
+
return;
|
|
1119
|
+
this.update({
|
|
1120
|
+
id,
|
|
1121
|
+
style: {
|
|
1122
|
+
...style,
|
|
1123
|
+
left: Number(style.left) + left,
|
|
1124
|
+
top: Number(style.top) + top
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1086
1128
|
destroy() {
|
|
1087
1129
|
this.removeAllListeners();
|
|
1088
1130
|
this.set("root", null);
|
|
@@ -1825,8 +1867,8 @@ Copyright (c) 2019 Daybrush
|
|
|
1825
1867
|
name: gesto
|
|
1826
1868
|
license: MIT
|
|
1827
1869
|
author: Daybrush
|
|
1828
|
-
repository: git+https://github.com/daybrush/
|
|
1829
|
-
version: 1.
|
|
1870
|
+
repository: git+https://github.com/daybrush/gesto.git
|
|
1871
|
+
version: 1.7.0
|
|
1830
1872
|
*/
|
|
1831
1873
|
|
|
1832
1874
|
/*! *****************************************************************************
|
|
@@ -1995,19 +2037,6 @@ function () {
|
|
|
1995
2037
|
|
|
1996
2038
|
var __proto = ClientStore.prototype;
|
|
1997
2039
|
|
|
1998
|
-
__proto.addClients = function (clients) {
|
|
1999
|
-
if (clients === void 0) {
|
|
2000
|
-
clients = this.prevClients;
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
var position = this.getPosition(clients);
|
|
2004
|
-
var deltaX = position.deltaX,
|
|
2005
|
-
deltaY = position.deltaY;
|
|
2006
|
-
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
2007
|
-
this.prevClients = clients;
|
|
2008
|
-
return position;
|
|
2009
|
-
};
|
|
2010
|
-
|
|
2011
2040
|
__proto.getAngle = function (clients) {
|
|
2012
2041
|
if (clients === void 0) {
|
|
2013
2042
|
clients = this.prevClients;
|
|
@@ -2024,8 +2053,17 @@ function () {
|
|
|
2024
2053
|
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
2025
2054
|
};
|
|
2026
2055
|
|
|
2027
|
-
__proto.getPosition = function (clients) {
|
|
2028
|
-
|
|
2056
|
+
__proto.getPosition = function (clients, isAdd) {
|
|
2057
|
+
if (clients === void 0) {
|
|
2058
|
+
clients = this.prevClients;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
var position = getPosition(clients || this.prevClients, this.prevClients, this.startClients);
|
|
2062
|
+
var deltaX = position.deltaX,
|
|
2063
|
+
deltaY = position.deltaY;
|
|
2064
|
+
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
2065
|
+
this.prevClients = clients;
|
|
2066
|
+
return position;
|
|
2029
2067
|
};
|
|
2030
2068
|
|
|
2031
2069
|
__proto.getPositions = function (clients) {
|
|
@@ -2074,10 +2112,6 @@ function () {
|
|
|
2074
2112
|
client.clientX -= deltaX;
|
|
2075
2113
|
client.clientY -= deltaY;
|
|
2076
2114
|
});
|
|
2077
|
-
this.prevClients.forEach(function (client) {
|
|
2078
|
-
client.clientX -= deltaX;
|
|
2079
|
-
client.clientY -= deltaY;
|
|
2080
|
-
});
|
|
2081
2115
|
};
|
|
2082
2116
|
|
|
2083
2117
|
return ClientStore;
|
|
@@ -2116,6 +2150,7 @@ function (_super) {
|
|
|
2116
2150
|
_this.targets = [];
|
|
2117
2151
|
_this.prevTime = 0;
|
|
2118
2152
|
_this.doubleFlag = false;
|
|
2153
|
+
_this._dragFlag = false;
|
|
2119
2154
|
|
|
2120
2155
|
_this.onDragStart = function (e, isTrusted) {
|
|
2121
2156
|
if (isTrusted === void 0) {
|
|
@@ -2146,7 +2181,8 @@ function (_super) {
|
|
|
2146
2181
|
if (checkInput || activeElement === target) {
|
|
2147
2182
|
// force false or already focused.
|
|
2148
2183
|
return false;
|
|
2149
|
-
}
|
|
2184
|
+
} // no focus
|
|
2185
|
+
|
|
2150
2186
|
|
|
2151
2187
|
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2152
2188
|
return false;
|
|
@@ -2162,6 +2198,7 @@ function (_super) {
|
|
|
2162
2198
|
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2163
2199
|
_this.flag = true;
|
|
2164
2200
|
_this.isDrag = false;
|
|
2201
|
+
_this._dragFlag = true;
|
|
2165
2202
|
_this.datas = {};
|
|
2166
2203
|
|
|
2167
2204
|
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
@@ -2177,7 +2214,14 @@ function (_super) {
|
|
|
2177
2214
|
inputEvent: e,
|
|
2178
2215
|
isTrusted: isTrusted,
|
|
2179
2216
|
isDouble: _this.doubleFlag
|
|
2180
|
-
}, _this.getCurrentStore().getPosition()
|
|
2217
|
+
}, _this.getCurrentStore().getPosition(), {
|
|
2218
|
+
preventDefault: function () {
|
|
2219
|
+
e.preventDefault();
|
|
2220
|
+
},
|
|
2221
|
+
preventDrag: function () {
|
|
2222
|
+
_this._dragFlag = false;
|
|
2223
|
+
}
|
|
2224
|
+
}));
|
|
2181
2225
|
|
|
2182
2226
|
if (result === false) {
|
|
2183
2227
|
_this.initDrag();
|
|
@@ -2226,24 +2270,26 @@ function (_super) {
|
|
|
2226
2270
|
|
|
2227
2271
|
var result = _this.moveClients(clients, e, false);
|
|
2228
2272
|
|
|
2229
|
-
if (_this.
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2273
|
+
if (_this._dragFlag) {
|
|
2274
|
+
if (_this.pinchFlag || result.deltaX || result.deltaY) {
|
|
2275
|
+
var dragResult = _this.emit("drag", __assign({}, result, {
|
|
2276
|
+
isScroll: !!isScroll,
|
|
2277
|
+
inputEvent: e
|
|
2278
|
+
}));
|
|
2234
2279
|
|
|
2235
|
-
|
|
2236
|
-
|
|
2280
|
+
if (dragResult === false) {
|
|
2281
|
+
_this.stop();
|
|
2237
2282
|
|
|
2238
|
-
|
|
2283
|
+
return;
|
|
2284
|
+
}
|
|
2239
2285
|
}
|
|
2240
|
-
}
|
|
2241
2286
|
|
|
2242
|
-
|
|
2243
|
-
|
|
2287
|
+
if (_this.pinchFlag) {
|
|
2288
|
+
_this.onPinch(e, clients);
|
|
2289
|
+
}
|
|
2244
2290
|
}
|
|
2245
2291
|
|
|
2246
|
-
_this.getCurrentStore().
|
|
2292
|
+
_this.getCurrentStore().getPosition(clients, true);
|
|
2247
2293
|
};
|
|
2248
2294
|
|
|
2249
2295
|
_this.onDragEnd = function (e) {
|
|
@@ -2261,7 +2307,7 @@ function (_super) {
|
|
|
2261
2307
|
|
|
2262
2308
|
_this.flag = false;
|
|
2263
2309
|
|
|
2264
|
-
var position = _this.
|
|
2310
|
+
var position = _this._getPosition();
|
|
2265
2311
|
|
|
2266
2312
|
var currentTime = now();
|
|
2267
2313
|
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
@@ -2455,7 +2501,23 @@ function (_super) {
|
|
|
2455
2501
|
return this;
|
|
2456
2502
|
};
|
|
2457
2503
|
/**
|
|
2458
|
-
*
|
|
2504
|
+
* Get the current event state while dragging.
|
|
2505
|
+
*/
|
|
2506
|
+
|
|
2507
|
+
|
|
2508
|
+
__proto.getCurrentEvent = function (inputEvent) {
|
|
2509
|
+
return __assign({
|
|
2510
|
+
datas: this.datas
|
|
2511
|
+
}, this._getPosition(), {
|
|
2512
|
+
movement: this.getMovement(),
|
|
2513
|
+
isDrag: this.isDrag,
|
|
2514
|
+
isPinch: this.isPinch,
|
|
2515
|
+
isScroll: false,
|
|
2516
|
+
inputEvent: inputEvent
|
|
2517
|
+
});
|
|
2518
|
+
};
|
|
2519
|
+
/**
|
|
2520
|
+
* Get & Set the event data while dragging.
|
|
2459
2521
|
*/
|
|
2460
2522
|
|
|
2461
2523
|
|
|
@@ -2571,9 +2633,12 @@ function (_super) {
|
|
|
2571
2633
|
};
|
|
2572
2634
|
|
|
2573
2635
|
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2574
|
-
var
|
|
2575
|
-
|
|
2576
|
-
|
|
2636
|
+
var position = this._getPosition(clients, isAdd);
|
|
2637
|
+
|
|
2638
|
+
if (position.deltaX || position.deltaY) {
|
|
2639
|
+
this.isDrag = true;
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2577
2642
|
return __assign({
|
|
2578
2643
|
datas: this.datas
|
|
2579
2644
|
}, position, {
|
|
@@ -2585,6 +2650,25 @@ function (_super) {
|
|
|
2585
2650
|
});
|
|
2586
2651
|
};
|
|
2587
2652
|
|
|
2653
|
+
__proto._getPosition = function (clients, isAdd) {
|
|
2654
|
+
var store = this.getCurrentStore();
|
|
2655
|
+
var position = store.getPosition(clients, isAdd);
|
|
2656
|
+
|
|
2657
|
+
var _a = this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2658
|
+
var storePosition = cur.getPosition();
|
|
2659
|
+
prev.distX += storePosition.distX;
|
|
2660
|
+
prev.distY += storePosition.distY;
|
|
2661
|
+
return prev;
|
|
2662
|
+
}, position),
|
|
2663
|
+
distX = _a.distX,
|
|
2664
|
+
distY = _a.distY;
|
|
2665
|
+
|
|
2666
|
+
return __assign({}, position, {
|
|
2667
|
+
distX: distX,
|
|
2668
|
+
distY: distY
|
|
2669
|
+
});
|
|
2670
|
+
};
|
|
2671
|
+
|
|
2588
2672
|
return Gesto;
|
|
2589
2673
|
}(EventEmitter$1);
|
|
2590
2674
|
|
|
@@ -2771,11 +2855,11 @@ const _sfc_main$c = defineComponent({
|
|
|
2771
2855
|
setup(props) {
|
|
2772
2856
|
const services = inject("services");
|
|
2773
2857
|
const uiService = services?.uiService;
|
|
2774
|
-
const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
|
|
2775
|
-
const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
|
|
2776
2858
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
2777
2859
|
const showGuides = computed(() => uiService?.get("showGuides") ?? true);
|
|
2778
2860
|
const showRule = computed(() => uiService?.get("showRule") ?? true);
|
|
2861
|
+
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
2862
|
+
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2779
2863
|
const item = computed(() => {
|
|
2780
2864
|
if (typeof props.data !== "string") {
|
|
2781
2865
|
return props.data;
|
|
@@ -3833,33 +3917,104 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3833
3917
|
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3834
3918
|
|
|
3835
3919
|
class ScrollViewer$1 {
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3920
|
+
constructor(options) {
|
|
3921
|
+
this.enter = false;
|
|
3922
|
+
this.targetEnter = false;
|
|
3923
|
+
this.keydown = false;
|
|
3924
|
+
this.zoom = 1;
|
|
3925
|
+
this.scrollLeft = 0;
|
|
3926
|
+
this.scrollTop = 0;
|
|
3927
|
+
this.x = 0;
|
|
3928
|
+
this.y = 0;
|
|
3929
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3930
|
+
for (const { contentRect } of entries) {
|
|
3931
|
+
const { width, height } = contentRect;
|
|
3932
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3933
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3934
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3935
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3936
|
+
if (targetWidth < width) {
|
|
3937
|
+
this.target._left = 0;
|
|
3938
|
+
}
|
|
3939
|
+
if (targetHeight < height) {
|
|
3940
|
+
this.target._top = 0;
|
|
3941
|
+
}
|
|
3942
|
+
this.scroll();
|
|
3858
3943
|
}
|
|
3944
|
+
});
|
|
3945
|
+
this.wheelHandler = (event) => {
|
|
3946
|
+
if (this.targetEnter)
|
|
3947
|
+
return;
|
|
3948
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3949
|
+
if (currentTarget !== this.container)
|
|
3950
|
+
return;
|
|
3951
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3859
3952
|
this.scroll();
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3953
|
+
this.scrollLeft = this.target._left;
|
|
3954
|
+
this.scrollTop = this.target._top;
|
|
3955
|
+
};
|
|
3956
|
+
this.mouseEnterHandler = () => {
|
|
3957
|
+
this.enter = true;
|
|
3958
|
+
};
|
|
3959
|
+
this.mouseLeaveHandler = () => {
|
|
3960
|
+
this.enter = false;
|
|
3961
|
+
};
|
|
3962
|
+
this.targetMouseEnterHandler = () => {
|
|
3963
|
+
this.targetEnter = true;
|
|
3964
|
+
};
|
|
3965
|
+
this.targetMouseLeaveHandler = () => {
|
|
3966
|
+
this.targetEnter = false;
|
|
3967
|
+
};
|
|
3968
|
+
this.mousedownHandler = (event) => {
|
|
3969
|
+
if (!this.keydown)
|
|
3970
|
+
return;
|
|
3971
|
+
event.stopImmediatePropagation();
|
|
3972
|
+
event.stopPropagation();
|
|
3973
|
+
this.target.style.cursor = "grabbing";
|
|
3974
|
+
this.x = event.clientX;
|
|
3975
|
+
this.y = event.clientY;
|
|
3976
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3977
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3978
|
+
};
|
|
3979
|
+
this.mouseupHandler = () => {
|
|
3980
|
+
this.x = 0;
|
|
3981
|
+
this.y = 0;
|
|
3982
|
+
this.scrollLeft = this.target._left;
|
|
3983
|
+
this.scrollTop = this.target._top;
|
|
3984
|
+
this.removeHandler();
|
|
3985
|
+
};
|
|
3986
|
+
this.mousemoveHandler = (event) => {
|
|
3987
|
+
event.stopImmediatePropagation();
|
|
3988
|
+
event.stopPropagation();
|
|
3989
|
+
const deltaX = event.clientX - this.x;
|
|
3990
|
+
const deltaY = event.clientY - this.y;
|
|
3991
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3992
|
+
this.scroll();
|
|
3993
|
+
};
|
|
3994
|
+
this.keydownHandler = (event) => {
|
|
3995
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3996
|
+
event.preventDefault();
|
|
3997
|
+
event.stopImmediatePropagation();
|
|
3998
|
+
event.stopPropagation();
|
|
3999
|
+
}
|
|
4000
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
4001
|
+
return;
|
|
4002
|
+
}
|
|
4003
|
+
this.keydown = true;
|
|
4004
|
+
this.target.style.cursor = "grab";
|
|
4005
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
4006
|
+
};
|
|
4007
|
+
this.keyupHandler = (event) => {
|
|
4008
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
4009
|
+
return;
|
|
4010
|
+
}
|
|
4011
|
+
event.preventDefault();
|
|
4012
|
+
event.stopImmediatePropagation();
|
|
4013
|
+
event.stopPropagation();
|
|
4014
|
+
this.keydown = false;
|
|
4015
|
+
event.preventDefault();
|
|
4016
|
+
this.removeHandler();
|
|
4017
|
+
};
|
|
3863
4018
|
this.container = options.container;
|
|
3864
4019
|
this.target = options.target;
|
|
3865
4020
|
this.zoom = options.zoom;
|
|
@@ -3895,79 +4050,6 @@ class ScrollViewer$1 {
|
|
|
3895
4050
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3896
4051
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3897
4052
|
}
|
|
3898
|
-
wheelHandler = (event) => {
|
|
3899
|
-
if (this.targetEnter)
|
|
3900
|
-
return;
|
|
3901
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3902
|
-
if (currentTarget !== this.container)
|
|
3903
|
-
return;
|
|
3904
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3905
|
-
this.scroll();
|
|
3906
|
-
this.scrollLeft = this.target._left;
|
|
3907
|
-
this.scrollTop = this.target._top;
|
|
3908
|
-
};
|
|
3909
|
-
mouseEnterHandler = () => {
|
|
3910
|
-
this.enter = true;
|
|
3911
|
-
};
|
|
3912
|
-
mouseLeaveHandler = () => {
|
|
3913
|
-
this.enter = false;
|
|
3914
|
-
};
|
|
3915
|
-
targetMouseEnterHandler = () => {
|
|
3916
|
-
this.targetEnter = true;
|
|
3917
|
-
};
|
|
3918
|
-
targetMouseLeaveHandler = () => {
|
|
3919
|
-
this.targetEnter = false;
|
|
3920
|
-
};
|
|
3921
|
-
mousedownHandler = (event) => {
|
|
3922
|
-
if (!this.keydown)
|
|
3923
|
-
return;
|
|
3924
|
-
event.stopImmediatePropagation();
|
|
3925
|
-
event.stopPropagation();
|
|
3926
|
-
this.target.style.cursor = "grabbing";
|
|
3927
|
-
this.x = event.clientX;
|
|
3928
|
-
this.y = event.clientY;
|
|
3929
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3930
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3931
|
-
};
|
|
3932
|
-
mouseupHandler = () => {
|
|
3933
|
-
this.x = 0;
|
|
3934
|
-
this.y = 0;
|
|
3935
|
-
this.scrollLeft = this.target._left;
|
|
3936
|
-
this.scrollTop = this.target._top;
|
|
3937
|
-
this.removeHandler();
|
|
3938
|
-
};
|
|
3939
|
-
mousemoveHandler = (event) => {
|
|
3940
|
-
event.stopImmediatePropagation();
|
|
3941
|
-
event.stopPropagation();
|
|
3942
|
-
const deltaX = event.clientX - this.x;
|
|
3943
|
-
const deltaY = event.clientY - this.y;
|
|
3944
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3945
|
-
this.scroll();
|
|
3946
|
-
};
|
|
3947
|
-
keydownHandler = (event) => {
|
|
3948
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3949
|
-
event.preventDefault();
|
|
3950
|
-
event.stopImmediatePropagation();
|
|
3951
|
-
event.stopPropagation();
|
|
3952
|
-
}
|
|
3953
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3954
|
-
return;
|
|
3955
|
-
}
|
|
3956
|
-
this.keydown = true;
|
|
3957
|
-
this.target.style.cursor = "grab";
|
|
3958
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3959
|
-
};
|
|
3960
|
-
keyupHandler = (event) => {
|
|
3961
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3962
|
-
return;
|
|
3963
|
-
}
|
|
3964
|
-
event.preventDefault();
|
|
3965
|
-
event.stopImmediatePropagation();
|
|
3966
|
-
event.stopPropagation();
|
|
3967
|
-
this.keydown = false;
|
|
3968
|
-
event.preventDefault();
|
|
3969
|
-
this.removeHandler();
|
|
3970
|
-
};
|
|
3971
4053
|
setScrollOffset(deltaX, deltaY) {
|
|
3972
4054
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3973
4055
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -4028,7 +4110,7 @@ const _sfc_main$4 = defineComponent({
|
|
|
4028
4110
|
el,
|
|
4029
4111
|
style: computed(() => `
|
|
4030
4112
|
width: ${props.width}px;
|
|
4031
|
-
height: ${props.height}px;
|
|
4113
|
+
height: ${(props.height || 0) - 40}px;
|
|
4032
4114
|
position: absolute;
|
|
4033
4115
|
margin-top: 30px;
|
|
4034
4116
|
`)
|
|
@@ -4373,29 +4455,74 @@ const _sfc_main$1 = defineComponent({
|
|
|
4373
4455
|
const mouseenterHandler = () => {
|
|
4374
4456
|
workspace.value?.focus();
|
|
4375
4457
|
};
|
|
4376
|
-
const mouseleaveHandler = () => {
|
|
4377
|
-
workspace.value?.blur();
|
|
4378
|
-
};
|
|
4379
4458
|
onMounted(() => {
|
|
4380
4459
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
4381
|
-
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
4382
4460
|
keycon = new KeyController(workspace.value);
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4461
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4462
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
4463
|
+
keycon.keyup("delete", (e) => {
|
|
4464
|
+
e.inputEvent.preventDefault();
|
|
4465
|
+
if (!node.value || isPage(node.value))
|
|
4466
|
+
return;
|
|
4467
|
+
services?.editorService.remove(node.value);
|
|
4468
|
+
}).keydown([ctrl, "c"], (e) => {
|
|
4469
|
+
e.inputEvent.preventDefault();
|
|
4386
4470
|
node.value && services?.editorService.copy(node.value);
|
|
4387
|
-
}).keyup([
|
|
4471
|
+
}).keyup([ctrl, "v"], (e) => {
|
|
4472
|
+
e.inputEvent.preventDefault();
|
|
4388
4473
|
node.value && services?.editorService.paste();
|
|
4389
|
-
}).keyup([
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4474
|
+
}).keyup([ctrl, "x"], (e) => {
|
|
4475
|
+
e.inputEvent.preventDefault();
|
|
4476
|
+
if (!node.value || isPage(node.value))
|
|
4477
|
+
return;
|
|
4478
|
+
services?.editorService.copy(node.value);
|
|
4479
|
+
services?.editorService.remove(node.value);
|
|
4480
|
+
}).keydown([ctrl, "z"], (e) => {
|
|
4481
|
+
e.inputEvent.preventDefault();
|
|
4482
|
+
services?.editorService.undo();
|
|
4483
|
+
}).keydown([ctrl, "shift", "z"], (e) => {
|
|
4484
|
+
e.inputEvent.preventDefault();
|
|
4485
|
+
services?.editorService.redo();
|
|
4486
|
+
}).keydown("up", (e) => {
|
|
4487
|
+
e.inputEvent.preventDefault();
|
|
4488
|
+
services?.editorService.move(0, -1);
|
|
4489
|
+
}).keydown("down", (e) => {
|
|
4490
|
+
e.inputEvent.preventDefault();
|
|
4491
|
+
services?.editorService.move(0, 1);
|
|
4492
|
+
}).keydown("left", (e) => {
|
|
4493
|
+
e.inputEvent.preventDefault();
|
|
4494
|
+
services?.editorService.move(-1, 0);
|
|
4495
|
+
}).keydown("right", (e) => {
|
|
4496
|
+
e.inputEvent.preventDefault();
|
|
4497
|
+
services?.editorService.move(1, 0);
|
|
4498
|
+
}).keydown([ctrl, "up"], (e) => {
|
|
4499
|
+
e.inputEvent.preventDefault();
|
|
4500
|
+
services?.editorService.move(0, -10);
|
|
4501
|
+
}).keydown([ctrl, "down"], (e) => {
|
|
4502
|
+
e.inputEvent.preventDefault();
|
|
4503
|
+
services?.editorService.move(0, 10);
|
|
4504
|
+
}).keydown([ctrl, "left"], (e) => {
|
|
4505
|
+
e.inputEvent.preventDefault();
|
|
4506
|
+
services?.editorService.move(-10, 0);
|
|
4507
|
+
}).keydown([ctrl, "right"], (e) => {
|
|
4508
|
+
e.inputEvent.preventDefault();
|
|
4509
|
+
services?.editorService.move(10, 0);
|
|
4510
|
+
}).keydown("tab", (e) => {
|
|
4511
|
+
e.inputEvent.preventDefault();
|
|
4512
|
+
services?.editorService.selectNextNode();
|
|
4513
|
+
}).keydown([ctrl, "tab"], (e) => {
|
|
4514
|
+
e.inputEvent.preventDefault();
|
|
4515
|
+
services?.editorService.selectNextPage();
|
|
4516
|
+
}).keydown([ctrl, "="], (e) => {
|
|
4517
|
+
e.inputEvent.preventDefault();
|
|
4518
|
+
services?.uiService.zoom(0.1);
|
|
4519
|
+
}).keydown([ctrl, "-"], (e) => {
|
|
4520
|
+
e.inputEvent.preventDefault();
|
|
4521
|
+
services?.uiService.zoom(-0.1);
|
|
4394
4522
|
});
|
|
4395
4523
|
});
|
|
4396
4524
|
onUnmounted(() => {
|
|
4397
4525
|
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
4398
|
-
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4399
4526
|
keycon.destroy();
|
|
4400
4527
|
});
|
|
4401
4528
|
return {
|
|
@@ -4435,11 +4562,11 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4435
4562
|
var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4436
4563
|
|
|
4437
4564
|
class ComponentList extends BaseService {
|
|
4438
|
-
state = reactive({
|
|
4439
|
-
list: []
|
|
4440
|
-
});
|
|
4441
4565
|
constructor() {
|
|
4442
4566
|
super([]);
|
|
4567
|
+
this.state = reactive({
|
|
4568
|
+
list: []
|
|
4569
|
+
});
|
|
4443
4570
|
}
|
|
4444
4571
|
setList(componentGroupList) {
|
|
4445
4572
|
this.state.list = componentGroupList;
|
|
@@ -4505,6 +4632,11 @@ class Ui extends BaseService {
|
|
|
4505
4632
|
get(name) {
|
|
4506
4633
|
return state[name];
|
|
4507
4634
|
}
|
|
4635
|
+
zoom(zoom) {
|
|
4636
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4637
|
+
if (this.get("zoom") < 0.1)
|
|
4638
|
+
this.set("zoom", 0.1);
|
|
4639
|
+
}
|
|
4508
4640
|
setColumnWidth({ left, center, right }) {
|
|
4509
4641
|
const columnWidth = {
|
|
4510
4642
|
...toRaw(this.get("columnWidth"))
|