@tmagic/editor 1.2.0-beta.8 → 1.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, ref, watchEffect, createElementBlock, createVNode, withCtx, createElementVNode, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, normalizeClass, resolveDynamicComponent, toRaw, renderSlot, Fragment, createSlots, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, isRef, Teleport, nextTick, toHandlers, provide } from 'vue';
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, ref, watchEffect, createElementBlock, createVNode, withCtx, createElementVNode, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, normalizeClass, resolveDynamicComponent, toRaw, renderSlot, Fragment, createSlots, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, isRef, withDirectives, Teleport, vShow, nextTick, toHandlers, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import {
|
|
3
|
+
import { map, xor, throttle, pick, cloneDeep, isEmpty, forIn, omit, keys, mergeWith, uniq } from 'lodash-es';
|
|
4
4
|
import { TMagicCard, TMagicTooltip, tMagicMessage, TMagicButton, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicDialog, TMagicInput, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicTabPane, TMagicTabs, TMagicPopover } from '@tmagic/design';
|
|
5
5
|
import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, DocumentCopy, EditPen, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
|
|
6
6
|
import * as monaco from 'monaco-editor';
|
|
@@ -174,6 +174,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
174
174
|
setup(__props, { emit }) {
|
|
175
175
|
const props = __props;
|
|
176
176
|
const services = inject("services");
|
|
177
|
+
const form = inject("mForm");
|
|
177
178
|
const selectConfig = computed(() => {
|
|
178
179
|
const defaultConfig = {
|
|
179
180
|
multiple: true,
|
|
@@ -196,17 +197,10 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
196
197
|
});
|
|
197
198
|
const fieldKey = ref("");
|
|
198
199
|
const multiple = ref(true);
|
|
199
|
-
|
|
200
|
-
let shouldWatch = true;
|
|
201
|
-
watch(
|
|
202
|
-
() => props.model[props.name],
|
|
203
|
-
(selectValue) => {
|
|
204
|
-
if (shouldWatch) {
|
|
205
|
-
lastTagSnapshot = cloneDeep(selectValue) || [];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
);
|
|
200
|
+
const lastTagSnapshot = ref([]);
|
|
209
201
|
watchEffect(async () => {
|
|
202
|
+
if (!props.model[props.name])
|
|
203
|
+
return;
|
|
210
204
|
const combineNames = await Promise.all(
|
|
211
205
|
props.model[props.name].map(async (id) => {
|
|
212
206
|
const { name = "" } = await services?.codeBlockService.getCodeContentById(id) || {};
|
|
@@ -216,11 +210,9 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
216
210
|
fieldKey.value = combineNames.join("-");
|
|
217
211
|
});
|
|
218
212
|
const changeHandler = async (value) => {
|
|
219
|
-
shouldWatch = false;
|
|
220
213
|
let codeIds = value;
|
|
221
214
|
if (typeof value === "string") {
|
|
222
215
|
multiple.value = false;
|
|
223
|
-
lastTagSnapshot = [lastTagSnapshot];
|
|
224
216
|
codeIds = value ? [value] : [];
|
|
225
217
|
}
|
|
226
218
|
await setCombineRelation(codeIds);
|
|
@@ -231,12 +223,11 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
231
223
|
let opFlag = CodeSelectOp.CHANGE;
|
|
232
224
|
let diffValues = codeIds;
|
|
233
225
|
if (multiple.value) {
|
|
234
|
-
|
|
235
|
-
|
|
226
|
+
lastTagSnapshot.value = form?.initValues[props.name] || [];
|
|
227
|
+
opFlag = codeIds.length < lastTagSnapshot.value.length ? CodeSelectOp.DELETE : CodeSelectOp.ADD;
|
|
228
|
+
diffValues = xor(codeIds, lastTagSnapshot.value);
|
|
236
229
|
}
|
|
237
230
|
await services?.codeBlockService.setCombineRelation(id, diffValues, opFlag, props.prop);
|
|
238
|
-
lastTagSnapshot = codeIds;
|
|
239
|
-
shouldWatch = true;
|
|
240
231
|
};
|
|
241
232
|
const viewHandler = async () => {
|
|
242
233
|
if (props.model[props.name].length === 0) {
|
|
@@ -3817,7 +3808,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3817
3808
|
});
|
|
3818
3809
|
return (_ctx, _cache) => {
|
|
3819
3810
|
const _component_content_menu = resolveComponent("content-menu", true);
|
|
3820
|
-
return __props.menuData.length
|
|
3811
|
+
return __props.menuData.length ? withDirectives((openBlock(), createElementBlock("div", {
|
|
3821
3812
|
key: 0,
|
|
3822
3813
|
class: "magic-editor-content-menu",
|
|
3823
3814
|
ref_key: "menu",
|
|
@@ -3845,7 +3836,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3845
3836
|
onHide: hide
|
|
3846
3837
|
}, null, 8, ["menu-data"])
|
|
3847
3838
|
]))
|
|
3848
|
-
], 4))
|
|
3839
|
+
], 4)), [
|
|
3840
|
+
[vShow, visible.value]
|
|
3841
|
+
]) : createCommentVNode("", true);
|
|
3849
3842
|
};
|
|
3850
3843
|
}
|
|
3851
3844
|
});
|