@tmagic/editor 1.0.0-rc.1 → 1.0.0-rc.2

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.
Files changed (62) hide show
  1. package/coverage/clover.xml +94 -98
  2. package/coverage/coverage-final.json +4 -4
  3. package/coverage/lcov-report/index.html +35 -35
  4. package/coverage/lcov-report/src/Editor.vue.html +24 -9
  5. package/coverage/lcov-report/src/components/ContentMenu.vue.html +1 -1
  6. package/coverage/lcov-report/src/components/Icon.vue.html +1 -1
  7. package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
  8. package/coverage/lcov-report/src/components/ToolButton.vue.html +1 -1
  9. package/coverage/lcov-report/src/components/index.html +1 -1
  10. package/coverage/lcov-report/src/index.html +14 -14
  11. package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
  12. package/coverage/lcov-report/src/layouts/Framework.vue.html +48 -9
  13. package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
  14. package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +2 -2
  15. package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
  16. package/coverage/lcov-report/src/layouts/index.html +15 -15
  17. package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +1 -1
  18. package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +1 -1
  19. package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +1 -1
  20. package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
  21. package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +1 -1
  22. package/coverage/lcov-report/src/layouts/sidebar/index.html +1 -1
  23. package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +1 -1
  24. package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +7 -4
  25. package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +1 -1
  26. package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +68 -56
  27. package/coverage/lcov-report/src/layouts/workspace/index.html +21 -21
  28. package/coverage/lcov-report/src/services/BaseService.ts.html +1 -1
  29. package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
  30. package/coverage/lcov-report/src/services/editor.ts.html +1 -1
  31. package/coverage/lcov-report/src/services/events.ts.html +1 -1
  32. package/coverage/lcov-report/src/services/history.ts.html +1 -1
  33. package/coverage/lcov-report/src/services/index.html +1 -1
  34. package/coverage/lcov-report/src/services/props.ts.html +1 -1
  35. package/coverage/lcov-report/src/services/ui.ts.html +1 -1
  36. package/coverage/lcov-report/src/type.ts.html +1 -1
  37. package/coverage/lcov-report/src/utils/compose.ts.html +1 -1
  38. package/coverage/lcov-report/src/utils/config.ts.html +1 -1
  39. package/coverage/lcov-report/src/utils/editor.ts.html +1 -1
  40. package/coverage/lcov-report/src/utils/index.html +1 -1
  41. package/coverage/lcov-report/src/utils/index.ts.html +1 -1
  42. package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
  43. package/coverage/lcov-report/src/utils/props.ts.html +1 -1
  44. package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
  45. package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
  46. package/coverage/lcov.info +314 -275
  47. package/dist/style.css +3 -3
  48. package/dist/tmagic-editor.es.js +60 -1256
  49. package/dist/tmagic-editor.es.js.map +1 -1
  50. package/dist/tmagic-editor.umd.js +62 -1258
  51. package/dist/tmagic-editor.umd.js.map +1 -1
  52. package/dist/types/src/Editor.vue.d.ts +9 -0
  53. package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
  54. package/package.json +16 -8
  55. package/src/Editor.vue +6 -1
  56. package/src/layouts/CodeEditor.vue +1 -4
  57. package/src/layouts/Framework.vue +14 -1
  58. package/src/layouts/PropsPanel.vue +1 -1
  59. package/src/layouts/workspace/Stage.vue +1 -0
  60. package/src/layouts/workspace/Workspace.vue +37 -33
  61. package/src/theme/props-panel.scss +6 -4
  62. package/src/utils/polyfills.ts +5 -19
@@ -5,15 +5,19 @@ import { throttle, cloneDeep, mergeWith, random } from 'lodash-es';
5
5
  import * as monaco from 'monaco-editor';
6
6
  import { NodeType } from '@tmagic/schema';
7
7
  import { toLine, isPop, getNodePath, isNumber, isPage } from '@tmagic/utils';
8
- import { EventEmitter as EventEmitter$2 } from 'events';
8
+ import { EventEmitter } from 'events';
9
9
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
10
+ import Gesto from 'gesto';
10
11
  import { ElMessage } from 'element-plus';
11
12
  import KeyController from 'keycon';
12
13
  import StageCore from '@tmagic/stage';
13
14
 
14
- if (typeof window.global === "undefined") {
15
+ if (typeof global === "undefined") {
15
16
  window.global = window;
16
17
  }
18
+ if (typeof globalThis === "undefined") {
19
+ window.globalThis = window;
20
+ }
17
21
 
18
22
  var _export_sfc = (sfc, props) => {
19
23
  const target = sfc.__vccOpts || sfc;
@@ -310,11 +314,7 @@ const _sfc_main$j = defineComponent({
310
314
  const options = {
311
315
  value: values.value,
312
316
  language: props.language,
313
- tabSize: 2,
314
317
  theme: "vs-dark",
315
- fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
316
- fontSize: 14,
317
- formatOnPaste: true,
318
318
  ...props.options
319
319
  };
320
320
  if (props.type === "diff") {
@@ -328,6 +328,7 @@ const _sfc_main$j = defineComponent({
328
328
  codeEditor.value.addEventListener("keydown", (e) => {
329
329
  if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
330
330
  e.preventDefault();
331
+ e.stopPropagation();
331
332
  emit("save", getEditorValue());
332
333
  }
333
334
  });
@@ -483,7 +484,7 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
483
484
  throw error;
484
485
  }
485
486
  };
486
- class BaseService extends EventEmitter$2 {
487
+ class BaseService extends EventEmitter {
487
488
  constructor(methods = [], serialMethods = []) {
488
489
  super();
489
490
  this.pluginOptionsList = {};
@@ -1553,1215 +1554,6 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1553
1554
  }
1554
1555
  var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
1555
1556
 
1556
- /*
1557
- Copyright (c) 2018 Daybrush
1558
- @name: @daybrush/utils
1559
- license: MIT
1560
- author: Daybrush
1561
- repository: https://github.com/daybrush/utils
1562
- @version 1.6.0
1563
- */
1564
- /**
1565
- * get string "object"
1566
- * @memberof Consts
1567
- * @example
1568
- import {OBJECT} from "@daybrush/utils";
1569
-
1570
- console.log(OBJECT); // "object"
1571
- */
1572
-
1573
- var OBJECT = "object";
1574
- /**
1575
- * Check the type that the value is object.
1576
- * @memberof Utils
1577
- * @param {string} value - Value to check the type
1578
- * @return {} true if the type is correct, false otherwise
1579
- * @example
1580
- import {isObject} from "@daybrush/utils";
1581
-
1582
- console.log(isObject({})); // true
1583
- console.log(isObject(undefined)); // false
1584
- console.log(isObject("")); // false
1585
- console.log(isObject(null)); // false
1586
- */
1587
-
1588
- function isObject(value) {
1589
- return value && typeof value === OBJECT;
1590
- }
1591
- /**
1592
- * Date.now() method
1593
- * @memberof CrossBrowser
1594
- * @return {number} milliseconds
1595
- * @example
1596
- import {now} from "@daybrush/utils";
1597
-
1598
- console.log(now()); // 12121324241(milliseconds)
1599
- */
1600
-
1601
- function now() {
1602
- return Date.now ? Date.now() : new Date().getTime();
1603
- }
1604
- /**
1605
- * Returns the index of the first element in the array that satisfies the provided testing function.
1606
- * @function
1607
- * @memberof CrossBrowser
1608
- * @param - The array `findIndex` was called upon.
1609
- * @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
1610
- * @param - Returns defaultIndex if not found by the function.
1611
- * @example
1612
- import { findIndex } from "@daybrush/utils";
1613
-
1614
- findIndex([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // 1
1615
- */
1616
-
1617
- function findIndex(arr, callback, defaultIndex) {
1618
- if (defaultIndex === void 0) {
1619
- defaultIndex = -1;
1620
- }
1621
-
1622
- var length = arr.length;
1623
-
1624
- for (var i = 0; i < length; ++i) {
1625
- if (callback(arr[i], i, arr)) {
1626
- return i;
1627
- }
1628
- }
1629
-
1630
- return defaultIndex;
1631
- }
1632
- /**
1633
- * Sets up a function that will be called whenever the specified event is delivered to the target
1634
- * @memberof DOM
1635
- * @param - event target
1636
- * @param - A case-sensitive string representing the event type to listen for.
1637
- * @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
1638
- * @param - An options object that specifies characteristics about the event listener.
1639
- * @example
1640
- import {addEvent} from "@daybrush/utils";
1641
-
1642
- addEvent(el, "click", e => {
1643
- console.log(e);
1644
- });
1645
- */
1646
-
1647
- function addEvent(el, type, listener, options) {
1648
- el.addEventListener(type, listener, options);
1649
- }
1650
- /**
1651
- * removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
1652
- * @memberof DOM
1653
- * @param - event target
1654
- * @param - A case-sensitive string representing the event type to listen for.
1655
- * @param - The EventListener function of the event handler to remove from the event target.
1656
- * @param - An options object that specifies characteristics about the event listener.
1657
- * @example
1658
- import {addEvent, removeEvent} from "@daybrush/utils";
1659
- const listener = e => {
1660
- console.log(e);
1661
- };
1662
- addEvent(el, "click", listener);
1663
- removeEvent(el, "click", listener);
1664
- */
1665
-
1666
- function removeEvent(el, type, listener, options) {
1667
- el.removeEventListener(type, listener, options);
1668
- }
1669
-
1670
- /*
1671
- Copyright (c) 2019 Daybrush
1672
- name: @scena/event-emitter
1673
- license: MIT
1674
- author: Daybrush
1675
- repository: git+https://github.com/daybrush/gesture.git
1676
- version: 1.0.5
1677
- */
1678
-
1679
- /*! *****************************************************************************
1680
- Copyright (c) Microsoft Corporation.
1681
-
1682
- Permission to use, copy, modify, and/or distribute this software for any
1683
- purpose with or without fee is hereby granted.
1684
-
1685
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1686
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1687
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1688
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1689
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1690
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1691
- PERFORMANCE OF THIS SOFTWARE.
1692
- ***************************************************************************** */
1693
- var __assign$1 = function () {
1694
- __assign$1 = Object.assign || function __assign(t) {
1695
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1696
- s = arguments[i];
1697
-
1698
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1699
- }
1700
-
1701
- return t;
1702
- };
1703
-
1704
- return __assign$1.apply(this, arguments);
1705
- };
1706
- function __spreadArrays() {
1707
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1708
-
1709
- 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];
1710
-
1711
- return r;
1712
- }
1713
-
1714
- /**
1715
- * Implement EventEmitter on object or component.
1716
- */
1717
-
1718
- var EventEmitter =
1719
- /*#__PURE__*/
1720
- function () {
1721
- function EventEmitter() {
1722
- this._events = {};
1723
- }
1724
- /**
1725
- * Add a listener to the registered event.
1726
- * @param - Name of the event to be added
1727
- * @param - listener function of the event to be added
1728
- * @example
1729
- * import EventEmitter from "@scena/event-emitter";
1730
- * cosnt emitter = new EventEmitter();
1731
- *
1732
- * // Add listener in "a" event
1733
- * emitter.on("a", () => {
1734
- * });
1735
- * // Add listeners
1736
- * emitter.on({
1737
- * a: () => {},
1738
- * b: () => {},
1739
- * });
1740
- */
1741
-
1742
-
1743
- var __proto = EventEmitter.prototype;
1744
-
1745
- __proto.on = function (eventName, listener) {
1746
- if (isObject(eventName)) {
1747
- for (var name in eventName) {
1748
- this.on(name, eventName[name]);
1749
- }
1750
- } else {
1751
- this._addEvent(eventName, listener, {});
1752
- }
1753
-
1754
- return this;
1755
- };
1756
- /**
1757
- * Remove listeners registered in the event target.
1758
- * @param - Name of the event to be removed
1759
- * @param - listener function of the event to be removed
1760
- * @example
1761
- * import EventEmitter from "@scena/event-emitter";
1762
- * cosnt emitter = new EventEmitter();
1763
- *
1764
- * // Remove all listeners.
1765
- * emitter.off();
1766
- *
1767
- * // Remove all listeners in "A" event.
1768
- * emitter.off("a");
1769
- *
1770
- *
1771
- * // Remove "listener" listener in "a" event.
1772
- * emitter.off("a", listener);
1773
- */
1774
-
1775
-
1776
- __proto.off = function (eventName, listener) {
1777
- if (!eventName) {
1778
- this._events = {};
1779
- } else if (isObject(eventName)) {
1780
- for (var name in eventName) {
1781
- this.off(name);
1782
- }
1783
- } else if (!listener) {
1784
- this._events[eventName] = [];
1785
- } else {
1786
- var events = this._events[eventName];
1787
-
1788
- if (events) {
1789
- var index = findIndex(events, function (e) {
1790
- return e.listener === listener;
1791
- });
1792
-
1793
- if (index > -1) {
1794
- events.splice(index, 1);
1795
- }
1796
- }
1797
- }
1798
-
1799
- return this;
1800
- };
1801
- /**
1802
- * Add a disposable listener and Use promise to the registered event.
1803
- * @param - Name of the event to be added
1804
- * @param - disposable listener function of the event to be added
1805
- * @example
1806
- * import EventEmitter from "@scena/event-emitter";
1807
- * cosnt emitter = new EventEmitter();
1808
- *
1809
- * // Add a disposable listener in "a" event
1810
- * emitter.once("a", () => {
1811
- * });
1812
- *
1813
- * // Use Promise
1814
- * emitter.once("a").then(e => {
1815
- * });
1816
- */
1817
-
1818
-
1819
- __proto.once = function (eventName, listener) {
1820
- var _this = this;
1821
-
1822
- if (listener) {
1823
- this._addEvent(eventName, listener, {
1824
- once: true
1825
- });
1826
- }
1827
-
1828
- return new Promise(function (resolve) {
1829
- _this._addEvent(eventName, resolve, {
1830
- once: true
1831
- });
1832
- });
1833
- };
1834
- /**
1835
- * Fires an event to call listeners.
1836
- * @param - Event name
1837
- * @param - Event parameter
1838
- * @return If false, stop the event.
1839
- * @example
1840
- *
1841
- * import EventEmitter from "@scena/event-emitter";
1842
- *
1843
- *
1844
- * const emitter = new EventEmitter();
1845
- *
1846
- * emitter.on("a", e => {
1847
- * });
1848
- *
1849
- *
1850
- * emitter.emit("a", {
1851
- * a: 1,
1852
- * });
1853
- */
1854
-
1855
-
1856
- __proto.emit = function (eventName, param) {
1857
- var _this = this;
1858
-
1859
- if (param === void 0) {
1860
- param = {};
1861
- }
1862
-
1863
- var events = this._events[eventName];
1864
-
1865
- if (!eventName || !events) {
1866
- return true;
1867
- }
1868
-
1869
- var isStop = false;
1870
- param.eventType = eventName;
1871
-
1872
- param.stop = function () {
1873
- isStop = true;
1874
- };
1875
-
1876
- param.currentTarget = this;
1877
-
1878
- __spreadArrays(events).forEach(function (info) {
1879
- info.listener(param);
1880
-
1881
- if (info.once) {
1882
- _this.off(eventName, info.listener);
1883
- }
1884
- });
1885
-
1886
- return !isStop;
1887
- };
1888
- /**
1889
- * Fires an event to call listeners.
1890
- * @param - Event name
1891
- * @param - Event parameter
1892
- * @return If false, stop the event.
1893
- * @example
1894
- *
1895
- * import EventEmitter from "@scena/event-emitter";
1896
- *
1897
- *
1898
- * const emitter = new EventEmitter();
1899
- *
1900
- * emitter.on("a", e => {
1901
- * });
1902
- *
1903
- *
1904
- * emitter.emit("a", {
1905
- * a: 1,
1906
- * });
1907
- */
1908
-
1909
- /**
1910
- * Fires an event to call listeners.
1911
- * @param - Event name
1912
- * @param - Event parameter
1913
- * @return If false, stop the event.
1914
- * @example
1915
- *
1916
- * import EventEmitter from "@scena/event-emitter";
1917
- *
1918
- *
1919
- * const emitter = new EventEmitter();
1920
- *
1921
- * emitter.on("a", e => {
1922
- * });
1923
- *
1924
- * // emit
1925
- * emitter.trigger("a", {
1926
- * a: 1,
1927
- * });
1928
- */
1929
-
1930
-
1931
- __proto.trigger = function (eventName, param) {
1932
- if (param === void 0) {
1933
- param = {};
1934
- }
1935
-
1936
- return this.emit(eventName, param);
1937
- };
1938
-
1939
- __proto._addEvent = function (eventName, listener, options) {
1940
- var events = this._events;
1941
- events[eventName] = events[eventName] || [];
1942
- var listeners = events[eventName];
1943
- listeners.push(__assign$1({
1944
- listener: listener
1945
- }, options));
1946
- };
1947
-
1948
- return EventEmitter;
1949
- }();
1950
-
1951
- var EventEmitter$1 = EventEmitter;
1952
-
1953
- /*
1954
- Copyright (c) 2019 Daybrush
1955
- name: gesto
1956
- license: MIT
1957
- author: Daybrush
1958
- repository: git+https://github.com/daybrush/gesto.git
1959
- version: 1.7.0
1960
- */
1961
-
1962
- /*! *****************************************************************************
1963
- Copyright (c) Microsoft Corporation. All rights reserved.
1964
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
1965
- this file except in compliance with the License. You may obtain a copy of the
1966
- License at http://www.apache.org/licenses/LICENSE-2.0
1967
-
1968
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1969
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
1970
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
1971
- MERCHANTABLITY OR NON-INFRINGEMENT.
1972
-
1973
- See the Apache Version 2.0 License for specific language governing permissions
1974
- and limitations under the License.
1975
- ***************************************************************************** */
1976
-
1977
- /* global Reflect, Promise */
1978
- var extendStatics = function (d, b) {
1979
- extendStatics = Object.setPrototypeOf || {
1980
- __proto__: []
1981
- } instanceof Array && function (d, b) {
1982
- d.__proto__ = b;
1983
- } || function (d, b) {
1984
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
1985
- };
1986
-
1987
- return extendStatics(d, b);
1988
- };
1989
-
1990
- function __extends(d, b) {
1991
- extendStatics(d, b);
1992
-
1993
- function __() {
1994
- this.constructor = d;
1995
- }
1996
-
1997
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1998
- }
1999
- var __assign = function () {
2000
- __assign = Object.assign || function __assign(t) {
2001
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2002
- s = arguments[i];
2003
-
2004
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2005
- }
2006
-
2007
- return t;
2008
- };
2009
-
2010
- return __assign.apply(this, arguments);
2011
- };
2012
-
2013
- function getRad(pos1, pos2) {
2014
- var distX = pos2[0] - pos1[0];
2015
- var distY = pos2[1] - pos1[1];
2016
- var rad = Math.atan2(distY, distX);
2017
- return rad >= 0 ? rad : rad + Math.PI * 2;
2018
- }
2019
- function getRotatiion(touches) {
2020
- return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
2021
- }
2022
- function isMultiTouch(e) {
2023
- return e.touches && e.touches.length >= 2;
2024
- }
2025
- function getEventClients(e) {
2026
- if (e.touches) {
2027
- return getClients(e.touches);
2028
- } else {
2029
- return [getClient(e)];
2030
- }
2031
- }
2032
- function getPosition(clients, prevClients, startClients) {
2033
- var length = startClients.length;
2034
-
2035
- var _a = getAverageClient(clients, length),
2036
- clientX = _a.clientX,
2037
- clientY = _a.clientY,
2038
- originalClientX = _a.originalClientX,
2039
- originalClientY = _a.originalClientY;
2040
-
2041
- var _b = getAverageClient(prevClients, length),
2042
- prevX = _b.clientX,
2043
- prevY = _b.clientY;
2044
-
2045
- var _c = getAverageClient(startClients, length),
2046
- startX = _c.clientX,
2047
- startY = _c.clientY;
2048
-
2049
- var deltaX = clientX - prevX;
2050
- var deltaY = clientY - prevY;
2051
- var distX = clientX - startX;
2052
- var distY = clientY - startY;
2053
- return {
2054
- clientX: originalClientX,
2055
- clientY: originalClientY,
2056
- deltaX: deltaX,
2057
- deltaY: deltaY,
2058
- distX: distX,
2059
- distY: distY
2060
- };
2061
- }
2062
- function getDist(clients) {
2063
- return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
2064
- }
2065
- function getClients(touches) {
2066
- var length = Math.min(touches.length, 2);
2067
- var clients = [];
2068
-
2069
- for (var i = 0; i < length; ++i) {
2070
- clients.push(getClient(touches[i]));
2071
- }
2072
-
2073
- return clients;
2074
- }
2075
- function getClient(e) {
2076
- return {
2077
- clientX: e.clientX,
2078
- clientY: e.clientY
2079
- };
2080
- }
2081
- function getAverageClient(clients, length) {
2082
- if (length === void 0) {
2083
- length = clients.length;
2084
- }
2085
-
2086
- var sumClient = {
2087
- clientX: 0,
2088
- clientY: 0,
2089
- originalClientX: 0,
2090
- originalClientY: 0
2091
- };
2092
-
2093
- for (var i = 0; i < length; ++i) {
2094
- var client = clients[i];
2095
- sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
2096
- sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
2097
- sumClient.clientX += client.clientX;
2098
- sumClient.clientY += client.clientY;
2099
- }
2100
-
2101
- if (!length) {
2102
- return sumClient;
2103
- }
2104
-
2105
- return {
2106
- clientX: sumClient.clientX / length,
2107
- clientY: sumClient.clientY / length,
2108
- originalClientX: sumClient.originalClientX / length,
2109
- originalClientY: sumClient.originalClientY / length
2110
- };
2111
- }
2112
-
2113
- var ClientStore =
2114
- /*#__PURE__*/
2115
- function () {
2116
- function ClientStore(clients) {
2117
- this.prevClients = [];
2118
- this.startClients = [];
2119
- this.movement = 0;
2120
- this.length = 0;
2121
- this.startClients = clients;
2122
- this.prevClients = clients;
2123
- this.length = clients.length;
2124
- }
2125
-
2126
- var __proto = ClientStore.prototype;
2127
-
2128
- __proto.getAngle = function (clients) {
2129
- if (clients === void 0) {
2130
- clients = this.prevClients;
2131
- }
2132
-
2133
- return getRotatiion(clients);
2134
- };
2135
-
2136
- __proto.getRotation = function (clients) {
2137
- if (clients === void 0) {
2138
- clients = this.prevClients;
2139
- }
2140
-
2141
- return getRotatiion(clients) - getRotatiion(this.startClients);
2142
- };
2143
-
2144
- __proto.getPosition = function (clients, isAdd) {
2145
- if (clients === void 0) {
2146
- clients = this.prevClients;
2147
- }
2148
-
2149
- var position = getPosition(clients || this.prevClients, this.prevClients, this.startClients);
2150
- var deltaX = position.deltaX,
2151
- deltaY = position.deltaY;
2152
- this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
2153
- this.prevClients = clients;
2154
- return position;
2155
- };
2156
-
2157
- __proto.getPositions = function (clients) {
2158
- if (clients === void 0) {
2159
- clients = this.prevClients;
2160
- }
2161
-
2162
- var prevClients = this.prevClients;
2163
- return this.startClients.map(function (startClient, i) {
2164
- return getPosition([clients[i]], [prevClients[i]], [startClient]);
2165
- });
2166
- };
2167
-
2168
- __proto.getMovement = function (clients) {
2169
- var movement = this.movement;
2170
-
2171
- if (!clients) {
2172
- return movement;
2173
- }
2174
-
2175
- var currentClient = getAverageClient(clients, this.length);
2176
- var prevClient = getAverageClient(this.prevClients, this.length);
2177
- var deltaX = currentClient.clientX - prevClient.clientX;
2178
- var deltaY = currentClient.clientY - prevClient.clientY;
2179
- return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
2180
- };
2181
-
2182
- __proto.getDistance = function (clients) {
2183
- if (clients === void 0) {
2184
- clients = this.prevClients;
2185
- }
2186
-
2187
- return getDist(clients);
2188
- };
2189
-
2190
- __proto.getScale = function (clients) {
2191
- if (clients === void 0) {
2192
- clients = this.prevClients;
2193
- }
2194
-
2195
- return getDist(clients) / getDist(this.startClients);
2196
- };
2197
-
2198
- __proto.move = function (deltaX, deltaY) {
2199
- this.startClients.forEach(function (client) {
2200
- client.clientX -= deltaX;
2201
- client.clientY -= deltaY;
2202
- });
2203
- };
2204
-
2205
- return ClientStore;
2206
- }();
2207
-
2208
- var INPUT_TAGNAMES = ["textarea", "input"];
2209
- /**
2210
- * You can set up drag, pinch events in any browser.
2211
- */
2212
-
2213
- var Gesto =
2214
- /*#__PURE__*/
2215
- function (_super) {
2216
- __extends(Gesto, _super);
2217
- /**
2218
- *
2219
- */
2220
-
2221
-
2222
- function Gesto(targets, options) {
2223
- if (options === void 0) {
2224
- options = {};
2225
- }
2226
-
2227
- var _this = _super.call(this) || this;
2228
-
2229
- _this.options = {};
2230
- _this.flag = false;
2231
- _this.pinchFlag = false;
2232
- _this.datas = {};
2233
- _this.isDrag = false;
2234
- _this.isPinch = false;
2235
- _this.isMouse = false;
2236
- _this.isTouch = false;
2237
- _this.clientStores = [];
2238
- _this.targets = [];
2239
- _this.prevTime = 0;
2240
- _this.doubleFlag = false;
2241
- _this._dragFlag = false;
2242
-
2243
- _this.onDragStart = function (e, isTrusted) {
2244
- if (isTrusted === void 0) {
2245
- isTrusted = true;
2246
- }
2247
-
2248
- if (!_this.flag && e.cancelable === false) {
2249
- return;
2250
- }
2251
-
2252
- var _a = _this.options,
2253
- container = _a.container,
2254
- pinchOutside = _a.pinchOutside,
2255
- preventRightClick = _a.preventRightClick,
2256
- preventDefault = _a.preventDefault,
2257
- checkInput = _a.checkInput;
2258
- var isTouch = _this.isTouch;
2259
- var isDragStart = !_this.flag;
2260
-
2261
- if (isDragStart) {
2262
- var activeElement = document.activeElement;
2263
- var target = e.target;
2264
- var tagName = target.tagName.toLowerCase();
2265
- var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
2266
- var hasContentEditable = target.isContentEditable;
2267
-
2268
- if (hasInput || hasContentEditable) {
2269
- if (checkInput || activeElement === target) {
2270
- // force false or already focused.
2271
- return false;
2272
- } // no focus
2273
-
2274
-
2275
- if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
2276
- return false;
2277
- }
2278
- } else if ((preventDefault || e.type === "touchstart") && activeElement) {
2279
- var activeTagName = activeElement.tagName;
2280
-
2281
- if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
2282
- activeElement.blur();
2283
- }
2284
- }
2285
-
2286
- _this.clientStores = [new ClientStore(getEventClients(e))];
2287
- _this.flag = true;
2288
- _this.isDrag = false;
2289
- _this._dragFlag = true;
2290
- _this.datas = {};
2291
-
2292
- if (preventRightClick && (e.which === 3 || e.button === 2)) {
2293
- _this.initDrag();
2294
-
2295
- return false;
2296
- }
2297
-
2298
- _this.doubleFlag = now() - _this.prevTime < 200;
2299
-
2300
- var result = _this.emit("dragStart", __assign({
2301
- datas: _this.datas,
2302
- inputEvent: e,
2303
- isTrusted: isTrusted,
2304
- isDouble: _this.doubleFlag
2305
- }, _this.getCurrentStore().getPosition(), {
2306
- preventDefault: function () {
2307
- e.preventDefault();
2308
- },
2309
- preventDrag: function () {
2310
- _this._dragFlag = false;
2311
- }
2312
- }));
2313
-
2314
- if (result === false) {
2315
- _this.initDrag();
2316
- }
2317
-
2318
- _this.flag && preventDefault && e.preventDefault();
2319
- }
2320
-
2321
- if (!_this.flag) {
2322
- return false;
2323
- }
2324
-
2325
- var timer = 0;
2326
-
2327
- if (isDragStart && isTouch && pinchOutside) {
2328
- timer = setTimeout(function () {
2329
- addEvent(container, "touchstart", _this.onDragStart, {
2330
- passive: false
2331
- });
2332
- });
2333
- }
2334
-
2335
- if (!isDragStart && isTouch && pinchOutside) {
2336
- removeEvent(container, "touchstart", _this.onDragStart);
2337
- }
2338
-
2339
- if (_this.flag && isMultiTouch(e)) {
2340
- clearTimeout(timer);
2341
-
2342
- if (isDragStart && e.touches.length !== e.changedTouches.length) {
2343
- return;
2344
- }
2345
-
2346
- if (!_this.pinchFlag) {
2347
- _this.onPinchStart(e);
2348
- }
2349
- }
2350
- };
2351
-
2352
- _this.onDrag = function (e, isScroll) {
2353
- if (!_this.flag) {
2354
- return;
2355
- }
2356
-
2357
- var clients = getEventClients(e);
2358
-
2359
- var result = _this.moveClients(clients, e, false);
2360
-
2361
- if (_this._dragFlag) {
2362
- if (_this.pinchFlag || result.deltaX || result.deltaY) {
2363
- var dragResult = _this.emit("drag", __assign({}, result, {
2364
- isScroll: !!isScroll,
2365
- inputEvent: e
2366
- }));
2367
-
2368
- if (dragResult === false) {
2369
- _this.stop();
2370
-
2371
- return;
2372
- }
2373
- }
2374
-
2375
- if (_this.pinchFlag) {
2376
- _this.onPinch(e, clients);
2377
- }
2378
- }
2379
-
2380
- _this.getCurrentStore().getPosition(clients, true);
2381
- };
2382
-
2383
- _this.onDragEnd = function (e) {
2384
- if (!_this.flag) {
2385
- return;
2386
- }
2387
-
2388
- var _a = _this.options,
2389
- pinchOutside = _a.pinchOutside,
2390
- container = _a.container;
2391
-
2392
- if (_this.isTouch && pinchOutside) {
2393
- removeEvent(container, "touchstart", _this.onDragStart);
2394
- }
2395
-
2396
- _this.flag = false;
2397
-
2398
- var position = _this._getPosition();
2399
-
2400
- var currentTime = now();
2401
- var isDouble = !_this.isDrag && _this.doubleFlag;
2402
- _this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
2403
-
2404
- _this.emit("dragEnd", __assign({
2405
- datas: _this.datas,
2406
- isDouble: isDouble,
2407
- isDrag: _this.isDrag,
2408
- isClick: !_this.isDrag,
2409
- inputEvent: e
2410
- }, position));
2411
-
2412
- if (_this.pinchFlag) {
2413
- _this.onPinchEnd(e);
2414
- }
2415
-
2416
- _this.clientStores = [];
2417
- };
2418
-
2419
- _this.onBlur = function () {
2420
- _this.onDragEnd();
2421
- };
2422
-
2423
- var elements = [].concat(targets);
2424
- _this.options = __assign({
2425
- checkInput: false,
2426
- container: elements.length > 1 ? window : elements[0],
2427
- preventRightClick: true,
2428
- preventDefault: true,
2429
- checkWindowBlur: false,
2430
- pinchThreshold: 0,
2431
- events: ["touch", "mouse"]
2432
- }, options);
2433
- var _a = _this.options,
2434
- container = _a.container,
2435
- events = _a.events,
2436
- checkWindowBlur = _a.checkWindowBlur;
2437
- _this.isTouch = events.indexOf("touch") > -1;
2438
- _this.isMouse = events.indexOf("mouse") > -1;
2439
- _this.targets = elements;
2440
-
2441
- if (_this.isMouse) {
2442
- elements.forEach(function (el) {
2443
- addEvent(el, "mousedown", _this.onDragStart);
2444
- });
2445
- addEvent(container, "mousemove", _this.onDrag);
2446
- addEvent(container, "mouseup", _this.onDragEnd);
2447
- addEvent(container, "contextmenu", _this.onDragEnd);
2448
- }
2449
-
2450
- if (checkWindowBlur) {
2451
- addEvent(window, "blur", _this.onBlur);
2452
- }
2453
-
2454
- if (_this.isTouch) {
2455
- var passive_1 = {
2456
- passive: false
2457
- };
2458
- elements.forEach(function (el) {
2459
- addEvent(el, "touchstart", _this.onDragStart, passive_1);
2460
- });
2461
- addEvent(container, "touchmove", _this.onDrag, passive_1);
2462
- addEvent(container, "touchend", _this.onDragEnd, passive_1);
2463
- addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
2464
- }
2465
-
2466
- return _this;
2467
- }
2468
- /**
2469
- * Stop Gesto's drag events.
2470
- */
2471
-
2472
-
2473
- var __proto = Gesto.prototype;
2474
-
2475
- __proto.stop = function () {
2476
- this.isDrag = false;
2477
- this.flag = false;
2478
- this.clientStores = [];
2479
- this.datas = {};
2480
- };
2481
- /**
2482
- * The total moved distance
2483
- */
2484
-
2485
-
2486
- __proto.getMovement = function (clients) {
2487
- return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
2488
- return prev + cur.movement;
2489
- }, 0);
2490
- };
2491
- /**
2492
- * Whether to drag
2493
- */
2494
-
2495
-
2496
- __proto.isDragging = function () {
2497
- return this.isDrag;
2498
- };
2499
- /**
2500
- * Whether to start drag
2501
- */
2502
-
2503
-
2504
- __proto.isFlag = function () {
2505
- return this.flag;
2506
- };
2507
- /**
2508
- * Whether to start pinch
2509
- */
2510
-
2511
-
2512
- __proto.isPinchFlag = function () {
2513
- return this.pinchFlag;
2514
- };
2515
- /**
2516
- * Whether to start double click
2517
- */
2518
-
2519
-
2520
- __proto.isDoubleFlag = function () {
2521
- return this.doubleFlag;
2522
- };
2523
- /**
2524
- * Whether to pinch
2525
- */
2526
-
2527
-
2528
- __proto.isPinching = function () {
2529
- return this.isPinch;
2530
- };
2531
- /**
2532
- * If a scroll event occurs, it is corrected by the scroll distance.
2533
- */
2534
-
2535
-
2536
- __proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
2537
- if (isCallDrag === void 0) {
2538
- isCallDrag = true;
2539
- }
2540
-
2541
- if (!this.flag) {
2542
- return;
2543
- }
2544
-
2545
- this.clientStores[0].move(deltaX, deltaY);
2546
- isCallDrag && this.onDrag(e, true);
2547
- };
2548
- /**
2549
- * Create a virtual drag event.
2550
- */
2551
-
2552
-
2553
- __proto.move = function (_a, inputEvent) {
2554
- var deltaX = _a[0],
2555
- deltaY = _a[1];
2556
- var store = this.getCurrentStore();
2557
- var nextClients = store.prevClients;
2558
- return this.moveClients(nextClients.map(function (_a) {
2559
- var clientX = _a.clientX,
2560
- clientY = _a.clientY;
2561
- return {
2562
- clientX: clientX + deltaX,
2563
- clientY: clientY + deltaY,
2564
- originalClientX: clientX,
2565
- originalClientY: clientY
2566
- };
2567
- }), inputEvent, true);
2568
- };
2569
- /**
2570
- * The dragStart event is triggered by an external event.
2571
- */
2572
-
2573
-
2574
- __proto.triggerDragStart = function (e) {
2575
- this.onDragStart(e, false);
2576
- };
2577
- /**
2578
- * Set the event data while dragging.
2579
- */
2580
-
2581
-
2582
- __proto.setEventDatas = function (datas) {
2583
- var currentDatas = this.datas;
2584
-
2585
- for (var name in datas) {
2586
- currentDatas[name] = datas[name];
2587
- }
2588
-
2589
- return this;
2590
- };
2591
- /**
2592
- * Get the current event state while dragging.
2593
- */
2594
-
2595
-
2596
- __proto.getCurrentEvent = function (inputEvent) {
2597
- return __assign({
2598
- datas: this.datas
2599
- }, this._getPosition(), {
2600
- movement: this.getMovement(),
2601
- isDrag: this.isDrag,
2602
- isPinch: this.isPinch,
2603
- isScroll: false,
2604
- inputEvent: inputEvent
2605
- });
2606
- };
2607
- /**
2608
- * Get & Set the event data while dragging.
2609
- */
2610
-
2611
-
2612
- __proto.getEventDatas = function () {
2613
- return this.datas;
2614
- };
2615
- /**
2616
- * Unset Gesto
2617
- */
2618
-
2619
-
2620
- __proto.unset = function () {
2621
- var _this = this;
2622
-
2623
- var targets = this.targets;
2624
- var container = this.options.container;
2625
- this.off();
2626
- removeEvent(window, "blur", this.onBlur);
2627
-
2628
- if (this.isMouse) {
2629
- targets.forEach(function (target) {
2630
- removeEvent(target, "mousedown", _this.onDragStart);
2631
- });
2632
- removeEvent(container, "mousemove", this.onDrag);
2633
- removeEvent(container, "mouseup", this.onDragEnd);
2634
- removeEvent(container, "contextmenu", this.onDragEnd);
2635
- }
2636
-
2637
- if (this.isTouch) {
2638
- targets.forEach(function (target) {
2639
- removeEvent(target, "touchstart", _this.onDragStart);
2640
- });
2641
- removeEvent(container, "touchstart", this.onDragStart);
2642
- removeEvent(container, "touchmove", this.onDrag);
2643
- removeEvent(container, "touchend", this.onDragEnd);
2644
- removeEvent(container, "touchcancel", this.onDragEnd);
2645
- }
2646
- };
2647
-
2648
- __proto.onPinchStart = function (e) {
2649
- var pinchThreshold = this.options.pinchThreshold;
2650
-
2651
- if (this.isDrag && this.getMovement() > pinchThreshold) {
2652
- return;
2653
- }
2654
-
2655
- var store = new ClientStore(getEventClients(e));
2656
- this.pinchFlag = true;
2657
- this.clientStores.splice(0, 0, store);
2658
- var result = this.emit("pinchStart", __assign({
2659
- datas: this.datas,
2660
- angle: store.getAngle(),
2661
- touches: this.getCurrentStore().getPositions()
2662
- }, store.getPosition(), {
2663
- inputEvent: e
2664
- }));
2665
-
2666
- if (result === false) {
2667
- this.pinchFlag = false;
2668
- }
2669
- };
2670
-
2671
- __proto.onPinch = function (e, clients) {
2672
- if (!this.flag || !this.pinchFlag || clients.length < 2) {
2673
- return;
2674
- }
2675
-
2676
- var store = this.getCurrentStore();
2677
- this.isPinch = true;
2678
- this.emit("pinch", __assign({
2679
- datas: this.datas,
2680
- movement: this.getMovement(clients),
2681
- angle: store.getAngle(clients),
2682
- rotation: store.getRotation(clients),
2683
- touches: store.getPositions(clients),
2684
- scale: store.getScale(clients),
2685
- distance: store.getDistance(clients)
2686
- }, store.getPosition(clients), {
2687
- inputEvent: e
2688
- }));
2689
- };
2690
-
2691
- __proto.onPinchEnd = function (e) {
2692
- if (!this.pinchFlag) {
2693
- return;
2694
- }
2695
-
2696
- var isPinch = this.isPinch;
2697
- this.isPinch = false;
2698
- this.pinchFlag = false;
2699
- var store = this.getCurrentStore();
2700
- this.emit("pinchEnd", __assign({
2701
- datas: this.datas,
2702
- isPinch: isPinch,
2703
- touches: store.getPositions()
2704
- }, store.getPosition(), {
2705
- inputEvent: e
2706
- }));
2707
- this.isPinch = false;
2708
- this.pinchFlag = false;
2709
- };
2710
-
2711
- __proto.initDrag = function () {
2712
- this.clientStores = [];
2713
- this.pinchFlag = false;
2714
- this.doubleFlag = false;
2715
- this.prevTime = 0;
2716
- this.flag = false;
2717
- };
2718
-
2719
- __proto.getCurrentStore = function () {
2720
- return this.clientStores[0];
2721
- };
2722
-
2723
- __proto.moveClients = function (clients, inputEvent, isAdd) {
2724
- var position = this._getPosition(clients, isAdd);
2725
-
2726
- if (position.deltaX || position.deltaY) {
2727
- this.isDrag = true;
2728
- }
2729
-
2730
- return __assign({
2731
- datas: this.datas
2732
- }, position, {
2733
- movement: this.getMovement(clients),
2734
- isDrag: this.isDrag,
2735
- isPinch: this.isPinch,
2736
- isScroll: false,
2737
- inputEvent: inputEvent
2738
- });
2739
- };
2740
-
2741
- __proto._getPosition = function (clients, isAdd) {
2742
- var store = this.getCurrentStore();
2743
- var position = store.getPosition(clients, isAdd);
2744
-
2745
- var _a = this.clientStores.slice(1).reduce(function (prev, cur) {
2746
- var storePosition = cur.getPosition();
2747
- prev.distX += storePosition.distX;
2748
- prev.distY += storePosition.distY;
2749
- return prev;
2750
- }, position),
2751
- distX = _a.distX,
2752
- distY = _a.distY;
2753
-
2754
- return __assign({}, position, {
2755
- distX: distX,
2756
- distY: distY
2757
- });
2758
- };
2759
-
2760
- return Gesto;
2761
- }(EventEmitter$1);
2762
-
2763
- var Gesto$1 = Gesto;
2764
-
2765
1557
  const _sfc_main$h = defineComponent({
2766
1558
  name: "m-editor-resize",
2767
1559
  props: {
@@ -2776,7 +1568,7 @@ const _sfc_main$h = defineComponent({
2776
1568
  onMounted(() => {
2777
1569
  if (!target.value)
2778
1570
  return;
2779
- getso = new Gesto$1(target.value, {
1571
+ getso = new Gesto(target.value, {
2780
1572
  container: window,
2781
1573
  pinchOutside: true
2782
1574
  }).on("drag", (e) => {
@@ -2820,6 +1612,12 @@ const _sfc_main$g = defineComponent({
2820
1612
  AddPageBox,
2821
1613
  Resizer
2822
1614
  },
1615
+ props: {
1616
+ codeOptions: {
1617
+ type: Object,
1618
+ default: () => ({})
1619
+ }
1620
+ },
2823
1621
  setup() {
2824
1622
  const { editorService, uiService } = inject("services") || {};
2825
1623
  const root = computed(() => editorService?.get("root"));
@@ -2854,8 +1652,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2854
1652
  key: 0,
2855
1653
  class: "m-editor-content",
2856
1654
  "init-values": _ctx.root,
1655
+ options: _ctx.codeOptions,
2857
1656
  onSave: _ctx.saveCode
2858
- }, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
1657
+ }, null, 8, ["init-values", "options", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
2859
1658
  createElementVNode("div", {
2860
1659
  class: "m-editor-framework-left",
2861
1660
  style: normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
@@ -3303,13 +2102,13 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
3303
2102
  const _component_m_form = resolveComponent("m-form");
3304
2103
  return openBlock(), createBlock(_component_m_form, {
3305
2104
  class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
3306
- "popper-class": "m-editor-props-panel-popper",
2105
+ "popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
3307
2106
  ref: "configForm",
3308
2107
  size: _ctx.propsPanelSize,
3309
2108
  "init-values": _ctx.values,
3310
2109
  config: _ctx.curFormConfig,
3311
2110
  onChange: _ctx.submit
3312
- }, null, 8, ["class", "size", "init-values", "config", "onChange"]);
2111
+ }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
3313
2112
  }
3314
2113
  var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
3315
2114
 
@@ -4638,6 +3437,7 @@ const _sfc_main$2 = defineComponent({
4638
3437
  const { scrollTop, scrollLeft } = stage.mask;
4639
3438
  if (layout === Layout.ABSOLUTE) {
4640
3439
  config.style = {
3440
+ ...config.style || {},
4641
3441
  position: "absolute",
4642
3442
  top: e.clientY - containerRect.top + scrollTop,
4643
3443
  left: e.clientX - containerRect.left + scrollLeft
@@ -4703,74 +3503,74 @@ const _sfc_main$1 = defineComponent({
4703
3503
  const mouseenterHandler = () => {
4704
3504
  workspace.value?.focus();
4705
3505
  };
3506
+ const mouseleaveHandler = () => {
3507
+ workspace.value?.blur();
3508
+ };
4706
3509
  onMounted(() => {
4707
3510
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3511
+ workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
4708
3512
  keycon = new KeyController(workspace.value);
4709
3513
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
4710
3514
  const ctrl = isMac ? "meta" : "ctrl";
4711
- keycon.keyup("delete", (e) => {
3515
+ keycon.keydown((e) => {
3516
+ console.log(e);
3517
+ e.inputEvent.preventDefault();
3518
+ }).keyup("delete", (e) => {
4712
3519
  e.inputEvent.preventDefault();
4713
3520
  if (!node.value || isPage(node.value))
4714
3521
  return;
4715
3522
  services?.editorService.remove(node.value);
4716
- }).keydown([ctrl, "c"], (e) => {
3523
+ }).keyup("backspace", (e) => {
4717
3524
  e.inputEvent.preventDefault();
3525
+ if (!node.value || isPage(node.value))
3526
+ return;
3527
+ services?.editorService.remove(node.value);
3528
+ }).keydown([ctrl, "c"], () => {
4718
3529
  node.value && services?.editorService.copy(node.value);
4719
- }).keydown([ctrl, "v"], (e) => {
4720
- e.inputEvent.preventDefault();
3530
+ }).keydown([ctrl, "v"], () => {
4721
3531
  node.value && services?.editorService.paste();
4722
- }).keydown([ctrl, "x"], (e) => {
4723
- e.inputEvent.preventDefault();
3532
+ }).keydown([ctrl, "x"], () => {
4724
3533
  if (!node.value || isPage(node.value))
4725
3534
  return;
4726
3535
  services?.editorService.copy(node.value);
4727
3536
  services?.editorService.remove(node.value);
4728
- }).keydown([ctrl, "z"], (e) => {
4729
- e.inputEvent.preventDefault();
3537
+ }).keydown([ctrl, "z"], () => {
4730
3538
  services?.editorService.undo();
4731
- }).keydown([ctrl, "shift", "z"], (e) => {
4732
- e.inputEvent.preventDefault();
3539
+ }).keydown([ctrl, "shift", "z"], () => {
4733
3540
  services?.editorService.redo();
4734
- }).keydown("up", (e) => {
4735
- e.inputEvent.preventDefault();
3541
+ }).keydown("up", () => {
4736
3542
  services?.editorService.move(0, -1);
4737
- }).keydown("down", (e) => {
4738
- e.inputEvent.preventDefault();
3543
+ }).keydown("down", () => {
4739
3544
  services?.editorService.move(0, 1);
4740
- }).keydown("left", (e) => {
4741
- e.inputEvent.preventDefault();
3545
+ }).keydown("left", () => {
4742
3546
  services?.editorService.move(-1, 0);
4743
- }).keydown("right", (e) => {
4744
- e.inputEvent.preventDefault();
3547
+ }).keydown("right", () => {
4745
3548
  services?.editorService.move(1, 0);
4746
- }).keydown([ctrl, "up"], (e) => {
4747
- e.inputEvent.preventDefault();
3549
+ }).keydown([ctrl, "up"], () => {
4748
3550
  services?.editorService.move(0, -10);
4749
- }).keydown([ctrl, "down"], (e) => {
4750
- e.inputEvent.preventDefault();
3551
+ }).keydown([ctrl, "down"], () => {
4751
3552
  services?.editorService.move(0, 10);
4752
- }).keydown([ctrl, "left"], (e) => {
4753
- e.inputEvent.preventDefault();
3553
+ }).keydown([ctrl, "left"], () => {
4754
3554
  services?.editorService.move(-10, 0);
4755
- }).keydown([ctrl, "right"], (e) => {
4756
- e.inputEvent.preventDefault();
3555
+ }).keydown([ctrl, "right"], () => {
4757
3556
  services?.editorService.move(10, 0);
4758
- }).keydown("tab", (e) => {
4759
- e.inputEvent.preventDefault();
3557
+ }).keydown("tab", () => {
4760
3558
  services?.editorService.selectNextNode();
4761
- }).keydown([ctrl, "tab"], (e) => {
4762
- e.inputEvent.preventDefault();
3559
+ }).keydown([ctrl, "tab"], () => {
4763
3560
  services?.editorService.selectNextPage();
4764
- }).keydown([ctrl, "="], (e) => {
4765
- e.inputEvent.preventDefault();
3561
+ }).keydown([ctrl, "="], () => {
4766
3562
  services?.uiService.zoom(0.1);
4767
- }).keydown([ctrl, "-"], (e) => {
4768
- e.inputEvent.preventDefault();
3563
+ }).keydown([ctrl, "numpadplus"], () => {
3564
+ services?.uiService.zoom(0.1);
3565
+ }).keydown([ctrl, "-"], () => {
3566
+ services?.uiService.zoom(-0.1);
3567
+ }).keydown([ctrl, "numpad-"], () => {
4769
3568
  services?.uiService.zoom(-0.1);
4770
3569
  });
4771
3570
  });
4772
3571
  onUnmounted(() => {
4773
3572
  workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
3573
+ workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
4774
3574
  keycon.destroy();
4775
3575
  });
4776
3576
  return {
@@ -4994,6 +3794,10 @@ const _sfc_main = defineComponent({
4994
3794
  },
4995
3795
  stageRect: {
4996
3796
  type: [String, Object]
3797
+ },
3798
+ codeOptions: {
3799
+ type: Object,
3800
+ default: () => ({})
4997
3801
  }
4998
3802
  },
4999
3803
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -5052,7 +3856,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5052
3856
  const _component_workspace = resolveComponent("workspace");
5053
3857
  const _component_props_panel = resolveComponent("props-panel");
5054
3858
  const _component_framework = resolveComponent("framework");
5055
- return openBlock(), createBlock(_component_framework, null, {
3859
+ return openBlock(), createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
5056
3860
  nav: withCtx(() => [
5057
3861
  renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
5058
3862
  createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
@@ -5096,7 +3900,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5096
3900
  renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
5097
3901
  ]),
5098
3902
  _: 3
5099
- });
3903
+ }, 8, ["code-options"]);
5100
3904
  }
5101
3905
  var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
5102
3906