@tmagic/editor 1.0.0-rc.1 → 1.0.0-rc.4
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 +476 -443
- package/coverage/coverage-final.json +10 -10
- package/coverage/lcov-report/index.html +55 -55
- package/coverage/lcov-report/src/Editor.vue.html +36 -9
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +11 -11
- package/coverage/lcov-report/src/components/Icon.vue.html +2 -2
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
- package/coverage/lcov-report/src/components/ToolButton.vue.html +25 -25
- package/coverage/lcov-report/src/components/index.html +5 -5
- package/coverage/lcov-report/src/index.html +14 -14
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Framework.vue.html +48 -9
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +2 -2
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/index.html +15 -15
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +17 -17
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +2 -2
- package/coverage/lcov-report/src/layouts/sidebar/index.html +19 -19
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +13 -4
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +69 -33
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +73 -10
- package/coverage/lcov-report/src/layouts/workspace/index.html +32 -32
- package/coverage/lcov-report/src/services/BaseService.ts.html +2 -2
- package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
- package/coverage/lcov-report/src/services/editor.ts.html +100 -10
- package/coverage/lcov-report/src/services/events.ts.html +1 -1
- package/coverage/lcov-report/src/services/history.ts.html +1 -1
- package/coverage/lcov-report/src/services/index.html +15 -15
- package/coverage/lcov-report/src/services/props.ts.html +1 -1
- package/coverage/lcov-report/src/services/ui.ts.html +1 -1
- package/coverage/lcov-report/src/type.ts.html +1 -1
- package/coverage/lcov-report/src/utils/compose.ts.html +1 -1
- package/coverage/lcov-report/src/utils/config.ts.html +1 -1
- package/coverage/lcov-report/src/utils/editor.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
- package/coverage/lcov-report/src/utils/props.ts.html +1 -1
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
- package/coverage/lcov.info +1203 -1065
- package/dist/style.css +3 -3
- package/dist/tmagic-editor.es.js +86 -1233
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +87 -1234
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +14 -0
- package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +5 -1
- package/dist/types/src/services/BaseService.d.ts +1 -1
- package/package.json +16 -8
- package/src/Editor.vue +10 -1
- package/src/components/ContentMenu.vue +1 -1
- package/src/layouts/CodeEditor.vue +1 -4
- package/src/layouts/Framework.vue +14 -1
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +1 -1
- package/src/layouts/workspace/Stage.vue +3 -0
- package/src/layouts/workspace/ViewerMenu.vue +14 -2
- package/src/layouts/workspace/Workspace.vue +21 -0
- package/src/services/BaseService.ts +1 -1
- package/src/services/editor.ts +31 -1
- package/src/theme/props-panel.scss +6 -4
- package/src/utils/polyfills.ts +5 -19
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons'), require('lodash-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('element-plus'), require('keycon'), require('@tmagic/stage')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons', 'lodash-es', 'monaco-editor', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'element-plus', 'keycon', '@tmagic/stage'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.icons, global.lodashEs, global.monaco, global.schema, global.utils, global.events, global.core, global.elementPlus, global.KeyController, global.StageCore));
|
|
5
|
-
})(this, (function (exports, vue, serialize, icons, lodashEs, monaco, schema, utils, events, core, elementPlus, KeyController, StageCore) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons'), require('lodash-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon'), require('@tmagic/stage')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons', 'lodash-es', 'monaco-editor', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon', '@tmagic/stage'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.icons, global.lodashEs, global.monaco, global.schema, global.utils, global.events, global.core, global.Gesto, global.elementPlus, global.KeyController, global.StageCore));
|
|
5
|
+
})(this, (function (exports, vue, serialize, icons, lodashEs, monaco, schema, utils, events, core, Gesto, elementPlus, KeyController, StageCore) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -26,12 +26,16 @@
|
|
|
26
26
|
|
|
27
27
|
var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
|
|
28
28
|
var monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
|
|
29
|
+
var Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
|
|
29
30
|
var KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
|
|
30
31
|
var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
31
32
|
|
|
32
|
-
if (typeof
|
|
33
|
+
if (typeof global === "undefined") {
|
|
33
34
|
window.global = window;
|
|
34
35
|
}
|
|
36
|
+
if (typeof globalThis === "undefined") {
|
|
37
|
+
window.globalThis = window;
|
|
38
|
+
}
|
|
35
39
|
|
|
36
40
|
var _export_sfc = (sfc, props) => {
|
|
37
41
|
const target = sfc.__vccOpts || sfc;
|
|
@@ -328,11 +332,7 @@
|
|
|
328
332
|
const options = {
|
|
329
333
|
value: values.value,
|
|
330
334
|
language: props.language,
|
|
331
|
-
tabSize: 2,
|
|
332
335
|
theme: "vs-dark",
|
|
333
|
-
fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
|
|
334
|
-
fontSize: 14,
|
|
335
|
-
formatOnPaste: true,
|
|
336
336
|
...props.options
|
|
337
337
|
};
|
|
338
338
|
if (props.type === "diff") {
|
|
@@ -346,6 +346,7 @@
|
|
|
346
346
|
codeEditor.value.addEventListener("keydown", (e) => {
|
|
347
347
|
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
348
348
|
e.preventDefault();
|
|
349
|
+
e.stopPropagation();
|
|
349
350
|
emit("save", getEditorValue());
|
|
350
351
|
}
|
|
351
352
|
});
|
|
@@ -962,6 +963,13 @@
|
|
|
962
963
|
} else {
|
|
963
964
|
historyService.empty();
|
|
964
965
|
}
|
|
966
|
+
if (node?.id) {
|
|
967
|
+
this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
|
|
968
|
+
node,
|
|
969
|
+
page,
|
|
970
|
+
parent
|
|
971
|
+
}, utils.getNodePath(node.id, this.get("root").items));
|
|
972
|
+
}
|
|
965
973
|
this.emit("select", node);
|
|
966
974
|
return node;
|
|
967
975
|
}
|
|
@@ -1150,6 +1158,9 @@
|
|
|
1150
1158
|
...position
|
|
1151
1159
|
};
|
|
1152
1160
|
}
|
|
1161
|
+
if (utils.isPage(config)) {
|
|
1162
|
+
config.name = generatePageNameByApp(this.get("root"));
|
|
1163
|
+
}
|
|
1153
1164
|
return await this.add(config);
|
|
1154
1165
|
}
|
|
1155
1166
|
async alignCenter(config2) {
|
|
@@ -1159,7 +1170,17 @@
|
|
|
1159
1170
|
if (layout === Layout.RELATIVE) {
|
|
1160
1171
|
return;
|
|
1161
1172
|
}
|
|
1162
|
-
if (
|
|
1173
|
+
if (!node.style)
|
|
1174
|
+
return;
|
|
1175
|
+
const stage = this.get("stage");
|
|
1176
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
1177
|
+
if (doc) {
|
|
1178
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1179
|
+
const el = doc.getElementById(`${node.id}`);
|
|
1180
|
+
if (parentEl && el) {
|
|
1181
|
+
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1182
|
+
}
|
|
1183
|
+
} else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
|
|
1163
1184
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1164
1185
|
}
|
|
1165
1186
|
await this.update(node);
|
|
@@ -1571,1215 +1592,6 @@
|
|
|
1571
1592
|
}
|
|
1572
1593
|
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
1573
1594
|
|
|
1574
|
-
/*
|
|
1575
|
-
Copyright (c) 2018 Daybrush
|
|
1576
|
-
@name: @daybrush/utils
|
|
1577
|
-
license: MIT
|
|
1578
|
-
author: Daybrush
|
|
1579
|
-
repository: https://github.com/daybrush/utils
|
|
1580
|
-
@version 1.6.0
|
|
1581
|
-
*/
|
|
1582
|
-
/**
|
|
1583
|
-
* get string "object"
|
|
1584
|
-
* @memberof Consts
|
|
1585
|
-
* @example
|
|
1586
|
-
import {OBJECT} from "@daybrush/utils";
|
|
1587
|
-
|
|
1588
|
-
console.log(OBJECT); // "object"
|
|
1589
|
-
*/
|
|
1590
|
-
|
|
1591
|
-
var OBJECT = "object";
|
|
1592
|
-
/**
|
|
1593
|
-
* Check the type that the value is object.
|
|
1594
|
-
* @memberof Utils
|
|
1595
|
-
* @param {string} value - Value to check the type
|
|
1596
|
-
* @return {} true if the type is correct, false otherwise
|
|
1597
|
-
* @example
|
|
1598
|
-
import {isObject} from "@daybrush/utils";
|
|
1599
|
-
|
|
1600
|
-
console.log(isObject({})); // true
|
|
1601
|
-
console.log(isObject(undefined)); // false
|
|
1602
|
-
console.log(isObject("")); // false
|
|
1603
|
-
console.log(isObject(null)); // false
|
|
1604
|
-
*/
|
|
1605
|
-
|
|
1606
|
-
function isObject(value) {
|
|
1607
|
-
return value && typeof value === OBJECT;
|
|
1608
|
-
}
|
|
1609
|
-
/**
|
|
1610
|
-
* Date.now() method
|
|
1611
|
-
* @memberof CrossBrowser
|
|
1612
|
-
* @return {number} milliseconds
|
|
1613
|
-
* @example
|
|
1614
|
-
import {now} from "@daybrush/utils";
|
|
1615
|
-
|
|
1616
|
-
console.log(now()); // 12121324241(milliseconds)
|
|
1617
|
-
*/
|
|
1618
|
-
|
|
1619
|
-
function now() {
|
|
1620
|
-
return Date.now ? Date.now() : new Date().getTime();
|
|
1621
|
-
}
|
|
1622
|
-
/**
|
|
1623
|
-
* Returns the index of the first element in the array that satisfies the provided testing function.
|
|
1624
|
-
* @function
|
|
1625
|
-
* @memberof CrossBrowser
|
|
1626
|
-
* @param - The array `findIndex` was called upon.
|
|
1627
|
-
* @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
|
|
1628
|
-
* @param - Returns defaultIndex if not found by the function.
|
|
1629
|
-
* @example
|
|
1630
|
-
import { findIndex } from "@daybrush/utils";
|
|
1631
|
-
|
|
1632
|
-
findIndex([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // 1
|
|
1633
|
-
*/
|
|
1634
|
-
|
|
1635
|
-
function findIndex(arr, callback, defaultIndex) {
|
|
1636
|
-
if (defaultIndex === void 0) {
|
|
1637
|
-
defaultIndex = -1;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
var length = arr.length;
|
|
1641
|
-
|
|
1642
|
-
for (var i = 0; i < length; ++i) {
|
|
1643
|
-
if (callback(arr[i], i, arr)) {
|
|
1644
|
-
return i;
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
return defaultIndex;
|
|
1649
|
-
}
|
|
1650
|
-
/**
|
|
1651
|
-
* Sets up a function that will be called whenever the specified event is delivered to the target
|
|
1652
|
-
* @memberof DOM
|
|
1653
|
-
* @param - event target
|
|
1654
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1655
|
-
* @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
|
1656
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1657
|
-
* @example
|
|
1658
|
-
import {addEvent} from "@daybrush/utils";
|
|
1659
|
-
|
|
1660
|
-
addEvent(el, "click", e => {
|
|
1661
|
-
console.log(e);
|
|
1662
|
-
});
|
|
1663
|
-
*/
|
|
1664
|
-
|
|
1665
|
-
function addEvent(el, type, listener, options) {
|
|
1666
|
-
el.addEventListener(type, listener, options);
|
|
1667
|
-
}
|
|
1668
|
-
/**
|
|
1669
|
-
* removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
|
|
1670
|
-
* @memberof DOM
|
|
1671
|
-
* @param - event target
|
|
1672
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1673
|
-
* @param - The EventListener function of the event handler to remove from the event target.
|
|
1674
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1675
|
-
* @example
|
|
1676
|
-
import {addEvent, removeEvent} from "@daybrush/utils";
|
|
1677
|
-
const listener = e => {
|
|
1678
|
-
console.log(e);
|
|
1679
|
-
};
|
|
1680
|
-
addEvent(el, "click", listener);
|
|
1681
|
-
removeEvent(el, "click", listener);
|
|
1682
|
-
*/
|
|
1683
|
-
|
|
1684
|
-
function removeEvent(el, type, listener, options) {
|
|
1685
|
-
el.removeEventListener(type, listener, options);
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
/*
|
|
1689
|
-
Copyright (c) 2019 Daybrush
|
|
1690
|
-
name: @scena/event-emitter
|
|
1691
|
-
license: MIT
|
|
1692
|
-
author: Daybrush
|
|
1693
|
-
repository: git+https://github.com/daybrush/gesture.git
|
|
1694
|
-
version: 1.0.5
|
|
1695
|
-
*/
|
|
1696
|
-
|
|
1697
|
-
/*! *****************************************************************************
|
|
1698
|
-
Copyright (c) Microsoft Corporation.
|
|
1699
|
-
|
|
1700
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1701
|
-
purpose with or without fee is hereby granted.
|
|
1702
|
-
|
|
1703
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1704
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1705
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1706
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1707
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1708
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1709
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1710
|
-
***************************************************************************** */
|
|
1711
|
-
var __assign$1 = function () {
|
|
1712
|
-
__assign$1 = Object.assign || function __assign(t) {
|
|
1713
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1714
|
-
s = arguments[i];
|
|
1715
|
-
|
|
1716
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
return t;
|
|
1720
|
-
};
|
|
1721
|
-
|
|
1722
|
-
return __assign$1.apply(this, arguments);
|
|
1723
|
-
};
|
|
1724
|
-
function __spreadArrays() {
|
|
1725
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
1726
|
-
|
|
1727
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
|
|
1728
|
-
|
|
1729
|
-
return r;
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
/**
|
|
1733
|
-
* Implement EventEmitter on object or component.
|
|
1734
|
-
*/
|
|
1735
|
-
|
|
1736
|
-
var EventEmitter =
|
|
1737
|
-
/*#__PURE__*/
|
|
1738
|
-
function () {
|
|
1739
|
-
function EventEmitter() {
|
|
1740
|
-
this._events = {};
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Add a listener to the registered event.
|
|
1744
|
-
* @param - Name of the event to be added
|
|
1745
|
-
* @param - listener function of the event to be added
|
|
1746
|
-
* @example
|
|
1747
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1748
|
-
* cosnt emitter = new EventEmitter();
|
|
1749
|
-
*
|
|
1750
|
-
* // Add listener in "a" event
|
|
1751
|
-
* emitter.on("a", () => {
|
|
1752
|
-
* });
|
|
1753
|
-
* // Add listeners
|
|
1754
|
-
* emitter.on({
|
|
1755
|
-
* a: () => {},
|
|
1756
|
-
* b: () => {},
|
|
1757
|
-
* });
|
|
1758
|
-
*/
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
var __proto = EventEmitter.prototype;
|
|
1762
|
-
|
|
1763
|
-
__proto.on = function (eventName, listener) {
|
|
1764
|
-
if (isObject(eventName)) {
|
|
1765
|
-
for (var name in eventName) {
|
|
1766
|
-
this.on(name, eventName[name]);
|
|
1767
|
-
}
|
|
1768
|
-
} else {
|
|
1769
|
-
this._addEvent(eventName, listener, {});
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1772
|
-
return this;
|
|
1773
|
-
};
|
|
1774
|
-
/**
|
|
1775
|
-
* Remove listeners registered in the event target.
|
|
1776
|
-
* @param - Name of the event to be removed
|
|
1777
|
-
* @param - listener function of the event to be removed
|
|
1778
|
-
* @example
|
|
1779
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1780
|
-
* cosnt emitter = new EventEmitter();
|
|
1781
|
-
*
|
|
1782
|
-
* // Remove all listeners.
|
|
1783
|
-
* emitter.off();
|
|
1784
|
-
*
|
|
1785
|
-
* // Remove all listeners in "A" event.
|
|
1786
|
-
* emitter.off("a");
|
|
1787
|
-
*
|
|
1788
|
-
*
|
|
1789
|
-
* // Remove "listener" listener in "a" event.
|
|
1790
|
-
* emitter.off("a", listener);
|
|
1791
|
-
*/
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
__proto.off = function (eventName, listener) {
|
|
1795
|
-
if (!eventName) {
|
|
1796
|
-
this._events = {};
|
|
1797
|
-
} else if (isObject(eventName)) {
|
|
1798
|
-
for (var name in eventName) {
|
|
1799
|
-
this.off(name);
|
|
1800
|
-
}
|
|
1801
|
-
} else if (!listener) {
|
|
1802
|
-
this._events[eventName] = [];
|
|
1803
|
-
} else {
|
|
1804
|
-
var events = this._events[eventName];
|
|
1805
|
-
|
|
1806
|
-
if (events) {
|
|
1807
|
-
var index = findIndex(events, function (e) {
|
|
1808
|
-
return e.listener === listener;
|
|
1809
|
-
});
|
|
1810
|
-
|
|
1811
|
-
if (index > -1) {
|
|
1812
|
-
events.splice(index, 1);
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
return this;
|
|
1818
|
-
};
|
|
1819
|
-
/**
|
|
1820
|
-
* Add a disposable listener and Use promise to the registered event.
|
|
1821
|
-
* @param - Name of the event to be added
|
|
1822
|
-
* @param - disposable listener function of the event to be added
|
|
1823
|
-
* @example
|
|
1824
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1825
|
-
* cosnt emitter = new EventEmitter();
|
|
1826
|
-
*
|
|
1827
|
-
* // Add a disposable listener in "a" event
|
|
1828
|
-
* emitter.once("a", () => {
|
|
1829
|
-
* });
|
|
1830
|
-
*
|
|
1831
|
-
* // Use Promise
|
|
1832
|
-
* emitter.once("a").then(e => {
|
|
1833
|
-
* });
|
|
1834
|
-
*/
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
__proto.once = function (eventName, listener) {
|
|
1838
|
-
var _this = this;
|
|
1839
|
-
|
|
1840
|
-
if (listener) {
|
|
1841
|
-
this._addEvent(eventName, listener, {
|
|
1842
|
-
once: true
|
|
1843
|
-
});
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
return new Promise(function (resolve) {
|
|
1847
|
-
_this._addEvent(eventName, resolve, {
|
|
1848
|
-
once: true
|
|
1849
|
-
});
|
|
1850
|
-
});
|
|
1851
|
-
};
|
|
1852
|
-
/**
|
|
1853
|
-
* Fires an event to call listeners.
|
|
1854
|
-
* @param - Event name
|
|
1855
|
-
* @param - Event parameter
|
|
1856
|
-
* @return If false, stop the event.
|
|
1857
|
-
* @example
|
|
1858
|
-
*
|
|
1859
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
1862
|
-
* const emitter = new EventEmitter();
|
|
1863
|
-
*
|
|
1864
|
-
* emitter.on("a", e => {
|
|
1865
|
-
* });
|
|
1866
|
-
*
|
|
1867
|
-
*
|
|
1868
|
-
* emitter.emit("a", {
|
|
1869
|
-
* a: 1,
|
|
1870
|
-
* });
|
|
1871
|
-
*/
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
__proto.emit = function (eventName, param) {
|
|
1875
|
-
var _this = this;
|
|
1876
|
-
|
|
1877
|
-
if (param === void 0) {
|
|
1878
|
-
param = {};
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
|
-
var events = this._events[eventName];
|
|
1882
|
-
|
|
1883
|
-
if (!eventName || !events) {
|
|
1884
|
-
return true;
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
var isStop = false;
|
|
1888
|
-
param.eventType = eventName;
|
|
1889
|
-
|
|
1890
|
-
param.stop = function () {
|
|
1891
|
-
isStop = true;
|
|
1892
|
-
};
|
|
1893
|
-
|
|
1894
|
-
param.currentTarget = this;
|
|
1895
|
-
|
|
1896
|
-
__spreadArrays(events).forEach(function (info) {
|
|
1897
|
-
info.listener(param);
|
|
1898
|
-
|
|
1899
|
-
if (info.once) {
|
|
1900
|
-
_this.off(eventName, info.listener);
|
|
1901
|
-
}
|
|
1902
|
-
});
|
|
1903
|
-
|
|
1904
|
-
return !isStop;
|
|
1905
|
-
};
|
|
1906
|
-
/**
|
|
1907
|
-
* Fires an event to call listeners.
|
|
1908
|
-
* @param - Event name
|
|
1909
|
-
* @param - Event parameter
|
|
1910
|
-
* @return If false, stop the event.
|
|
1911
|
-
* @example
|
|
1912
|
-
*
|
|
1913
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1914
|
-
*
|
|
1915
|
-
*
|
|
1916
|
-
* const emitter = new EventEmitter();
|
|
1917
|
-
*
|
|
1918
|
-
* emitter.on("a", e => {
|
|
1919
|
-
* });
|
|
1920
|
-
*
|
|
1921
|
-
*
|
|
1922
|
-
* emitter.emit("a", {
|
|
1923
|
-
* a: 1,
|
|
1924
|
-
* });
|
|
1925
|
-
*/
|
|
1926
|
-
|
|
1927
|
-
/**
|
|
1928
|
-
* Fires an event to call listeners.
|
|
1929
|
-
* @param - Event name
|
|
1930
|
-
* @param - Event parameter
|
|
1931
|
-
* @return If false, stop the event.
|
|
1932
|
-
* @example
|
|
1933
|
-
*
|
|
1934
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1937
|
-
* const emitter = new EventEmitter();
|
|
1938
|
-
*
|
|
1939
|
-
* emitter.on("a", e => {
|
|
1940
|
-
* });
|
|
1941
|
-
*
|
|
1942
|
-
* // emit
|
|
1943
|
-
* emitter.trigger("a", {
|
|
1944
|
-
* a: 1,
|
|
1945
|
-
* });
|
|
1946
|
-
*/
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
__proto.trigger = function (eventName, param) {
|
|
1950
|
-
if (param === void 0) {
|
|
1951
|
-
param = {};
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
return this.emit(eventName, param);
|
|
1955
|
-
};
|
|
1956
|
-
|
|
1957
|
-
__proto._addEvent = function (eventName, listener, options) {
|
|
1958
|
-
var events = this._events;
|
|
1959
|
-
events[eventName] = events[eventName] || [];
|
|
1960
|
-
var listeners = events[eventName];
|
|
1961
|
-
listeners.push(__assign$1({
|
|
1962
|
-
listener: listener
|
|
1963
|
-
}, options));
|
|
1964
|
-
};
|
|
1965
|
-
|
|
1966
|
-
return EventEmitter;
|
|
1967
|
-
}();
|
|
1968
|
-
|
|
1969
|
-
var EventEmitter$1 = EventEmitter;
|
|
1970
|
-
|
|
1971
|
-
/*
|
|
1972
|
-
Copyright (c) 2019 Daybrush
|
|
1973
|
-
name: gesto
|
|
1974
|
-
license: MIT
|
|
1975
|
-
author: Daybrush
|
|
1976
|
-
repository: git+https://github.com/daybrush/gesto.git
|
|
1977
|
-
version: 1.7.0
|
|
1978
|
-
*/
|
|
1979
|
-
|
|
1980
|
-
/*! *****************************************************************************
|
|
1981
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1982
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
1983
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
1984
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1985
|
-
|
|
1986
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
1987
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
1988
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
1989
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
1990
|
-
|
|
1991
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
1992
|
-
and limitations under the License.
|
|
1993
|
-
***************************************************************************** */
|
|
1994
|
-
|
|
1995
|
-
/* global Reflect, Promise */
|
|
1996
|
-
var extendStatics = function (d, b) {
|
|
1997
|
-
extendStatics = Object.setPrototypeOf || {
|
|
1998
|
-
__proto__: []
|
|
1999
|
-
} instanceof Array && function (d, b) {
|
|
2000
|
-
d.__proto__ = b;
|
|
2001
|
-
} || function (d, b) {
|
|
2002
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
2003
|
-
};
|
|
2004
|
-
|
|
2005
|
-
return extendStatics(d, b);
|
|
2006
|
-
};
|
|
2007
|
-
|
|
2008
|
-
function __extends(d, b) {
|
|
2009
|
-
extendStatics(d, b);
|
|
2010
|
-
|
|
2011
|
-
function __() {
|
|
2012
|
-
this.constructor = d;
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2016
|
-
}
|
|
2017
|
-
var __assign = function () {
|
|
2018
|
-
__assign = Object.assign || function __assign(t) {
|
|
2019
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2020
|
-
s = arguments[i];
|
|
2021
|
-
|
|
2022
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
return t;
|
|
2026
|
-
};
|
|
2027
|
-
|
|
2028
|
-
return __assign.apply(this, arguments);
|
|
2029
|
-
};
|
|
2030
|
-
|
|
2031
|
-
function getRad(pos1, pos2) {
|
|
2032
|
-
var distX = pos2[0] - pos1[0];
|
|
2033
|
-
var distY = pos2[1] - pos1[1];
|
|
2034
|
-
var rad = Math.atan2(distY, distX);
|
|
2035
|
-
return rad >= 0 ? rad : rad + Math.PI * 2;
|
|
2036
|
-
}
|
|
2037
|
-
function getRotatiion(touches) {
|
|
2038
|
-
return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
|
|
2039
|
-
}
|
|
2040
|
-
function isMultiTouch(e) {
|
|
2041
|
-
return e.touches && e.touches.length >= 2;
|
|
2042
|
-
}
|
|
2043
|
-
function getEventClients(e) {
|
|
2044
|
-
if (e.touches) {
|
|
2045
|
-
return getClients(e.touches);
|
|
2046
|
-
} else {
|
|
2047
|
-
return [getClient(e)];
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
function getPosition(clients, prevClients, startClients) {
|
|
2051
|
-
var length = startClients.length;
|
|
2052
|
-
|
|
2053
|
-
var _a = getAverageClient(clients, length),
|
|
2054
|
-
clientX = _a.clientX,
|
|
2055
|
-
clientY = _a.clientY,
|
|
2056
|
-
originalClientX = _a.originalClientX,
|
|
2057
|
-
originalClientY = _a.originalClientY;
|
|
2058
|
-
|
|
2059
|
-
var _b = getAverageClient(prevClients, length),
|
|
2060
|
-
prevX = _b.clientX,
|
|
2061
|
-
prevY = _b.clientY;
|
|
2062
|
-
|
|
2063
|
-
var _c = getAverageClient(startClients, length),
|
|
2064
|
-
startX = _c.clientX,
|
|
2065
|
-
startY = _c.clientY;
|
|
2066
|
-
|
|
2067
|
-
var deltaX = clientX - prevX;
|
|
2068
|
-
var deltaY = clientY - prevY;
|
|
2069
|
-
var distX = clientX - startX;
|
|
2070
|
-
var distY = clientY - startY;
|
|
2071
|
-
return {
|
|
2072
|
-
clientX: originalClientX,
|
|
2073
|
-
clientY: originalClientY,
|
|
2074
|
-
deltaX: deltaX,
|
|
2075
|
-
deltaY: deltaY,
|
|
2076
|
-
distX: distX,
|
|
2077
|
-
distY: distY
|
|
2078
|
-
};
|
|
2079
|
-
}
|
|
2080
|
-
function getDist(clients) {
|
|
2081
|
-
return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
|
|
2082
|
-
}
|
|
2083
|
-
function getClients(touches) {
|
|
2084
|
-
var length = Math.min(touches.length, 2);
|
|
2085
|
-
var clients = [];
|
|
2086
|
-
|
|
2087
|
-
for (var i = 0; i < length; ++i) {
|
|
2088
|
-
clients.push(getClient(touches[i]));
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
return clients;
|
|
2092
|
-
}
|
|
2093
|
-
function getClient(e) {
|
|
2094
|
-
return {
|
|
2095
|
-
clientX: e.clientX,
|
|
2096
|
-
clientY: e.clientY
|
|
2097
|
-
};
|
|
2098
|
-
}
|
|
2099
|
-
function getAverageClient(clients, length) {
|
|
2100
|
-
if (length === void 0) {
|
|
2101
|
-
length = clients.length;
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
|
-
var sumClient = {
|
|
2105
|
-
clientX: 0,
|
|
2106
|
-
clientY: 0,
|
|
2107
|
-
originalClientX: 0,
|
|
2108
|
-
originalClientY: 0
|
|
2109
|
-
};
|
|
2110
|
-
|
|
2111
|
-
for (var i = 0; i < length; ++i) {
|
|
2112
|
-
var client = clients[i];
|
|
2113
|
-
sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
|
|
2114
|
-
sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
|
|
2115
|
-
sumClient.clientX += client.clientX;
|
|
2116
|
-
sumClient.clientY += client.clientY;
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
if (!length) {
|
|
2120
|
-
return sumClient;
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
return {
|
|
2124
|
-
clientX: sumClient.clientX / length,
|
|
2125
|
-
clientY: sumClient.clientY / length,
|
|
2126
|
-
originalClientX: sumClient.originalClientX / length,
|
|
2127
|
-
originalClientY: sumClient.originalClientY / length
|
|
2128
|
-
};
|
|
2129
|
-
}
|
|
2130
|
-
|
|
2131
|
-
var ClientStore =
|
|
2132
|
-
/*#__PURE__*/
|
|
2133
|
-
function () {
|
|
2134
|
-
function ClientStore(clients) {
|
|
2135
|
-
this.prevClients = [];
|
|
2136
|
-
this.startClients = [];
|
|
2137
|
-
this.movement = 0;
|
|
2138
|
-
this.length = 0;
|
|
2139
|
-
this.startClients = clients;
|
|
2140
|
-
this.prevClients = clients;
|
|
2141
|
-
this.length = clients.length;
|
|
2142
|
-
}
|
|
2143
|
-
|
|
2144
|
-
var __proto = ClientStore.prototype;
|
|
2145
|
-
|
|
2146
|
-
__proto.getAngle = function (clients) {
|
|
2147
|
-
if (clients === void 0) {
|
|
2148
|
-
clients = this.prevClients;
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
return getRotatiion(clients);
|
|
2152
|
-
};
|
|
2153
|
-
|
|
2154
|
-
__proto.getRotation = function (clients) {
|
|
2155
|
-
if (clients === void 0) {
|
|
2156
|
-
clients = this.prevClients;
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
2160
|
-
};
|
|
2161
|
-
|
|
2162
|
-
__proto.getPosition = function (clients, isAdd) {
|
|
2163
|
-
if (clients === void 0) {
|
|
2164
|
-
clients = this.prevClients;
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
var position = getPosition(clients || this.prevClients, this.prevClients, this.startClients);
|
|
2168
|
-
var deltaX = position.deltaX,
|
|
2169
|
-
deltaY = position.deltaY;
|
|
2170
|
-
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
2171
|
-
this.prevClients = clients;
|
|
2172
|
-
return position;
|
|
2173
|
-
};
|
|
2174
|
-
|
|
2175
|
-
__proto.getPositions = function (clients) {
|
|
2176
|
-
if (clients === void 0) {
|
|
2177
|
-
clients = this.prevClients;
|
|
2178
|
-
}
|
|
2179
|
-
|
|
2180
|
-
var prevClients = this.prevClients;
|
|
2181
|
-
return this.startClients.map(function (startClient, i) {
|
|
2182
|
-
return getPosition([clients[i]], [prevClients[i]], [startClient]);
|
|
2183
|
-
});
|
|
2184
|
-
};
|
|
2185
|
-
|
|
2186
|
-
__proto.getMovement = function (clients) {
|
|
2187
|
-
var movement = this.movement;
|
|
2188
|
-
|
|
2189
|
-
if (!clients) {
|
|
2190
|
-
return movement;
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
var currentClient = getAverageClient(clients, this.length);
|
|
2194
|
-
var prevClient = getAverageClient(this.prevClients, this.length);
|
|
2195
|
-
var deltaX = currentClient.clientX - prevClient.clientX;
|
|
2196
|
-
var deltaY = currentClient.clientY - prevClient.clientY;
|
|
2197
|
-
return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
|
|
2198
|
-
};
|
|
2199
|
-
|
|
2200
|
-
__proto.getDistance = function (clients) {
|
|
2201
|
-
if (clients === void 0) {
|
|
2202
|
-
clients = this.prevClients;
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
|
-
return getDist(clients);
|
|
2206
|
-
};
|
|
2207
|
-
|
|
2208
|
-
__proto.getScale = function (clients) {
|
|
2209
|
-
if (clients === void 0) {
|
|
2210
|
-
clients = this.prevClients;
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2213
|
-
return getDist(clients) / getDist(this.startClients);
|
|
2214
|
-
};
|
|
2215
|
-
|
|
2216
|
-
__proto.move = function (deltaX, deltaY) {
|
|
2217
|
-
this.startClients.forEach(function (client) {
|
|
2218
|
-
client.clientX -= deltaX;
|
|
2219
|
-
client.clientY -= deltaY;
|
|
2220
|
-
});
|
|
2221
|
-
};
|
|
2222
|
-
|
|
2223
|
-
return ClientStore;
|
|
2224
|
-
}();
|
|
2225
|
-
|
|
2226
|
-
var INPUT_TAGNAMES = ["textarea", "input"];
|
|
2227
|
-
/**
|
|
2228
|
-
* You can set up drag, pinch events in any browser.
|
|
2229
|
-
*/
|
|
2230
|
-
|
|
2231
|
-
var Gesto =
|
|
2232
|
-
/*#__PURE__*/
|
|
2233
|
-
function (_super) {
|
|
2234
|
-
__extends(Gesto, _super);
|
|
2235
|
-
/**
|
|
2236
|
-
*
|
|
2237
|
-
*/
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
function Gesto(targets, options) {
|
|
2241
|
-
if (options === void 0) {
|
|
2242
|
-
options = {};
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
var _this = _super.call(this) || this;
|
|
2246
|
-
|
|
2247
|
-
_this.options = {};
|
|
2248
|
-
_this.flag = false;
|
|
2249
|
-
_this.pinchFlag = false;
|
|
2250
|
-
_this.datas = {};
|
|
2251
|
-
_this.isDrag = false;
|
|
2252
|
-
_this.isPinch = false;
|
|
2253
|
-
_this.isMouse = false;
|
|
2254
|
-
_this.isTouch = false;
|
|
2255
|
-
_this.clientStores = [];
|
|
2256
|
-
_this.targets = [];
|
|
2257
|
-
_this.prevTime = 0;
|
|
2258
|
-
_this.doubleFlag = false;
|
|
2259
|
-
_this._dragFlag = false;
|
|
2260
|
-
|
|
2261
|
-
_this.onDragStart = function (e, isTrusted) {
|
|
2262
|
-
if (isTrusted === void 0) {
|
|
2263
|
-
isTrusted = true;
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
if (!_this.flag && e.cancelable === false) {
|
|
2267
|
-
return;
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
var _a = _this.options,
|
|
2271
|
-
container = _a.container,
|
|
2272
|
-
pinchOutside = _a.pinchOutside,
|
|
2273
|
-
preventRightClick = _a.preventRightClick,
|
|
2274
|
-
preventDefault = _a.preventDefault,
|
|
2275
|
-
checkInput = _a.checkInput;
|
|
2276
|
-
var isTouch = _this.isTouch;
|
|
2277
|
-
var isDragStart = !_this.flag;
|
|
2278
|
-
|
|
2279
|
-
if (isDragStart) {
|
|
2280
|
-
var activeElement = document.activeElement;
|
|
2281
|
-
var target = e.target;
|
|
2282
|
-
var tagName = target.tagName.toLowerCase();
|
|
2283
|
-
var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
|
|
2284
|
-
var hasContentEditable = target.isContentEditable;
|
|
2285
|
-
|
|
2286
|
-
if (hasInput || hasContentEditable) {
|
|
2287
|
-
if (checkInput || activeElement === target) {
|
|
2288
|
-
// force false or already focused.
|
|
2289
|
-
return false;
|
|
2290
|
-
} // no focus
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2294
|
-
return false;
|
|
2295
|
-
}
|
|
2296
|
-
} else if ((preventDefault || e.type === "touchstart") && activeElement) {
|
|
2297
|
-
var activeTagName = activeElement.tagName;
|
|
2298
|
-
|
|
2299
|
-
if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
|
|
2300
|
-
activeElement.blur();
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2305
|
-
_this.flag = true;
|
|
2306
|
-
_this.isDrag = false;
|
|
2307
|
-
_this._dragFlag = true;
|
|
2308
|
-
_this.datas = {};
|
|
2309
|
-
|
|
2310
|
-
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
2311
|
-
_this.initDrag();
|
|
2312
|
-
|
|
2313
|
-
return false;
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
_this.doubleFlag = now() - _this.prevTime < 200;
|
|
2317
|
-
|
|
2318
|
-
var result = _this.emit("dragStart", __assign({
|
|
2319
|
-
datas: _this.datas,
|
|
2320
|
-
inputEvent: e,
|
|
2321
|
-
isTrusted: isTrusted,
|
|
2322
|
-
isDouble: _this.doubleFlag
|
|
2323
|
-
}, _this.getCurrentStore().getPosition(), {
|
|
2324
|
-
preventDefault: function () {
|
|
2325
|
-
e.preventDefault();
|
|
2326
|
-
},
|
|
2327
|
-
preventDrag: function () {
|
|
2328
|
-
_this._dragFlag = false;
|
|
2329
|
-
}
|
|
2330
|
-
}));
|
|
2331
|
-
|
|
2332
|
-
if (result === false) {
|
|
2333
|
-
_this.initDrag();
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
_this.flag && preventDefault && e.preventDefault();
|
|
2337
|
-
}
|
|
2338
|
-
|
|
2339
|
-
if (!_this.flag) {
|
|
2340
|
-
return false;
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2343
|
-
var timer = 0;
|
|
2344
|
-
|
|
2345
|
-
if (isDragStart && isTouch && pinchOutside) {
|
|
2346
|
-
timer = setTimeout(function () {
|
|
2347
|
-
addEvent(container, "touchstart", _this.onDragStart, {
|
|
2348
|
-
passive: false
|
|
2349
|
-
});
|
|
2350
|
-
});
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
if (!isDragStart && isTouch && pinchOutside) {
|
|
2354
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2355
|
-
}
|
|
2356
|
-
|
|
2357
|
-
if (_this.flag && isMultiTouch(e)) {
|
|
2358
|
-
clearTimeout(timer);
|
|
2359
|
-
|
|
2360
|
-
if (isDragStart && e.touches.length !== e.changedTouches.length) {
|
|
2361
|
-
return;
|
|
2362
|
-
}
|
|
2363
|
-
|
|
2364
|
-
if (!_this.pinchFlag) {
|
|
2365
|
-
_this.onPinchStart(e);
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
};
|
|
2369
|
-
|
|
2370
|
-
_this.onDrag = function (e, isScroll) {
|
|
2371
|
-
if (!_this.flag) {
|
|
2372
|
-
return;
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
var clients = getEventClients(e);
|
|
2376
|
-
|
|
2377
|
-
var result = _this.moveClients(clients, e, false);
|
|
2378
|
-
|
|
2379
|
-
if (_this._dragFlag) {
|
|
2380
|
-
if (_this.pinchFlag || result.deltaX || result.deltaY) {
|
|
2381
|
-
var dragResult = _this.emit("drag", __assign({}, result, {
|
|
2382
|
-
isScroll: !!isScroll,
|
|
2383
|
-
inputEvent: e
|
|
2384
|
-
}));
|
|
2385
|
-
|
|
2386
|
-
if (dragResult === false) {
|
|
2387
|
-
_this.stop();
|
|
2388
|
-
|
|
2389
|
-
return;
|
|
2390
|
-
}
|
|
2391
|
-
}
|
|
2392
|
-
|
|
2393
|
-
if (_this.pinchFlag) {
|
|
2394
|
-
_this.onPinch(e, clients);
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
_this.getCurrentStore().getPosition(clients, true);
|
|
2399
|
-
};
|
|
2400
|
-
|
|
2401
|
-
_this.onDragEnd = function (e) {
|
|
2402
|
-
if (!_this.flag) {
|
|
2403
|
-
return;
|
|
2404
|
-
}
|
|
2405
|
-
|
|
2406
|
-
var _a = _this.options,
|
|
2407
|
-
pinchOutside = _a.pinchOutside,
|
|
2408
|
-
container = _a.container;
|
|
2409
|
-
|
|
2410
|
-
if (_this.isTouch && pinchOutside) {
|
|
2411
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
_this.flag = false;
|
|
2415
|
-
|
|
2416
|
-
var position = _this._getPosition();
|
|
2417
|
-
|
|
2418
|
-
var currentTime = now();
|
|
2419
|
-
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
2420
|
-
_this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
|
|
2421
|
-
|
|
2422
|
-
_this.emit("dragEnd", __assign({
|
|
2423
|
-
datas: _this.datas,
|
|
2424
|
-
isDouble: isDouble,
|
|
2425
|
-
isDrag: _this.isDrag,
|
|
2426
|
-
isClick: !_this.isDrag,
|
|
2427
|
-
inputEvent: e
|
|
2428
|
-
}, position));
|
|
2429
|
-
|
|
2430
|
-
if (_this.pinchFlag) {
|
|
2431
|
-
_this.onPinchEnd(e);
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
_this.clientStores = [];
|
|
2435
|
-
};
|
|
2436
|
-
|
|
2437
|
-
_this.onBlur = function () {
|
|
2438
|
-
_this.onDragEnd();
|
|
2439
|
-
};
|
|
2440
|
-
|
|
2441
|
-
var elements = [].concat(targets);
|
|
2442
|
-
_this.options = __assign({
|
|
2443
|
-
checkInput: false,
|
|
2444
|
-
container: elements.length > 1 ? window : elements[0],
|
|
2445
|
-
preventRightClick: true,
|
|
2446
|
-
preventDefault: true,
|
|
2447
|
-
checkWindowBlur: false,
|
|
2448
|
-
pinchThreshold: 0,
|
|
2449
|
-
events: ["touch", "mouse"]
|
|
2450
|
-
}, options);
|
|
2451
|
-
var _a = _this.options,
|
|
2452
|
-
container = _a.container,
|
|
2453
|
-
events = _a.events,
|
|
2454
|
-
checkWindowBlur = _a.checkWindowBlur;
|
|
2455
|
-
_this.isTouch = events.indexOf("touch") > -1;
|
|
2456
|
-
_this.isMouse = events.indexOf("mouse") > -1;
|
|
2457
|
-
_this.targets = elements;
|
|
2458
|
-
|
|
2459
|
-
if (_this.isMouse) {
|
|
2460
|
-
elements.forEach(function (el) {
|
|
2461
|
-
addEvent(el, "mousedown", _this.onDragStart);
|
|
2462
|
-
});
|
|
2463
|
-
addEvent(container, "mousemove", _this.onDrag);
|
|
2464
|
-
addEvent(container, "mouseup", _this.onDragEnd);
|
|
2465
|
-
addEvent(container, "contextmenu", _this.onDragEnd);
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
if (checkWindowBlur) {
|
|
2469
|
-
addEvent(window, "blur", _this.onBlur);
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
if (_this.isTouch) {
|
|
2473
|
-
var passive_1 = {
|
|
2474
|
-
passive: false
|
|
2475
|
-
};
|
|
2476
|
-
elements.forEach(function (el) {
|
|
2477
|
-
addEvent(el, "touchstart", _this.onDragStart, passive_1);
|
|
2478
|
-
});
|
|
2479
|
-
addEvent(container, "touchmove", _this.onDrag, passive_1);
|
|
2480
|
-
addEvent(container, "touchend", _this.onDragEnd, passive_1);
|
|
2481
|
-
addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
|
-
return _this;
|
|
2485
|
-
}
|
|
2486
|
-
/**
|
|
2487
|
-
* Stop Gesto's drag events.
|
|
2488
|
-
*/
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
var __proto = Gesto.prototype;
|
|
2492
|
-
|
|
2493
|
-
__proto.stop = function () {
|
|
2494
|
-
this.isDrag = false;
|
|
2495
|
-
this.flag = false;
|
|
2496
|
-
this.clientStores = [];
|
|
2497
|
-
this.datas = {};
|
|
2498
|
-
};
|
|
2499
|
-
/**
|
|
2500
|
-
* The total moved distance
|
|
2501
|
-
*/
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
__proto.getMovement = function (clients) {
|
|
2505
|
-
return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2506
|
-
return prev + cur.movement;
|
|
2507
|
-
}, 0);
|
|
2508
|
-
};
|
|
2509
|
-
/**
|
|
2510
|
-
* Whether to drag
|
|
2511
|
-
*/
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
__proto.isDragging = function () {
|
|
2515
|
-
return this.isDrag;
|
|
2516
|
-
};
|
|
2517
|
-
/**
|
|
2518
|
-
* Whether to start drag
|
|
2519
|
-
*/
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
__proto.isFlag = function () {
|
|
2523
|
-
return this.flag;
|
|
2524
|
-
};
|
|
2525
|
-
/**
|
|
2526
|
-
* Whether to start pinch
|
|
2527
|
-
*/
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
__proto.isPinchFlag = function () {
|
|
2531
|
-
return this.pinchFlag;
|
|
2532
|
-
};
|
|
2533
|
-
/**
|
|
2534
|
-
* Whether to start double click
|
|
2535
|
-
*/
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
__proto.isDoubleFlag = function () {
|
|
2539
|
-
return this.doubleFlag;
|
|
2540
|
-
};
|
|
2541
|
-
/**
|
|
2542
|
-
* Whether to pinch
|
|
2543
|
-
*/
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
__proto.isPinching = function () {
|
|
2547
|
-
return this.isPinch;
|
|
2548
|
-
};
|
|
2549
|
-
/**
|
|
2550
|
-
* If a scroll event occurs, it is corrected by the scroll distance.
|
|
2551
|
-
*/
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
__proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
|
|
2555
|
-
if (isCallDrag === void 0) {
|
|
2556
|
-
isCallDrag = true;
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
|
-
if (!this.flag) {
|
|
2560
|
-
return;
|
|
2561
|
-
}
|
|
2562
|
-
|
|
2563
|
-
this.clientStores[0].move(deltaX, deltaY);
|
|
2564
|
-
isCallDrag && this.onDrag(e, true);
|
|
2565
|
-
};
|
|
2566
|
-
/**
|
|
2567
|
-
* Create a virtual drag event.
|
|
2568
|
-
*/
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
__proto.move = function (_a, inputEvent) {
|
|
2572
|
-
var deltaX = _a[0],
|
|
2573
|
-
deltaY = _a[1];
|
|
2574
|
-
var store = this.getCurrentStore();
|
|
2575
|
-
var nextClients = store.prevClients;
|
|
2576
|
-
return this.moveClients(nextClients.map(function (_a) {
|
|
2577
|
-
var clientX = _a.clientX,
|
|
2578
|
-
clientY = _a.clientY;
|
|
2579
|
-
return {
|
|
2580
|
-
clientX: clientX + deltaX,
|
|
2581
|
-
clientY: clientY + deltaY,
|
|
2582
|
-
originalClientX: clientX,
|
|
2583
|
-
originalClientY: clientY
|
|
2584
|
-
};
|
|
2585
|
-
}), inputEvent, true);
|
|
2586
|
-
};
|
|
2587
|
-
/**
|
|
2588
|
-
* The dragStart event is triggered by an external event.
|
|
2589
|
-
*/
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
__proto.triggerDragStart = function (e) {
|
|
2593
|
-
this.onDragStart(e, false);
|
|
2594
|
-
};
|
|
2595
|
-
/**
|
|
2596
|
-
* Set the event data while dragging.
|
|
2597
|
-
*/
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
__proto.setEventDatas = function (datas) {
|
|
2601
|
-
var currentDatas = this.datas;
|
|
2602
|
-
|
|
2603
|
-
for (var name in datas) {
|
|
2604
|
-
currentDatas[name] = datas[name];
|
|
2605
|
-
}
|
|
2606
|
-
|
|
2607
|
-
return this;
|
|
2608
|
-
};
|
|
2609
|
-
/**
|
|
2610
|
-
* Get the current event state while dragging.
|
|
2611
|
-
*/
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
__proto.getCurrentEvent = function (inputEvent) {
|
|
2615
|
-
return __assign({
|
|
2616
|
-
datas: this.datas
|
|
2617
|
-
}, this._getPosition(), {
|
|
2618
|
-
movement: this.getMovement(),
|
|
2619
|
-
isDrag: this.isDrag,
|
|
2620
|
-
isPinch: this.isPinch,
|
|
2621
|
-
isScroll: false,
|
|
2622
|
-
inputEvent: inputEvent
|
|
2623
|
-
});
|
|
2624
|
-
};
|
|
2625
|
-
/**
|
|
2626
|
-
* Get & Set the event data while dragging.
|
|
2627
|
-
*/
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
__proto.getEventDatas = function () {
|
|
2631
|
-
return this.datas;
|
|
2632
|
-
};
|
|
2633
|
-
/**
|
|
2634
|
-
* Unset Gesto
|
|
2635
|
-
*/
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
__proto.unset = function () {
|
|
2639
|
-
var _this = this;
|
|
2640
|
-
|
|
2641
|
-
var targets = this.targets;
|
|
2642
|
-
var container = this.options.container;
|
|
2643
|
-
this.off();
|
|
2644
|
-
removeEvent(window, "blur", this.onBlur);
|
|
2645
|
-
|
|
2646
|
-
if (this.isMouse) {
|
|
2647
|
-
targets.forEach(function (target) {
|
|
2648
|
-
removeEvent(target, "mousedown", _this.onDragStart);
|
|
2649
|
-
});
|
|
2650
|
-
removeEvent(container, "mousemove", this.onDrag);
|
|
2651
|
-
removeEvent(container, "mouseup", this.onDragEnd);
|
|
2652
|
-
removeEvent(container, "contextmenu", this.onDragEnd);
|
|
2653
|
-
}
|
|
2654
|
-
|
|
2655
|
-
if (this.isTouch) {
|
|
2656
|
-
targets.forEach(function (target) {
|
|
2657
|
-
removeEvent(target, "touchstart", _this.onDragStart);
|
|
2658
|
-
});
|
|
2659
|
-
removeEvent(container, "touchstart", this.onDragStart);
|
|
2660
|
-
removeEvent(container, "touchmove", this.onDrag);
|
|
2661
|
-
removeEvent(container, "touchend", this.onDragEnd);
|
|
2662
|
-
removeEvent(container, "touchcancel", this.onDragEnd);
|
|
2663
|
-
}
|
|
2664
|
-
};
|
|
2665
|
-
|
|
2666
|
-
__proto.onPinchStart = function (e) {
|
|
2667
|
-
var pinchThreshold = this.options.pinchThreshold;
|
|
2668
|
-
|
|
2669
|
-
if (this.isDrag && this.getMovement() > pinchThreshold) {
|
|
2670
|
-
return;
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
var store = new ClientStore(getEventClients(e));
|
|
2674
|
-
this.pinchFlag = true;
|
|
2675
|
-
this.clientStores.splice(0, 0, store);
|
|
2676
|
-
var result = this.emit("pinchStart", __assign({
|
|
2677
|
-
datas: this.datas,
|
|
2678
|
-
angle: store.getAngle(),
|
|
2679
|
-
touches: this.getCurrentStore().getPositions()
|
|
2680
|
-
}, store.getPosition(), {
|
|
2681
|
-
inputEvent: e
|
|
2682
|
-
}));
|
|
2683
|
-
|
|
2684
|
-
if (result === false) {
|
|
2685
|
-
this.pinchFlag = false;
|
|
2686
|
-
}
|
|
2687
|
-
};
|
|
2688
|
-
|
|
2689
|
-
__proto.onPinch = function (e, clients) {
|
|
2690
|
-
if (!this.flag || !this.pinchFlag || clients.length < 2) {
|
|
2691
|
-
return;
|
|
2692
|
-
}
|
|
2693
|
-
|
|
2694
|
-
var store = this.getCurrentStore();
|
|
2695
|
-
this.isPinch = true;
|
|
2696
|
-
this.emit("pinch", __assign({
|
|
2697
|
-
datas: this.datas,
|
|
2698
|
-
movement: this.getMovement(clients),
|
|
2699
|
-
angle: store.getAngle(clients),
|
|
2700
|
-
rotation: store.getRotation(clients),
|
|
2701
|
-
touches: store.getPositions(clients),
|
|
2702
|
-
scale: store.getScale(clients),
|
|
2703
|
-
distance: store.getDistance(clients)
|
|
2704
|
-
}, store.getPosition(clients), {
|
|
2705
|
-
inputEvent: e
|
|
2706
|
-
}));
|
|
2707
|
-
};
|
|
2708
|
-
|
|
2709
|
-
__proto.onPinchEnd = function (e) {
|
|
2710
|
-
if (!this.pinchFlag) {
|
|
2711
|
-
return;
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
var isPinch = this.isPinch;
|
|
2715
|
-
this.isPinch = false;
|
|
2716
|
-
this.pinchFlag = false;
|
|
2717
|
-
var store = this.getCurrentStore();
|
|
2718
|
-
this.emit("pinchEnd", __assign({
|
|
2719
|
-
datas: this.datas,
|
|
2720
|
-
isPinch: isPinch,
|
|
2721
|
-
touches: store.getPositions()
|
|
2722
|
-
}, store.getPosition(), {
|
|
2723
|
-
inputEvent: e
|
|
2724
|
-
}));
|
|
2725
|
-
this.isPinch = false;
|
|
2726
|
-
this.pinchFlag = false;
|
|
2727
|
-
};
|
|
2728
|
-
|
|
2729
|
-
__proto.initDrag = function () {
|
|
2730
|
-
this.clientStores = [];
|
|
2731
|
-
this.pinchFlag = false;
|
|
2732
|
-
this.doubleFlag = false;
|
|
2733
|
-
this.prevTime = 0;
|
|
2734
|
-
this.flag = false;
|
|
2735
|
-
};
|
|
2736
|
-
|
|
2737
|
-
__proto.getCurrentStore = function () {
|
|
2738
|
-
return this.clientStores[0];
|
|
2739
|
-
};
|
|
2740
|
-
|
|
2741
|
-
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2742
|
-
var position = this._getPosition(clients, isAdd);
|
|
2743
|
-
|
|
2744
|
-
if (position.deltaX || position.deltaY) {
|
|
2745
|
-
this.isDrag = true;
|
|
2746
|
-
}
|
|
2747
|
-
|
|
2748
|
-
return __assign({
|
|
2749
|
-
datas: this.datas
|
|
2750
|
-
}, position, {
|
|
2751
|
-
movement: this.getMovement(clients),
|
|
2752
|
-
isDrag: this.isDrag,
|
|
2753
|
-
isPinch: this.isPinch,
|
|
2754
|
-
isScroll: false,
|
|
2755
|
-
inputEvent: inputEvent
|
|
2756
|
-
});
|
|
2757
|
-
};
|
|
2758
|
-
|
|
2759
|
-
__proto._getPosition = function (clients, isAdd) {
|
|
2760
|
-
var store = this.getCurrentStore();
|
|
2761
|
-
var position = store.getPosition(clients, isAdd);
|
|
2762
|
-
|
|
2763
|
-
var _a = this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2764
|
-
var storePosition = cur.getPosition();
|
|
2765
|
-
prev.distX += storePosition.distX;
|
|
2766
|
-
prev.distY += storePosition.distY;
|
|
2767
|
-
return prev;
|
|
2768
|
-
}, position),
|
|
2769
|
-
distX = _a.distX,
|
|
2770
|
-
distY = _a.distY;
|
|
2771
|
-
|
|
2772
|
-
return __assign({}, position, {
|
|
2773
|
-
distX: distX,
|
|
2774
|
-
distY: distY
|
|
2775
|
-
});
|
|
2776
|
-
};
|
|
2777
|
-
|
|
2778
|
-
return Gesto;
|
|
2779
|
-
}(EventEmitter$1);
|
|
2780
|
-
|
|
2781
|
-
var Gesto$1 = Gesto;
|
|
2782
|
-
|
|
2783
1595
|
const _sfc_main$h = vue.defineComponent({
|
|
2784
1596
|
name: "m-editor-resize",
|
|
2785
1597
|
props: {
|
|
@@ -2794,7 +1606,7 @@
|
|
|
2794
1606
|
vue.onMounted(() => {
|
|
2795
1607
|
if (!target.value)
|
|
2796
1608
|
return;
|
|
2797
|
-
getso = new
|
|
1609
|
+
getso = new Gesto__default["default"](target.value, {
|
|
2798
1610
|
container: window,
|
|
2799
1611
|
pinchOutside: true
|
|
2800
1612
|
}).on("drag", (e) => {
|
|
@@ -2838,6 +1650,12 @@
|
|
|
2838
1650
|
AddPageBox,
|
|
2839
1651
|
Resizer
|
|
2840
1652
|
},
|
|
1653
|
+
props: {
|
|
1654
|
+
codeOptions: {
|
|
1655
|
+
type: Object,
|
|
1656
|
+
default: () => ({})
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
2841
1659
|
setup() {
|
|
2842
1660
|
const { editorService, uiService } = vue.inject("services") || {};
|
|
2843
1661
|
const root = vue.computed(() => editorService?.get("root"));
|
|
@@ -2872,8 +1690,9 @@
|
|
|
2872
1690
|
key: 0,
|
|
2873
1691
|
class: "m-editor-content",
|
|
2874
1692
|
"init-values": _ctx.root,
|
|
1693
|
+
options: _ctx.codeOptions,
|
|
2875
1694
|
onSave: _ctx.saveCode
|
|
2876
|
-
}, null, 8, ["init-values", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
|
|
1695
|
+
}, null, 8, ["init-values", "options", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
|
|
2877
1696
|
vue.createElementVNode("div", {
|
|
2878
1697
|
class: "m-editor-framework-left",
|
|
2879
1698
|
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
@@ -3321,13 +2140,13 @@
|
|
|
3321
2140
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
3322
2141
|
return vue.openBlock(), vue.createBlock(_component_m_form, {
|
|
3323
2142
|
class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
3324
|
-
"popper-class":
|
|
2143
|
+
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
3325
2144
|
ref: "configForm",
|
|
3326
2145
|
size: _ctx.propsPanelSize,
|
|
3327
2146
|
"init-values": _ctx.values,
|
|
3328
2147
|
config: _ctx.curFormConfig,
|
|
3329
2148
|
onChange: _ctx.submit
|
|
3330
|
-
}, null, 8, ["class", "size", "init-values", "config", "onChange"]);
|
|
2149
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
|
|
3331
2150
|
}
|
|
3332
2151
|
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3333
2152
|
|
|
@@ -3507,7 +2326,7 @@
|
|
|
3507
2326
|
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3508
2327
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
3509
2328
|
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
3510
|
-
return _ctx.menuData.length ?
|
|
2329
|
+
return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3511
2330
|
key: 0,
|
|
3512
2331
|
class: "magic-editor-content-menu",
|
|
3513
2332
|
ref: "menu",
|
|
@@ -3531,9 +2350,7 @@
|
|
|
3531
2350
|
"menu-data": _ctx.subMenuData
|
|
3532
2351
|
}, null, 8, ["menu-data"])
|
|
3533
2352
|
]))
|
|
3534
|
-
], 4)),
|
|
3535
|
-
[vue.vShow, _ctx.visible]
|
|
3536
|
-
]) : vue.createCommentVNode("", true);
|
|
2353
|
+
], 4)) : vue.createCommentVNode("", true);
|
|
3537
2354
|
}
|
|
3538
2355
|
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3539
2356
|
|
|
@@ -3833,7 +2650,7 @@
|
|
|
3833
2650
|
components: { MIcon },
|
|
3834
2651
|
props: {
|
|
3835
2652
|
data: {
|
|
3836
|
-
type: Object
|
|
2653
|
+
type: [Object, String]
|
|
3837
2654
|
}
|
|
3838
2655
|
},
|
|
3839
2656
|
setup(props) {
|
|
@@ -4436,8 +3253,17 @@
|
|
|
4436
3253
|
text: "\u7C98\u8D34",
|
|
4437
3254
|
display: () => canPaste.value,
|
|
4438
3255
|
handler: () => {
|
|
4439
|
-
const
|
|
4440
|
-
const
|
|
3256
|
+
const stage = editorService?.get("stage");
|
|
3257
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3258
|
+
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3259
|
+
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3260
|
+
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3261
|
+
if (node.value?.items && stage) {
|
|
3262
|
+
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3263
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3264
|
+
left = left - (parentElRect?.left || 0);
|
|
3265
|
+
top = top - (parentElRect?.top || 0);
|
|
3266
|
+
}
|
|
4441
3267
|
editorService?.paste({ left, top });
|
|
4442
3268
|
}
|
|
4443
3269
|
},
|
|
@@ -4532,6 +3358,7 @@
|
|
|
4532
3358
|
type: Function
|
|
4533
3359
|
},
|
|
4534
3360
|
runtimeUrl: String,
|
|
3361
|
+
autoScrollIntoView: Boolean,
|
|
4535
3362
|
canSelect: {
|
|
4536
3363
|
type: Function,
|
|
4537
3364
|
default: (el) => Boolean(el.id)
|
|
@@ -4567,6 +3394,7 @@
|
|
|
4567
3394
|
render: props.render,
|
|
4568
3395
|
runtimeUrl: props.runtimeUrl,
|
|
4569
3396
|
zoom: zoom.value,
|
|
3397
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
4570
3398
|
canSelect: (el, event, stop) => {
|
|
4571
3399
|
const elCanSelect = props.canSelect(el);
|
|
4572
3400
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -4656,6 +3484,7 @@
|
|
|
4656
3484
|
const { scrollTop, scrollLeft } = stage.mask;
|
|
4657
3485
|
if (layout === Layout.ABSOLUTE) {
|
|
4658
3486
|
config.style = {
|
|
3487
|
+
...config.style || {},
|
|
4659
3488
|
position: "absolute",
|
|
4660
3489
|
top: e.clientY - containerRect.top + scrollTop,
|
|
4661
3490
|
left: e.clientX - containerRect.left + scrollLeft
|
|
@@ -4703,6 +3532,7 @@
|
|
|
4703
3532
|
},
|
|
4704
3533
|
props: {
|
|
4705
3534
|
runtimeUrl: String,
|
|
3535
|
+
autoScrollIntoView: Boolean,
|
|
4706
3536
|
render: {
|
|
4707
3537
|
type: Function
|
|
4708
3538
|
},
|
|
@@ -4721,8 +3551,12 @@
|
|
|
4721
3551
|
const mouseenterHandler = () => {
|
|
4722
3552
|
workspace.value?.focus();
|
|
4723
3553
|
};
|
|
3554
|
+
const mouseleaveHandler = () => {
|
|
3555
|
+
workspace.value?.blur();
|
|
3556
|
+
};
|
|
4724
3557
|
vue.onMounted(() => {
|
|
4725
3558
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3559
|
+
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
4726
3560
|
keycon = new KeyController__default["default"](workspace.value);
|
|
4727
3561
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4728
3562
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
@@ -4731,6 +3565,11 @@
|
|
|
4731
3565
|
if (!node.value || utils.isPage(node.value))
|
|
4732
3566
|
return;
|
|
4733
3567
|
services?.editorService.remove(node.value);
|
|
3568
|
+
}).keyup("backspace", (e) => {
|
|
3569
|
+
e.inputEvent.preventDefault();
|
|
3570
|
+
if (!node.value || utils.isPage(node.value))
|
|
3571
|
+
return;
|
|
3572
|
+
services?.editorService.remove(node.value);
|
|
4734
3573
|
}).keydown([ctrl, "c"], (e) => {
|
|
4735
3574
|
e.inputEvent.preventDefault();
|
|
4736
3575
|
node.value && services?.editorService.copy(node.value);
|
|
@@ -4782,13 +3621,20 @@
|
|
|
4782
3621
|
}).keydown([ctrl, "="], (e) => {
|
|
4783
3622
|
e.inputEvent.preventDefault();
|
|
4784
3623
|
services?.uiService.zoom(0.1);
|
|
3624
|
+
}).keydown([ctrl, "numpadplus"], (e) => {
|
|
3625
|
+
e.inputEvent.preventDefault();
|
|
3626
|
+
services?.uiService.zoom(0.1);
|
|
4785
3627
|
}).keydown([ctrl, "-"], (e) => {
|
|
4786
3628
|
e.inputEvent.preventDefault();
|
|
4787
3629
|
services?.uiService.zoom(-0.1);
|
|
3630
|
+
}).keydown([ctrl, "numpad-"], (e) => {
|
|
3631
|
+
e.inputEvent.preventDefault();
|
|
3632
|
+
services?.uiService.zoom(-0.1);
|
|
4788
3633
|
});
|
|
4789
3634
|
});
|
|
4790
3635
|
vue.onUnmounted(() => {
|
|
4791
3636
|
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
3637
|
+
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4792
3638
|
keycon.destroy();
|
|
4793
3639
|
});
|
|
4794
3640
|
return {
|
|
@@ -4809,10 +3655,11 @@
|
|
|
4809
3655
|
(vue.openBlock(), vue.createBlock(_component_magic_stage, {
|
|
4810
3656
|
key: _ctx.page?.id,
|
|
4811
3657
|
"runtime-url": _ctx.runtimeUrl,
|
|
3658
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
4812
3659
|
render: _ctx.render,
|
|
4813
3660
|
"moveable-options": _ctx.moveableOptions,
|
|
4814
3661
|
"can-select": _ctx.canSelect
|
|
4815
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select"])),
|
|
3662
|
+
}, null, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])),
|
|
4816
3663
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4817
3664
|
vue.createVNode(_component_page_bar, null, {
|
|
4818
3665
|
"page-bar-title": vue.withCtx(({ page }) => [
|
|
@@ -4989,6 +3836,7 @@
|
|
|
4989
3836
|
type: Function
|
|
4990
3837
|
},
|
|
4991
3838
|
runtimeUrl: String,
|
|
3839
|
+
autoScrollIntoView: Boolean,
|
|
4992
3840
|
propsConfigs: {
|
|
4993
3841
|
type: Object,
|
|
4994
3842
|
default: () => ({})
|
|
@@ -5012,6 +3860,10 @@
|
|
|
5012
3860
|
},
|
|
5013
3861
|
stageRect: {
|
|
5014
3862
|
type: [String, Object]
|
|
3863
|
+
},
|
|
3864
|
+
codeOptions: {
|
|
3865
|
+
type: Object,
|
|
3866
|
+
default: () => ({})
|
|
5015
3867
|
}
|
|
5016
3868
|
},
|
|
5017
3869
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
@@ -5070,7 +3922,7 @@
|
|
|
5070
3922
|
const _component_workspace = vue.resolveComponent("workspace");
|
|
5071
3923
|
const _component_props_panel = vue.resolveComponent("props-panel");
|
|
5072
3924
|
const _component_framework = vue.resolveComponent("framework");
|
|
5073
|
-
return vue.openBlock(), vue.createBlock(_component_framework,
|
|
3925
|
+
return vue.openBlock(), vue.createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
|
|
5074
3926
|
nav: vue.withCtx(() => [
|
|
5075
3927
|
vue.renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
5076
3928
|
vue.createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
|
|
@@ -5085,6 +3937,7 @@
|
|
|
5085
3937
|
vue.renderSlot(_ctx.$slots, "workspace", {}, () => [
|
|
5086
3938
|
vue.createVNode(_component_workspace, {
|
|
5087
3939
|
"runtime-url": _ctx.runtimeUrl,
|
|
3940
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
5088
3941
|
render: _ctx.render,
|
|
5089
3942
|
"moveable-options": _ctx.moveableOptions,
|
|
5090
3943
|
"can-select": _ctx.canSelect
|
|
@@ -5099,7 +3952,7 @@
|
|
|
5099
3952
|
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
5100
3953
|
]),
|
|
5101
3954
|
_: 3
|
|
5102
|
-
}, 8, ["runtime-url", "render", "moveable-options", "can-select"])
|
|
3955
|
+
}, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])
|
|
5103
3956
|
])
|
|
5104
3957
|
]),
|
|
5105
3958
|
propsPanel: vue.withCtx(() => [
|
|
@@ -5114,7 +3967,7 @@
|
|
|
5114
3967
|
vue.renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
|
|
5115
3968
|
]),
|
|
5116
3969
|
_: 3
|
|
5117
|
-
});
|
|
3970
|
+
}, 8, ["code-options"]);
|
|
5118
3971
|
}
|
|
5119
3972
|
var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
5120
3973
|
|