@tmagic/editor 1.3.11 → 1.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +3 -2
- package/dist/tmagic-editor.js +453 -363
- package/dist/tmagic-editor.umd.cjs +452 -361
- package/package.json +11 -11
- package/src/Editor.vue +28 -21
- package/src/components/SplitView.vue +1 -1
- package/src/editorProps.ts +25 -12
- package/src/fields/UISelect.vue +3 -0
- package/src/hooks/use-stage.ts +3 -1
- package/src/index.ts +1 -0
- package/src/layouts/sidebar/ComponentListPanel.vue +2 -2
- package/src/layouts/sidebar/layer/use-click.ts +3 -0
- package/src/layouts/workspace/Workspace.vue +11 -4
- package/src/layouts/workspace/viewer/Stage.vue +11 -5
- package/src/layouts/workspace/viewer/StageOverlay.vue +55 -5
- package/src/services/editor.ts +7 -6
- package/src/services/stageOverlay.ts +204 -0
- package/src/theme/stage.scss +3 -2
- package/src/type.ts +25 -12
- package/types/editorProps.d.ts +25 -12
- package/types/index.d.ts +1 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +19 -3
- package/types/layouts/workspace/viewer/Stage.vue.d.ts +19 -3
- package/types/services/editor.d.ts +1 -1
- package/types/services/stageOverlay.d.ts +23 -0
- package/types/type.d.ts +24 -12
- package/src/hooks/use-stage-overlay.ts +0 -158
- package/types/hooks/use-stage-overlay.d.ts +0 -7
package/dist/tmagic-editor.js
CHANGED
|
@@ -13,7 +13,7 @@ import Gesto from 'gesto';
|
|
|
13
13
|
import Moveable from 'moveable';
|
|
14
14
|
import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
|
|
15
15
|
export { DepTargetType } from '@tmagic/dep';
|
|
16
|
-
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType
|
|
16
|
+
import StageCore, { GuidesType, getOffset, calcValueByFontsize, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
17
17
|
import { EventEmitter } from 'events';
|
|
18
18
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
19
19
|
import KeyController from 'keycon';
|
|
@@ -1850,6 +1850,197 @@ class Dep extends BaseService {
|
|
|
1850
1850
|
}
|
|
1851
1851
|
const depService = new Dep();
|
|
1852
1852
|
|
|
1853
|
+
class Props extends BaseService {
|
|
1854
|
+
state = reactive({
|
|
1855
|
+
propsConfigMap: {},
|
|
1856
|
+
propsValueMap: {},
|
|
1857
|
+
relateIdMap: {}
|
|
1858
|
+
});
|
|
1859
|
+
constructor() {
|
|
1860
|
+
super([
|
|
1861
|
+
{ name: "setPropsConfig", isAsync: true },
|
|
1862
|
+
{ name: "getPropsConfig", isAsync: true },
|
|
1863
|
+
{ name: "setPropsValue", isAsync: true },
|
|
1864
|
+
{ name: "getPropsValue", isAsync: true },
|
|
1865
|
+
{ name: "createId", isAsync: false },
|
|
1866
|
+
{ name: "setNewItemId", isAsync: true },
|
|
1867
|
+
{ name: "fillConfig", isAsync: true },
|
|
1868
|
+
{ name: "getDefaultPropsValue", isAsync: true }
|
|
1869
|
+
]);
|
|
1870
|
+
}
|
|
1871
|
+
setPropsConfigs(configs) {
|
|
1872
|
+
Object.keys(configs).forEach((type) => {
|
|
1873
|
+
this.setPropsConfig(toLine(type), configs[type]);
|
|
1874
|
+
});
|
|
1875
|
+
this.emit("props-configs-change");
|
|
1876
|
+
}
|
|
1877
|
+
async fillConfig(config) {
|
|
1878
|
+
return fillConfig(config);
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* 为指定类型组件设置组件属性表单配置
|
|
1882
|
+
* @param type 组件类型
|
|
1883
|
+
* @param config 组件属性表单配置
|
|
1884
|
+
*/
|
|
1885
|
+
async setPropsConfig(type, config) {
|
|
1886
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* 获取指点类型的组件属性表单配置
|
|
1890
|
+
* @param type 组件类型
|
|
1891
|
+
* @returns 组件属性表单配置
|
|
1892
|
+
*/
|
|
1893
|
+
async getPropsConfig(type) {
|
|
1894
|
+
if (type === "area") {
|
|
1895
|
+
return await this.getPropsConfig("button");
|
|
1896
|
+
}
|
|
1897
|
+
return cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
1898
|
+
}
|
|
1899
|
+
setPropsValues(values) {
|
|
1900
|
+
Object.keys(values).forEach((type) => {
|
|
1901
|
+
this.setPropsValue(toLine(type), values[type]);
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* 为指点类型组件设置组件初始值
|
|
1906
|
+
* @param type 组件类型
|
|
1907
|
+
* @param value 组件初始值
|
|
1908
|
+
*/
|
|
1909
|
+
async setPropsValue(type, value) {
|
|
1910
|
+
this.state.propsValueMap[type] = value;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* 获取指定类型的组件初始值
|
|
1914
|
+
* @param type 组件类型
|
|
1915
|
+
* @returns 组件初始值
|
|
1916
|
+
*/
|
|
1917
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
1918
|
+
if (type === "area") {
|
|
1919
|
+
const value = await this.getPropsValue("button");
|
|
1920
|
+
value.className = "action-area";
|
|
1921
|
+
value.text = "";
|
|
1922
|
+
if (value.style) {
|
|
1923
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
1924
|
+
}
|
|
1925
|
+
return value;
|
|
1926
|
+
}
|
|
1927
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
1928
|
+
this.createId(type),
|
|
1929
|
+
this.getDefaultPropsValue(type),
|
|
1930
|
+
this.setNewItemId(
|
|
1931
|
+
cloneDeep({
|
|
1932
|
+
type,
|
|
1933
|
+
...defaultValue
|
|
1934
|
+
})
|
|
1935
|
+
)
|
|
1936
|
+
]);
|
|
1937
|
+
return {
|
|
1938
|
+
id,
|
|
1939
|
+
...defaultPropsValue,
|
|
1940
|
+
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
async createId(type) {
|
|
1944
|
+
return `${type}_${guid()}`;
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
1948
|
+
* 如果没有相同ID并且force为false则保持不变
|
|
1949
|
+
* @param {Object} config 组件配置
|
|
1950
|
+
* @param {Boolean} force 是否强制设置新的ID
|
|
1951
|
+
*/
|
|
1952
|
+
/* eslint no-param-reassign: ["error", { "props": false }] */
|
|
1953
|
+
async setNewItemId(config, force = true) {
|
|
1954
|
+
if (force || editorService.getNodeById(config.id)) {
|
|
1955
|
+
const newId = await this.createId(config.type || "component");
|
|
1956
|
+
this.setRelateId(config.id, newId);
|
|
1957
|
+
config.id = newId;
|
|
1958
|
+
}
|
|
1959
|
+
if (config.items && Array.isArray(config.items)) {
|
|
1960
|
+
for (const item of config.items) {
|
|
1961
|
+
await this.setNewItemId(item);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
return config;
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* 获取默认属性配置
|
|
1968
|
+
* @param type 组件类型
|
|
1969
|
+
* @returns Object
|
|
1970
|
+
*/
|
|
1971
|
+
async getDefaultPropsValue(type) {
|
|
1972
|
+
return ["page", "container"].includes(type) ? {
|
|
1973
|
+
type,
|
|
1974
|
+
layout: "absolute",
|
|
1975
|
+
style: {},
|
|
1976
|
+
name: type,
|
|
1977
|
+
items: []
|
|
1978
|
+
} : {
|
|
1979
|
+
type,
|
|
1980
|
+
style: {},
|
|
1981
|
+
name: type
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
resetState() {
|
|
1985
|
+
this.state.propsConfigMap = {};
|
|
1986
|
+
this.state.propsValueMap = {};
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* 替换关联ID
|
|
1990
|
+
* @param originConfigs 原组件配置
|
|
1991
|
+
* @param targetConfigs 待替换的组件配置
|
|
1992
|
+
*/
|
|
1993
|
+
replaceRelateId(originConfigs, targetConfigs) {
|
|
1994
|
+
const relateIdMap = this.getRelateIdMap();
|
|
1995
|
+
if (Object.keys(relateIdMap).length === 0)
|
|
1996
|
+
return;
|
|
1997
|
+
const target = depService.getTarget(DepTargetType.RELATED_COMP_WHEN_COPY, DepTargetType.RELATED_COMP_WHEN_COPY);
|
|
1998
|
+
if (!target)
|
|
1999
|
+
return;
|
|
2000
|
+
originConfigs.forEach((config) => {
|
|
2001
|
+
const newId = relateIdMap[config.id];
|
|
2002
|
+
const targetConfig = targetConfigs.find((targetConfig2) => targetConfig2.id === newId);
|
|
2003
|
+
if (!targetConfig)
|
|
2004
|
+
return;
|
|
2005
|
+
target.deps[config.id]?.keys?.forEach((fullKey) => {
|
|
2006
|
+
const relateOriginId = getValueByKeyPath(fullKey, config);
|
|
2007
|
+
const relateTargetId = relateIdMap[relateOriginId];
|
|
2008
|
+
if (!relateTargetId)
|
|
2009
|
+
return;
|
|
2010
|
+
setValueByKeyPath(fullKey, relateTargetId, targetConfig);
|
|
2011
|
+
});
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* 清除setNewItemId前后映射关系
|
|
2016
|
+
*/
|
|
2017
|
+
clearRelateId() {
|
|
2018
|
+
this.state.relateIdMap = {};
|
|
2019
|
+
}
|
|
2020
|
+
destroy() {
|
|
2021
|
+
this.resetState();
|
|
2022
|
+
this.removeAllListeners();
|
|
2023
|
+
this.removeAllPlugins();
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* 获取setNewItemId前后映射关系
|
|
2027
|
+
* @param oldId 原组件ID
|
|
2028
|
+
* @returns 新旧ID映射
|
|
2029
|
+
*/
|
|
2030
|
+
getRelateIdMap() {
|
|
2031
|
+
return this.state.relateIdMap;
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* 记录setNewItemId前后映射关系
|
|
2035
|
+
* @param oldId 原组件ID
|
|
2036
|
+
* @param newId 分配的新ID
|
|
2037
|
+
*/
|
|
2038
|
+
setRelateId(oldId, newId) {
|
|
2039
|
+
this.state.relateIdMap[oldId] = newId;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
const propsService = new Props();
|
|
2043
|
+
|
|
1853
2044
|
class UndoRedo {
|
|
1854
2045
|
elementList;
|
|
1855
2046
|
listCursor;
|
|
@@ -2104,197 +2295,6 @@ class WebStorage extends BaseService {
|
|
|
2104
2295
|
}
|
|
2105
2296
|
const storageService = new WebStorage();
|
|
2106
2297
|
|
|
2107
|
-
class Props extends BaseService {
|
|
2108
|
-
state = reactive({
|
|
2109
|
-
propsConfigMap: {},
|
|
2110
|
-
propsValueMap: {},
|
|
2111
|
-
relateIdMap: {}
|
|
2112
|
-
});
|
|
2113
|
-
constructor() {
|
|
2114
|
-
super([
|
|
2115
|
-
{ name: "setPropsConfig", isAsync: true },
|
|
2116
|
-
{ name: "getPropsConfig", isAsync: true },
|
|
2117
|
-
{ name: "setPropsValue", isAsync: true },
|
|
2118
|
-
{ name: "getPropsValue", isAsync: true },
|
|
2119
|
-
{ name: "createId", isAsync: false },
|
|
2120
|
-
{ name: "setNewItemId", isAsync: true },
|
|
2121
|
-
{ name: "fillConfig", isAsync: true },
|
|
2122
|
-
{ name: "getDefaultPropsValue", isAsync: true }
|
|
2123
|
-
]);
|
|
2124
|
-
}
|
|
2125
|
-
setPropsConfigs(configs) {
|
|
2126
|
-
Object.keys(configs).forEach((type) => {
|
|
2127
|
-
this.setPropsConfig(toLine(type), configs[type]);
|
|
2128
|
-
});
|
|
2129
|
-
this.emit("props-configs-change");
|
|
2130
|
-
}
|
|
2131
|
-
async fillConfig(config) {
|
|
2132
|
-
return fillConfig(config);
|
|
2133
|
-
}
|
|
2134
|
-
/**
|
|
2135
|
-
* 为指定类型组件设置组件属性表单配置
|
|
2136
|
-
* @param type 组件类型
|
|
2137
|
-
* @param config 组件属性表单配置
|
|
2138
|
-
*/
|
|
2139
|
-
async setPropsConfig(type, config) {
|
|
2140
|
-
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
2141
|
-
}
|
|
2142
|
-
/**
|
|
2143
|
-
* 获取指点类型的组件属性表单配置
|
|
2144
|
-
* @param type 组件类型
|
|
2145
|
-
* @returns 组件属性表单配置
|
|
2146
|
-
*/
|
|
2147
|
-
async getPropsConfig(type) {
|
|
2148
|
-
if (type === "area") {
|
|
2149
|
-
return await this.getPropsConfig("button");
|
|
2150
|
-
}
|
|
2151
|
-
return cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
2152
|
-
}
|
|
2153
|
-
setPropsValues(values) {
|
|
2154
|
-
Object.keys(values).forEach((type) => {
|
|
2155
|
-
this.setPropsValue(toLine(type), values[type]);
|
|
2156
|
-
});
|
|
2157
|
-
}
|
|
2158
|
-
/**
|
|
2159
|
-
* 为指点类型组件设置组件初始值
|
|
2160
|
-
* @param type 组件类型
|
|
2161
|
-
* @param value 组件初始值
|
|
2162
|
-
*/
|
|
2163
|
-
async setPropsValue(type, value) {
|
|
2164
|
-
this.state.propsValueMap[type] = value;
|
|
2165
|
-
}
|
|
2166
|
-
/**
|
|
2167
|
-
* 获取指定类型的组件初始值
|
|
2168
|
-
* @param type 组件类型
|
|
2169
|
-
* @returns 组件初始值
|
|
2170
|
-
*/
|
|
2171
|
-
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
2172
|
-
if (type === "area") {
|
|
2173
|
-
const value = await this.getPropsValue("button");
|
|
2174
|
-
value.className = "action-area";
|
|
2175
|
-
value.text = "";
|
|
2176
|
-
if (value.style) {
|
|
2177
|
-
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
2178
|
-
}
|
|
2179
|
-
return value;
|
|
2180
|
-
}
|
|
2181
|
-
const [id, defaultPropsValue, data] = await Promise.all([
|
|
2182
|
-
this.createId(type),
|
|
2183
|
-
this.getDefaultPropsValue(type),
|
|
2184
|
-
this.setNewItemId(
|
|
2185
|
-
cloneDeep({
|
|
2186
|
-
type,
|
|
2187
|
-
...defaultValue
|
|
2188
|
-
})
|
|
2189
|
-
)
|
|
2190
|
-
]);
|
|
2191
|
-
return {
|
|
2192
|
-
id,
|
|
2193
|
-
...defaultPropsValue,
|
|
2194
|
-
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
2195
|
-
};
|
|
2196
|
-
}
|
|
2197
|
-
async createId(type) {
|
|
2198
|
-
return `${type}_${guid()}`;
|
|
2199
|
-
}
|
|
2200
|
-
/**
|
|
2201
|
-
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
2202
|
-
* 如果没有相同ID并且force为false则保持不变
|
|
2203
|
-
* @param {Object} config 组件配置
|
|
2204
|
-
* @param {Boolean} force 是否强制设置新的ID
|
|
2205
|
-
*/
|
|
2206
|
-
/* eslint no-param-reassign: ["error", { "props": false }] */
|
|
2207
|
-
async setNewItemId(config, force = true) {
|
|
2208
|
-
if (force || editorService.getNodeById(config.id)) {
|
|
2209
|
-
const newId = await this.createId(config.type || "component");
|
|
2210
|
-
this.setRelateId(config.id, newId);
|
|
2211
|
-
config.id = newId;
|
|
2212
|
-
}
|
|
2213
|
-
if (config.items && Array.isArray(config.items)) {
|
|
2214
|
-
for (const item of config.items) {
|
|
2215
|
-
await this.setNewItemId(item);
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
return config;
|
|
2219
|
-
}
|
|
2220
|
-
/**
|
|
2221
|
-
* 获取默认属性配置
|
|
2222
|
-
* @param type 组件类型
|
|
2223
|
-
* @returns Object
|
|
2224
|
-
*/
|
|
2225
|
-
async getDefaultPropsValue(type) {
|
|
2226
|
-
return ["page", "container"].includes(type) ? {
|
|
2227
|
-
type,
|
|
2228
|
-
layout: "absolute",
|
|
2229
|
-
style: {},
|
|
2230
|
-
name: type,
|
|
2231
|
-
items: []
|
|
2232
|
-
} : {
|
|
2233
|
-
type,
|
|
2234
|
-
style: {},
|
|
2235
|
-
name: type
|
|
2236
|
-
};
|
|
2237
|
-
}
|
|
2238
|
-
resetState() {
|
|
2239
|
-
this.state.propsConfigMap = {};
|
|
2240
|
-
this.state.propsValueMap = {};
|
|
2241
|
-
}
|
|
2242
|
-
/**
|
|
2243
|
-
* 替换关联ID
|
|
2244
|
-
* @param originConfigs 原组件配置
|
|
2245
|
-
* @param targetConfigs 待替换的组件配置
|
|
2246
|
-
*/
|
|
2247
|
-
replaceRelateId(originConfigs, targetConfigs) {
|
|
2248
|
-
const relateIdMap = this.getRelateIdMap();
|
|
2249
|
-
if (Object.keys(relateIdMap).length === 0)
|
|
2250
|
-
return;
|
|
2251
|
-
const target = depService.getTarget(DepTargetType.RELATED_COMP_WHEN_COPY, DepTargetType.RELATED_COMP_WHEN_COPY);
|
|
2252
|
-
if (!target)
|
|
2253
|
-
return;
|
|
2254
|
-
originConfigs.forEach((config) => {
|
|
2255
|
-
const newId = relateIdMap[config.id];
|
|
2256
|
-
const targetConfig = targetConfigs.find((targetConfig2) => targetConfig2.id === newId);
|
|
2257
|
-
if (!targetConfig)
|
|
2258
|
-
return;
|
|
2259
|
-
target.deps[config.id]?.keys?.forEach((fullKey) => {
|
|
2260
|
-
const relateOriginId = getValueByKeyPath(fullKey, config);
|
|
2261
|
-
const relateTargetId = relateIdMap[relateOriginId];
|
|
2262
|
-
if (!relateTargetId)
|
|
2263
|
-
return;
|
|
2264
|
-
setValueByKeyPath(fullKey, relateTargetId, targetConfig);
|
|
2265
|
-
});
|
|
2266
|
-
});
|
|
2267
|
-
}
|
|
2268
|
-
/**
|
|
2269
|
-
* 清除setNewItemId前后映射关系
|
|
2270
|
-
*/
|
|
2271
|
-
clearRelateId() {
|
|
2272
|
-
this.state.relateIdMap = {};
|
|
2273
|
-
}
|
|
2274
|
-
destroy() {
|
|
2275
|
-
this.resetState();
|
|
2276
|
-
this.removeAllListeners();
|
|
2277
|
-
this.removeAllPlugins();
|
|
2278
|
-
}
|
|
2279
|
-
/**
|
|
2280
|
-
* 获取setNewItemId前后映射关系
|
|
2281
|
-
* @param oldId 原组件ID
|
|
2282
|
-
* @returns 新旧ID映射
|
|
2283
|
-
*/
|
|
2284
|
-
getRelateIdMap() {
|
|
2285
|
-
return this.state.relateIdMap;
|
|
2286
|
-
}
|
|
2287
|
-
/**
|
|
2288
|
-
* 记录setNewItemId前后映射关系
|
|
2289
|
-
* @param oldId 原组件ID
|
|
2290
|
-
* @param newId 分配的新ID
|
|
2291
|
-
*/
|
|
2292
|
-
setRelateId(oldId, newId) {
|
|
2293
|
-
this.state.relateIdMap[oldId] = newId;
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
const propsService = new Props();
|
|
2297
|
-
|
|
2298
2298
|
class Editor extends BaseService {
|
|
2299
2299
|
state = reactive({
|
|
2300
2300
|
root: null,
|
|
@@ -2930,14 +2930,14 @@ class Editor extends BaseService {
|
|
|
2930
2930
|
* @param targetId 容器ID
|
|
2931
2931
|
*/
|
|
2932
2932
|
async moveToContainer(config, targetId) {
|
|
2933
|
-
const root =
|
|
2933
|
+
const root = this.get("root");
|
|
2934
2934
|
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
2935
2935
|
const target = this.getNodeById(targetId, false);
|
|
2936
2936
|
const stage = this.get("stage");
|
|
2937
2937
|
if (root && node && parent && stage) {
|
|
2938
2938
|
const index = getNodeIndex(node.id, parent);
|
|
2939
2939
|
parent.items?.splice(index, 1);
|
|
2940
|
-
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
2940
|
+
await stage.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
|
|
2941
2941
|
const layout = await this.getLayout(target);
|
|
2942
2942
|
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
2943
2943
|
if (Array.isArray(srcValue)) {
|
|
@@ -2948,7 +2948,7 @@ class Editor extends BaseService {
|
|
|
2948
2948
|
target.items.push(newConfig);
|
|
2949
2949
|
await stage.select(targetId);
|
|
2950
2950
|
const targetParent = this.getParentById(target.id);
|
|
2951
|
-
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
|
|
2951
|
+
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root: cloneDeep(root) });
|
|
2952
2952
|
await this.select(newConfig);
|
|
2953
2953
|
stage.select(newConfig.id);
|
|
2954
2954
|
this.addModifiedNodeId(target.id);
|
|
@@ -2993,6 +2993,7 @@ class Editor extends BaseService {
|
|
|
2993
2993
|
this.addModifiedNodeId(config.id);
|
|
2994
2994
|
this.addModifiedNodeId(parent.id);
|
|
2995
2995
|
this.pushHistoryState();
|
|
2996
|
+
this.emit("drag-to", { index, targetIndex, config, parent, targetParent });
|
|
2996
2997
|
}
|
|
2997
2998
|
/**
|
|
2998
2999
|
* 撤销当前操作
|
|
@@ -5218,14 +5219,17 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
5218
5219
|
const selectNode = async (id) => {
|
|
5219
5220
|
await services?.editorService.select(id);
|
|
5220
5221
|
services?.editorService.get("stage")?.select(id);
|
|
5222
|
+
services?.stageOverlayService.get("stage")?.select(id);
|
|
5221
5223
|
};
|
|
5222
5224
|
const highlight = throttle((id) => {
|
|
5223
5225
|
services?.editorService.highlight(id);
|
|
5224
5226
|
services?.editorService.get("stage")?.highlight(id);
|
|
5227
|
+
services?.stageOverlayService.get("stage")?.highlight(id);
|
|
5225
5228
|
}, 150);
|
|
5226
5229
|
const unhightlight = () => {
|
|
5227
5230
|
services?.editorService.set("highlightNode", null);
|
|
5228
5231
|
services?.editorService.get("stage")?.clearHighlight();
|
|
5232
|
+
services?.stageOverlayService.get("stage")?.clearHighlight();
|
|
5229
5233
|
};
|
|
5230
5234
|
return (_ctx, _cache) => {
|
|
5231
5235
|
return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
|
|
@@ -5365,7 +5369,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5365
5369
|
|
|
5366
5370
|
const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
5367
5371
|
...{
|
|
5368
|
-
name: "
|
|
5372
|
+
name: "MEditorSplitView"
|
|
5369
5373
|
},
|
|
5370
5374
|
__name: "SplitView",
|
|
5371
5375
|
props: {
|
|
@@ -7893,6 +7897,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
|
|
|
7893
7897
|
} else {
|
|
7894
7898
|
await services?.editorService.select(data);
|
|
7895
7899
|
services?.editorService.get("stage")?.select(data.id);
|
|
7900
|
+
services?.stageOverlayService.get("stage")?.select(data.id);
|
|
7896
7901
|
}
|
|
7897
7902
|
};
|
|
7898
7903
|
const multiSelect = async (data) => {
|
|
@@ -7911,6 +7916,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
|
|
|
7911
7916
|
}
|
|
7912
7917
|
await services?.editorService.multiSelect(newNodes);
|
|
7913
7918
|
services?.editorService.get("stage")?.multiSelect(newNodes);
|
|
7919
|
+
services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
|
|
7914
7920
|
};
|
|
7915
7921
|
const throttleTime = 300;
|
|
7916
7922
|
const highlightHandler = throttle((event, data) => {
|
|
@@ -7919,6 +7925,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
|
|
|
7919
7925
|
const highlight = (data) => {
|
|
7920
7926
|
services?.editorService?.highlight(data);
|
|
7921
7927
|
services?.editorService?.get("stage")?.highlight(data.id);
|
|
7928
|
+
services?.stageOverlayService?.get("stage")?.highlight(data.id);
|
|
7922
7929
|
};
|
|
7923
7930
|
const nodeClickHandler = (event, data) => {
|
|
7924
7931
|
if (!nodeStatusMap?.value)
|
|
@@ -8468,8 +8475,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
8468
8475
|
globalThis.clearTimeout(timeout);
|
|
8469
8476
|
timeout = void 0;
|
|
8470
8477
|
}
|
|
8471
|
-
const doc = stage.value?.renderer.
|
|
8472
|
-
if (doc && stageOptions) {
|
|
8478
|
+
const doc = stage.value?.renderer.getDocument();
|
|
8479
|
+
if (doc && stageOptions?.containerHighlightClassName) {
|
|
8473
8480
|
removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
8474
8481
|
}
|
|
8475
8482
|
clientX = 0;
|
|
@@ -9277,7 +9284,9 @@ const useStage = (stageOptions) => {
|
|
|
9277
9284
|
disabledDragStart: stageOptions.disabledDragStart,
|
|
9278
9285
|
renderType: stageOptions.renderType,
|
|
9279
9286
|
canSelect: (el, event, stop) => {
|
|
9280
|
-
|
|
9287
|
+
if (!stageOptions.canSelect)
|
|
9288
|
+
return true;
|
|
9289
|
+
const elCanSelect = stageOptions.canSelect?.(el);
|
|
9281
9290
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
9282
9291
|
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
9283
9292
|
return stop();
|
|
@@ -9572,152 +9581,71 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
9572
9581
|
}
|
|
9573
9582
|
});
|
|
9574
9583
|
|
|
9575
|
-
const useStageOverlay = () => {
|
|
9576
|
-
const services = inject("services");
|
|
9577
|
-
const stageOptions = inject("stageOptions");
|
|
9578
|
-
const wrapWidth = ref(0);
|
|
9579
|
-
const wrapHeight = ref(0);
|
|
9580
|
-
const stageOverlayVisible = ref(false);
|
|
9581
|
-
const stageOverlay = ref();
|
|
9582
|
-
const stage = computed(() => services?.editorService.get("stage"));
|
|
9583
|
-
let subStage = null;
|
|
9584
|
-
const div = document.createElement("div");
|
|
9585
|
-
let selectEl = null;
|
|
9586
|
-
const render = () => {
|
|
9587
|
-
if (!selectEl)
|
|
9588
|
-
return;
|
|
9589
|
-
const content = selectEl.cloneNode(true);
|
|
9590
|
-
content.style.position = "static";
|
|
9591
|
-
Array.from(div.children).forEach((element) => {
|
|
9592
|
-
element.remove();
|
|
9593
|
-
});
|
|
9594
|
-
div.appendChild(content);
|
|
9595
|
-
subStage?.renderer.contentWindow?.magic.onPageElUpdate(div);
|
|
9596
|
-
subStage?.select(content);
|
|
9597
|
-
};
|
|
9598
|
-
const copyDocumentElement = () => {
|
|
9599
|
-
const doc = subStage?.renderer.getDocument();
|
|
9600
|
-
const documentElement = stage.value?.renderer.getDocument()?.documentElement;
|
|
9601
|
-
if (doc && documentElement) {
|
|
9602
|
-
doc.replaceChild(documentElement.cloneNode(true), doc.documentElement);
|
|
9603
|
-
}
|
|
9604
|
-
};
|
|
9605
|
-
const updateOverlay = () => {
|
|
9606
|
-
if (!selectEl)
|
|
9607
|
-
return;
|
|
9608
|
-
const { scrollWidth, scrollHeight } = selectEl;
|
|
9609
|
-
stageOverlay.value.style.width = `${scrollWidth}px`;
|
|
9610
|
-
stageOverlay.value.style.height = `${scrollHeight}px`;
|
|
9611
|
-
wrapWidth.value = scrollWidth;
|
|
9612
|
-
wrapHeight.value = scrollHeight;
|
|
9613
|
-
};
|
|
9614
|
-
const updateHandler = () => {
|
|
9615
|
-
render();
|
|
9616
|
-
updateOverlay();
|
|
9617
|
-
};
|
|
9618
|
-
const addHandler = () => {
|
|
9619
|
-
render();
|
|
9620
|
-
updateOverlay();
|
|
9621
|
-
};
|
|
9622
|
-
const removeHandler = () => {
|
|
9623
|
-
render();
|
|
9624
|
-
updateOverlay();
|
|
9625
|
-
};
|
|
9626
|
-
const openOverlay = async (el) => {
|
|
9627
|
-
selectEl = el;
|
|
9628
|
-
stageOverlayVisible.value = true;
|
|
9629
|
-
if (!stageOverlay.value) {
|
|
9630
|
-
await nextTick();
|
|
9631
|
-
}
|
|
9632
|
-
if (!stageOptions) {
|
|
9633
|
-
return;
|
|
9634
|
-
}
|
|
9635
|
-
subStage = useStage({
|
|
9636
|
-
...stageOptions,
|
|
9637
|
-
runtimeUrl: "",
|
|
9638
|
-
autoScrollIntoView: false,
|
|
9639
|
-
render(stage2) {
|
|
9640
|
-
copyDocumentElement();
|
|
9641
|
-
const rootEl = stage2.renderer.getDocument()?.getElementById("app");
|
|
9642
|
-
if (rootEl) {
|
|
9643
|
-
rootEl.remove();
|
|
9644
|
-
}
|
|
9645
|
-
div.style.cssText = `
|
|
9646
|
-
width: ${el.scrollWidth}px;
|
|
9647
|
-
height: ${el.scrollHeight}px;
|
|
9648
|
-
background-color: #fff;
|
|
9649
|
-
`;
|
|
9650
|
-
render();
|
|
9651
|
-
return div;
|
|
9652
|
-
}
|
|
9653
|
-
});
|
|
9654
|
-
subStage.mount(stageOverlay.value);
|
|
9655
|
-
const { mask, renderer } = subStage;
|
|
9656
|
-
const { contentWindow } = renderer;
|
|
9657
|
-
mask.showRule(false);
|
|
9658
|
-
updateOverlay();
|
|
9659
|
-
contentWindow?.magic.onRuntimeReady({});
|
|
9660
|
-
services?.editorService.on("update", updateHandler);
|
|
9661
|
-
services?.editorService.on("add", addHandler);
|
|
9662
|
-
services?.editorService.on("remove", removeHandler);
|
|
9663
|
-
};
|
|
9664
|
-
const closeOverlay = () => {
|
|
9665
|
-
stageOverlayVisible.value = false;
|
|
9666
|
-
subStage?.destroy();
|
|
9667
|
-
subStage = null;
|
|
9668
|
-
services?.editorService.off("update", updateHandler);
|
|
9669
|
-
services?.editorService.off("add", addHandler);
|
|
9670
|
-
services?.editorService.off("remove", removeHandler);
|
|
9671
|
-
};
|
|
9672
|
-
watch(stage, (stage2) => {
|
|
9673
|
-
if (stage2) {
|
|
9674
|
-
stage2.on("dblclick", async (event) => {
|
|
9675
|
-
const el = await stage2.actionManager.getElementFromPoint(event);
|
|
9676
|
-
if (el) {
|
|
9677
|
-
openOverlay(el);
|
|
9678
|
-
}
|
|
9679
|
-
});
|
|
9680
|
-
} else if (subStage) {
|
|
9681
|
-
closeOverlay();
|
|
9682
|
-
}
|
|
9683
|
-
});
|
|
9684
|
-
return {
|
|
9685
|
-
wrapWidth,
|
|
9686
|
-
wrapHeight,
|
|
9687
|
-
stageOverlayVisible,
|
|
9688
|
-
stageOverlay,
|
|
9689
|
-
closeOverlay
|
|
9690
|
-
};
|
|
9691
|
-
};
|
|
9692
|
-
|
|
9693
9584
|
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
9694
9585
|
__name: "StageOverlay",
|
|
9695
9586
|
setup(__props) {
|
|
9696
|
-
const
|
|
9587
|
+
const services = inject("services");
|
|
9588
|
+
const stageOptions = inject("stageOptions");
|
|
9589
|
+
const stageOverlay = ref();
|
|
9590
|
+
const stageOverlayVisible = computed(() => services?.stageOverlayService.get("stageOverlayVisible"));
|
|
9591
|
+
const wrapWidth = computed(() => services?.stageOverlayService.get("wrapWidth") || 0);
|
|
9592
|
+
const wrapHeight = computed(() => services?.stageOverlayService.get("wrapHeight") || 0);
|
|
9593
|
+
const stage = computed(() => services?.editorService.get("stage"));
|
|
9594
|
+
const style = computed(() => ({
|
|
9595
|
+
width: `${wrapWidth.value}px`,
|
|
9596
|
+
height: `${wrapHeight.value}px`
|
|
9597
|
+
}));
|
|
9598
|
+
watch(stage, (stage2) => {
|
|
9599
|
+
if (stage2) {
|
|
9600
|
+
stage2.on("dblclick", async (event) => {
|
|
9601
|
+
const el = await stage2.actionManager.getElementFromPoint(event);
|
|
9602
|
+
services?.stageOverlayService.openOverlay(el);
|
|
9603
|
+
});
|
|
9604
|
+
} else {
|
|
9605
|
+
services?.stageOverlayService.closeOverlay();
|
|
9606
|
+
}
|
|
9607
|
+
});
|
|
9608
|
+
watch(stageOverlay, (stageOverlay2) => {
|
|
9609
|
+
if (!services)
|
|
9610
|
+
return;
|
|
9611
|
+
const subStage = services.stageOverlayService.createStage(stageOptions);
|
|
9612
|
+
services?.stageOverlayService.set("stage", subStage);
|
|
9613
|
+
if (stageOverlay2 && subStage) {
|
|
9614
|
+
subStage.mount(stageOverlay2);
|
|
9615
|
+
const { mask, renderer } = subStage;
|
|
9616
|
+
const { contentWindow } = renderer;
|
|
9617
|
+
mask.showRule(false);
|
|
9618
|
+
services?.stageOverlayService.updateOverlay();
|
|
9619
|
+
contentWindow?.magic.onRuntimeReady({});
|
|
9620
|
+
}
|
|
9621
|
+
});
|
|
9622
|
+
const closeOverlayHandler = () => {
|
|
9623
|
+
services?.stageOverlayService.closeOverlay();
|
|
9624
|
+
};
|
|
9697
9625
|
return (_ctx, _cache) => {
|
|
9698
|
-
return
|
|
9626
|
+
return stageOverlayVisible.value ? (openBlock(), createElementBlock("div", {
|
|
9699
9627
|
key: 0,
|
|
9700
9628
|
class: "m-editor-stage-overlay",
|
|
9701
|
-
onClick:
|
|
9702
|
-
(...args) => unref(closeOverlay) && unref(closeOverlay)(...args))
|
|
9629
|
+
onClick: closeOverlayHandler
|
|
9703
9630
|
}, [
|
|
9704
9631
|
createVNode(unref(TMagicIcon), {
|
|
9705
9632
|
class: "m-editor-stage-overlay-close",
|
|
9706
9633
|
size: 20,
|
|
9707
|
-
onClick:
|
|
9634
|
+
onClick: closeOverlayHandler
|
|
9708
9635
|
}, {
|
|
9709
9636
|
default: withCtx(() => [
|
|
9710
9637
|
createVNode(unref(CloseBold))
|
|
9711
9638
|
]),
|
|
9712
9639
|
_: 1
|
|
9713
|
-
}
|
|
9640
|
+
}),
|
|
9714
9641
|
createElementVNode("div", {
|
|
9715
9642
|
ref_key: "stageOverlay",
|
|
9716
9643
|
ref: stageOverlay,
|
|
9717
9644
|
class: "m-editor-stage-overlay-container",
|
|
9645
|
+
style: normalizeStyle(style.value),
|
|
9718
9646
|
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
9719
9647
|
}, ["stop"]))
|
|
9720
|
-
}, null,
|
|
9648
|
+
}, null, 4)
|
|
9721
9649
|
])) : createCommentVNode("", true);
|
|
9722
9650
|
};
|
|
9723
9651
|
}
|
|
@@ -9904,7 +9832,8 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
9904
9832
|
__name: "Stage",
|
|
9905
9833
|
props: {
|
|
9906
9834
|
stageContentMenu: {},
|
|
9907
|
-
|
|
9835
|
+
disabledStageOverlay: { type: Boolean, default: false },
|
|
9836
|
+
customContentMenu: {}
|
|
9908
9837
|
},
|
|
9909
9838
|
setup(__props) {
|
|
9910
9839
|
let stage = null;
|
|
@@ -10065,7 +9994,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
10065
9994
|
onClick: _cache[0] || (_cache[0] = ($event) => stageWrap.value?.container?.focus())
|
|
10066
9995
|
}, {
|
|
10067
9996
|
content: withCtx(() => [
|
|
10068
|
-
|
|
9997
|
+
!_ctx.disabledStageOverlay ? (openBlock(), createBlock(_sfc_main$6, { key: 0 })) : createCommentVNode("", true),
|
|
10069
9998
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
10070
9999
|
createVNode(_sfc_main$4, {
|
|
10071
10000
|
ref_key: "menu",
|
|
@@ -10147,7 +10076,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
10147
10076
|
__name: "Workspace",
|
|
10148
10077
|
props: {
|
|
10149
10078
|
stageContentMenu: {},
|
|
10150
|
-
|
|
10079
|
+
disabledStageOverlay: { type: Boolean, default: false },
|
|
10080
|
+
customContentMenu: {}
|
|
10151
10081
|
},
|
|
10152
10082
|
setup(__props) {
|
|
10153
10083
|
const services = inject("services");
|
|
@@ -10158,9 +10088,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
10158
10088
|
renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
10159
10089
|
page.value ? (openBlock(), createBlock(_sfc_main$3, {
|
|
10160
10090
|
key: 0,
|
|
10091
|
+
"disabled-stage-overlay": _ctx.disabledStageOverlay,
|
|
10161
10092
|
"stage-content-menu": _ctx.stageContentMenu,
|
|
10162
10093
|
"custom-content-menu": _ctx.customContentMenu
|
|
10163
|
-
}, null, 8, ["stage-content-menu", "custom-content-menu"])) : createCommentVNode("", true)
|
|
10094
|
+
}, null, 8, ["disabled-stage-overlay", "stage-content-menu", "custom-content-menu"])) : createCommentVNode("", true)
|
|
10164
10095
|
]),
|
|
10165
10096
|
renderSlot(_ctx.$slots, "workspace-content")
|
|
10166
10097
|
]);
|
|
@@ -10619,7 +10550,170 @@ class Keybinding extends BaseService {
|
|
|
10619
10550
|
}
|
|
10620
10551
|
const keybindingService = new Keybinding();
|
|
10621
10552
|
|
|
10553
|
+
class StageOverlay extends BaseService {
|
|
10554
|
+
state = reactive({
|
|
10555
|
+
wrapDiv: document.createElement("div"),
|
|
10556
|
+
sourceEl: null,
|
|
10557
|
+
contentEl: null,
|
|
10558
|
+
stage: null,
|
|
10559
|
+
stageOptions: null,
|
|
10560
|
+
wrapWidth: 0,
|
|
10561
|
+
wrapHeight: 0,
|
|
10562
|
+
stageOverlayVisible: false
|
|
10563
|
+
});
|
|
10564
|
+
constructor() {
|
|
10565
|
+
super([
|
|
10566
|
+
{ name: "openOverlay", isAsync: false },
|
|
10567
|
+
{ name: "closeOverlay", isAsync: false },
|
|
10568
|
+
{ name: "updateOverlay", isAsync: false },
|
|
10569
|
+
{ name: "createStage", isAsync: false }
|
|
10570
|
+
]);
|
|
10571
|
+
this.get("wrapDiv").classList.add("tmagic-editor-sub-stage-wrap");
|
|
10572
|
+
}
|
|
10573
|
+
get(name) {
|
|
10574
|
+
return this.state[name];
|
|
10575
|
+
}
|
|
10576
|
+
set(name, value) {
|
|
10577
|
+
this.state[name] = value;
|
|
10578
|
+
}
|
|
10579
|
+
openOverlay(el) {
|
|
10580
|
+
const stageOptions = this.get("stageOptions");
|
|
10581
|
+
if (!el || !stageOptions)
|
|
10582
|
+
return;
|
|
10583
|
+
this.set("sourceEl", el);
|
|
10584
|
+
this.createContentEl();
|
|
10585
|
+
this.set("stageOverlayVisible", true);
|
|
10586
|
+
editorService.on("update", this.updateHandler);
|
|
10587
|
+
editorService.on("add", this.addHandler);
|
|
10588
|
+
editorService.on("remove", this.removeHandler);
|
|
10589
|
+
editorService.on("drag-to", this.updateHandler);
|
|
10590
|
+
editorService.on("move-layer", this.updateHandler);
|
|
10591
|
+
}
|
|
10592
|
+
closeOverlay() {
|
|
10593
|
+
this.set("stageOverlayVisible", false);
|
|
10594
|
+
const subStage = this.get("stage");
|
|
10595
|
+
const wrapDiv = this.get("wrapDiv");
|
|
10596
|
+
subStage?.destroy();
|
|
10597
|
+
wrapDiv.remove();
|
|
10598
|
+
this.set("stage", null);
|
|
10599
|
+
this.set("sourceEl", null);
|
|
10600
|
+
this.set("contentEl", null);
|
|
10601
|
+
editorService.off("update", this.updateHandler);
|
|
10602
|
+
editorService.off("add", this.addHandler);
|
|
10603
|
+
editorService.off("remove", this.removeHandler);
|
|
10604
|
+
editorService.off("drag-to", this.updateHandler);
|
|
10605
|
+
editorService.off("move-layer", this.updateHandler);
|
|
10606
|
+
}
|
|
10607
|
+
updateOverlay() {
|
|
10608
|
+
const sourceEl = this.get("sourceEl");
|
|
10609
|
+
if (!sourceEl)
|
|
10610
|
+
return;
|
|
10611
|
+
const { scrollWidth, scrollHeight } = sourceEl;
|
|
10612
|
+
this.set("wrapWidth", scrollWidth);
|
|
10613
|
+
this.set("wrapHeight", scrollHeight);
|
|
10614
|
+
}
|
|
10615
|
+
createStage(stageOptions = {}) {
|
|
10616
|
+
return useStage({
|
|
10617
|
+
...stageOptions,
|
|
10618
|
+
runtimeUrl: "",
|
|
10619
|
+
autoScrollIntoView: false,
|
|
10620
|
+
render: async (stage) => {
|
|
10621
|
+
this.copyDocumentElement();
|
|
10622
|
+
const rootEls = stage.renderer.getDocument()?.body.children;
|
|
10623
|
+
if (rootEls) {
|
|
10624
|
+
Array.from(rootEls).forEach((element) => {
|
|
10625
|
+
if (["SCRIPT", "STYLE"].includes(element.tagName)) {
|
|
10626
|
+
return;
|
|
10627
|
+
}
|
|
10628
|
+
element.remove();
|
|
10629
|
+
});
|
|
10630
|
+
}
|
|
10631
|
+
const wrapDiv = this.get("wrapDiv");
|
|
10632
|
+
await this.render();
|
|
10633
|
+
return wrapDiv;
|
|
10634
|
+
}
|
|
10635
|
+
});
|
|
10636
|
+
}
|
|
10637
|
+
createContentEl() {
|
|
10638
|
+
const sourceEl = this.get("sourceEl");
|
|
10639
|
+
if (!sourceEl)
|
|
10640
|
+
return;
|
|
10641
|
+
const contentEl = sourceEl.cloneNode(true);
|
|
10642
|
+
this.set("contentEl", contentEl);
|
|
10643
|
+
contentEl.style.position = "static";
|
|
10644
|
+
contentEl.style.overflow = "visible";
|
|
10645
|
+
}
|
|
10646
|
+
copyDocumentElement() {
|
|
10647
|
+
const subStage = this.get("stage");
|
|
10648
|
+
const stage = editorService.get("stage");
|
|
10649
|
+
const doc = subStage?.renderer.getDocument();
|
|
10650
|
+
const documentElement = stage?.renderer.getDocument()?.documentElement;
|
|
10651
|
+
if (doc && documentElement) {
|
|
10652
|
+
doc.replaceChild(documentElement.cloneNode(true), doc.documentElement);
|
|
10653
|
+
}
|
|
10654
|
+
}
|
|
10655
|
+
async render() {
|
|
10656
|
+
this.createContentEl();
|
|
10657
|
+
const contentEl = this.get("contentEl");
|
|
10658
|
+
const sourceEl = this.get("sourceEl");
|
|
10659
|
+
const wrapDiv = this.get("wrapDiv");
|
|
10660
|
+
const subStage = this.get("stage");
|
|
10661
|
+
const stageOptions = this.get("stageOptions");
|
|
10662
|
+
if (!contentEl)
|
|
10663
|
+
return;
|
|
10664
|
+
wrapDiv.style.cssText = `
|
|
10665
|
+
width: ${sourceEl?.scrollWidth}px;
|
|
10666
|
+
height: ${sourceEl?.scrollHeight}px;
|
|
10667
|
+
background-color: #fff;
|
|
10668
|
+
`;
|
|
10669
|
+
Array.from(wrapDiv.children).forEach((element) => {
|
|
10670
|
+
element.remove();
|
|
10671
|
+
});
|
|
10672
|
+
wrapDiv.appendChild(contentEl);
|
|
10673
|
+
setTimeout(() => {
|
|
10674
|
+
subStage?.renderer.contentWindow?.magic.onPageElUpdate(wrapDiv);
|
|
10675
|
+
});
|
|
10676
|
+
if (await stageOptions?.canSelect?.(contentEl)) {
|
|
10677
|
+
subStage?.select(contentEl);
|
|
10678
|
+
}
|
|
10679
|
+
}
|
|
10680
|
+
updateHandler = () => {
|
|
10681
|
+
setTimeout(() => {
|
|
10682
|
+
this.render();
|
|
10683
|
+
this.updateOverlay();
|
|
10684
|
+
this.updateSelectStatus();
|
|
10685
|
+
});
|
|
10686
|
+
};
|
|
10687
|
+
addHandler = () => {
|
|
10688
|
+
this.render();
|
|
10689
|
+
this.updateOverlay();
|
|
10690
|
+
this.updateSelectStatus();
|
|
10691
|
+
};
|
|
10692
|
+
removeHandler = () => {
|
|
10693
|
+
this.render();
|
|
10694
|
+
this.updateOverlay();
|
|
10695
|
+
this.updateSelectStatus();
|
|
10696
|
+
};
|
|
10697
|
+
updateSelectStatus() {
|
|
10698
|
+
const subStage = this.get("stage");
|
|
10699
|
+
const nodes = editorService.get("nodes");
|
|
10700
|
+
if (nodes.length > 1) {
|
|
10701
|
+
subStage?.multiSelect(nodes.map((n) => n.id));
|
|
10702
|
+
} else {
|
|
10703
|
+
subStage?.select(nodes[0].id);
|
|
10704
|
+
}
|
|
10705
|
+
}
|
|
10706
|
+
}
|
|
10707
|
+
const stageOverlayService = new StageOverlay();
|
|
10708
|
+
|
|
10622
10709
|
const defaultEditorProps = {
|
|
10710
|
+
renderType: RenderType.IFRAME,
|
|
10711
|
+
disabledMultiSelect: false,
|
|
10712
|
+
disabledPageFragment: false,
|
|
10713
|
+
disabledStageOverlay: false,
|
|
10714
|
+
containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
10715
|
+
containerHighlightDuration: 800,
|
|
10716
|
+
containerHighlightType: ContainerHighlightType.DEFAULT,
|
|
10623
10717
|
componentGroupList: () => [],
|
|
10624
10718
|
datasourceList: () => [],
|
|
10625
10719
|
menu: () => ({ left: [], right: [] }),
|
|
@@ -10632,13 +10726,7 @@ const defaultEditorProps = {
|
|
|
10632
10726
|
datasourceConfigs: () => ({}),
|
|
10633
10727
|
canSelect: (el) => Boolean(el.id),
|
|
10634
10728
|
isContainer: (el) => el.classList.contains("magic-ui-container"),
|
|
10635
|
-
|
|
10636
|
-
containerHighlightDuration: 800,
|
|
10637
|
-
containerHighlightType: ContainerHighlightType.DEFAULT,
|
|
10638
|
-
codeOptions: () => ({}),
|
|
10639
|
-
renderType: RenderType.IFRAME,
|
|
10640
|
-
disabledMultiSelect: false,
|
|
10641
|
-
disabledPageFragment: false
|
|
10729
|
+
codeOptions: () => ({})
|
|
10642
10730
|
};
|
|
10643
10731
|
|
|
10644
10732
|
const initServiceState = (props, {
|
|
@@ -10985,7 +11073,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
10985
11073
|
menu: {},
|
|
10986
11074
|
layerContentMenu: {},
|
|
10987
11075
|
stageContentMenu: {},
|
|
10988
|
-
render: { type: Function },
|
|
10989
11076
|
runtimeUrl: {},
|
|
10990
11077
|
renderType: {},
|
|
10991
11078
|
autoScrollIntoView: { type: Boolean },
|
|
@@ -10997,21 +11084,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
10997
11084
|
datasourceEventMethodList: {},
|
|
10998
11085
|
moveableOptions: { type: Function },
|
|
10999
11086
|
defaultSelected: {},
|
|
11000
|
-
canSelect: { type: Function },
|
|
11001
|
-
isContainer: { type: Function },
|
|
11002
11087
|
containerHighlightClassName: {},
|
|
11003
11088
|
containerHighlightDuration: {},
|
|
11004
11089
|
containerHighlightType: {},
|
|
11005
11090
|
stageRect: {},
|
|
11006
11091
|
codeOptions: {},
|
|
11007
|
-
updateDragEl: { type: Function },
|
|
11008
11092
|
disabledDragStart: { type: Boolean },
|
|
11009
|
-
extendFormState: { type: Function },
|
|
11010
11093
|
collectorOptions: {},
|
|
11011
11094
|
guidesOptions: {},
|
|
11012
11095
|
disabledMultiSelect: { type: Boolean },
|
|
11013
11096
|
disabledPageFragment: { type: Boolean },
|
|
11014
|
-
|
|
11097
|
+
disabledStageOverlay: { type: Boolean },
|
|
11098
|
+
render: { type: Function },
|
|
11099
|
+
updateDragEl: { type: Function },
|
|
11100
|
+
canSelect: { type: Function },
|
|
11101
|
+
isContainer: { type: Function },
|
|
11102
|
+
customContentMenu: { type: Function },
|
|
11103
|
+
extendFormState: { type: Function }
|
|
11015
11104
|
}, defaultEditorProps),
|
|
11016
11105
|
emits: ["props-panel-mounted", "update:modelValue", "props-form-error", "props-submit-error"],
|
|
11017
11106
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -11028,33 +11117,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11028
11117
|
codeBlockService,
|
|
11029
11118
|
depService,
|
|
11030
11119
|
dataSourceService,
|
|
11031
|
-
keybindingService
|
|
11120
|
+
keybindingService,
|
|
11121
|
+
stageOverlayService
|
|
11032
11122
|
};
|
|
11033
11123
|
initServiceEvents(props, emit, services);
|
|
11034
11124
|
initServiceState(props, services);
|
|
11035
11125
|
keybindingService.register(keybindingConfig);
|
|
11036
11126
|
keybindingService.registerEl("global");
|
|
11127
|
+
const stageOptions = {
|
|
11128
|
+
runtimeUrl: props.runtimeUrl,
|
|
11129
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
11130
|
+
render: props.render,
|
|
11131
|
+
moveableOptions: props.moveableOptions,
|
|
11132
|
+
canSelect: props.canSelect,
|
|
11133
|
+
updateDragEl: props.updateDragEl,
|
|
11134
|
+
isContainer: props.isContainer,
|
|
11135
|
+
containerHighlightClassName: props.containerHighlightClassName,
|
|
11136
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
11137
|
+
containerHighlightType: props.containerHighlightType,
|
|
11138
|
+
disabledDragStart: props.disabledDragStart,
|
|
11139
|
+
renderType: props.renderType,
|
|
11140
|
+
guidesOptions: props.guidesOptions,
|
|
11141
|
+
disabledMultiSelect: props.disabledMultiSelect
|
|
11142
|
+
};
|
|
11143
|
+
stageOverlayService.set("stageOptions", stageOptions);
|
|
11037
11144
|
provide("services", services);
|
|
11038
11145
|
provide("codeOptions", props.codeOptions);
|
|
11039
|
-
provide(
|
|
11040
|
-
"stageOptions",
|
|
11041
|
-
reactive({
|
|
11042
|
-
runtimeUrl: props.runtimeUrl,
|
|
11043
|
-
autoScrollIntoView: props.autoScrollIntoView,
|
|
11044
|
-
render: props.render,
|
|
11045
|
-
moveableOptions: props.moveableOptions,
|
|
11046
|
-
canSelect: props.canSelect,
|
|
11047
|
-
updateDragEl: props.updateDragEl,
|
|
11048
|
-
isContainer: props.isContainer,
|
|
11049
|
-
containerHighlightClassName: props.containerHighlightClassName,
|
|
11050
|
-
containerHighlightDuration: props.containerHighlightDuration,
|
|
11051
|
-
containerHighlightType: props.containerHighlightType,
|
|
11052
|
-
disabledDragStart: props.disabledDragStart,
|
|
11053
|
-
renderType: props.renderType,
|
|
11054
|
-
guidesOptions: props.guidesOptions,
|
|
11055
|
-
disabledMultiSelect: props.disabledMultiSelect
|
|
11056
|
-
})
|
|
11057
|
-
);
|
|
11146
|
+
provide("stageOptions", stageOptions);
|
|
11058
11147
|
__expose(services);
|
|
11059
11148
|
return (_ctx, _cache) => {
|
|
11060
11149
|
return openBlock(), createBlock(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
|
|
@@ -11116,6 +11205,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11116
11205
|
workspace: withCtx(() => [
|
|
11117
11206
|
renderSlot(_ctx.$slots, "workspace", { editorService: unref(editorService) }, () => [
|
|
11118
11207
|
createVNode(_sfc_main$1, {
|
|
11208
|
+
"disabled-stage-overlay": _ctx.disabledStageOverlay,
|
|
11119
11209
|
"stage-content-menu": _ctx.stageContentMenu,
|
|
11120
11210
|
"custom-content-menu": _ctx.customContentMenu
|
|
11121
11211
|
}, {
|
|
@@ -11126,7 +11216,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11126
11216
|
renderSlot(_ctx.$slots, "workspace-content", { editorService: unref(editorService) })
|
|
11127
11217
|
]),
|
|
11128
11218
|
_: 3
|
|
11129
|
-
}, 8, ["stage-content-menu", "custom-content-menu"])
|
|
11219
|
+
}, 8, ["disabled-stage-overlay", "stage-content-menu", "custom-content-menu"])
|
|
11130
11220
|
])
|
|
11131
11221
|
]),
|
|
11132
11222
|
"props-panel": withCtx(() => [
|
|
@@ -11197,4 +11287,4 @@ const index = {
|
|
|
11197
11287
|
}
|
|
11198
11288
|
};
|
|
11199
11289
|
|
|
11200
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$Q as CodeBlockEditor, _sfc_main$m as CodeBlockList, _sfc_main$l as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$R as CodeSelect, _sfc_main$N as CodeSelectCol, ColumnLayout, _sfc_main$c as ComponentListPanel, _sfc_main$h as ContentMenu, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K as DataSourceInput, _sfc_main$I as DataSourceMethodSelect, _sfc_main$J as DataSourceMethods, _sfc_main$H as DataSourceMocks, _sfc_main$G as DataSourceSelect, DragType, _sfc_main$F as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$O as Icon, KeyBindingCommand, _sfc_main$D as KeyValue, Keys, LayerOffset, _sfc_main$d as LayerPanel, Layout, _sfc_main$z as LayoutContainer, _sfc_main$C as PageFragmentSelect, _sfc_main$q as PropsPanel, _sfc_main$A as Resizer, _sfc_main$z as SplitView, _sfc_main$U as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$y as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useFloatBox, useStage, warn };
|
|
11290
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$Q as CodeBlockEditor, _sfc_main$m as CodeBlockList, _sfc_main$l as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$R as CodeSelect, _sfc_main$N as CodeSelectCol, ColumnLayout, _sfc_main$c as ComponentListPanel, _sfc_main$h as ContentMenu, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K as DataSourceInput, _sfc_main$I as DataSourceMethodSelect, _sfc_main$J as DataSourceMethods, _sfc_main$H as DataSourceMocks, _sfc_main$G as DataSourceSelect, DragType, _sfc_main$F as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$O as Icon, KeyBindingCommand, _sfc_main$D as KeyValue, Keys, LayerOffset, _sfc_main$d as LayerPanel, Layout, _sfc_main$z as LayoutContainer, _sfc_main$C as PageFragmentSelect, _sfc_main$q as PropsPanel, _sfc_main$A as Resizer, _sfc_main$z as SplitView, _sfc_main$U as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$y as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useFloatBox, useStage, warn };
|