@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.
|
@@ -192,6 +192,7 @@
|
|
|
192
192
|
setup(__props, { emit }) {
|
|
193
193
|
const props = __props;
|
|
194
194
|
const services = vue.inject("services");
|
|
195
|
+
const form = vue.inject("mForm");
|
|
195
196
|
const selectConfig = vue.computed(() => {
|
|
196
197
|
const defaultConfig = {
|
|
197
198
|
multiple: true,
|
|
@@ -214,17 +215,10 @@
|
|
|
214
215
|
});
|
|
215
216
|
const fieldKey = vue.ref("");
|
|
216
217
|
const multiple = vue.ref(true);
|
|
217
|
-
|
|
218
|
-
let shouldWatch = true;
|
|
219
|
-
vue.watch(
|
|
220
|
-
() => props.model[props.name],
|
|
221
|
-
(selectValue) => {
|
|
222
|
-
if (shouldWatch) {
|
|
223
|
-
lastTagSnapshot = lodashEs.cloneDeep(selectValue) || [];
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
);
|
|
218
|
+
const lastTagSnapshot = vue.ref([]);
|
|
227
219
|
vue.watchEffect(async () => {
|
|
220
|
+
if (!props.model[props.name])
|
|
221
|
+
return;
|
|
228
222
|
const combineNames = await Promise.all(
|
|
229
223
|
props.model[props.name].map(async (id) => {
|
|
230
224
|
const { name = "" } = await services?.codeBlockService.getCodeContentById(id) || {};
|
|
@@ -234,11 +228,9 @@
|
|
|
234
228
|
fieldKey.value = combineNames.join("-");
|
|
235
229
|
});
|
|
236
230
|
const changeHandler = async (value) => {
|
|
237
|
-
shouldWatch = false;
|
|
238
231
|
let codeIds = value;
|
|
239
232
|
if (typeof value === "string") {
|
|
240
233
|
multiple.value = false;
|
|
241
|
-
lastTagSnapshot = [lastTagSnapshot];
|
|
242
234
|
codeIds = value ? [value] : [];
|
|
243
235
|
}
|
|
244
236
|
await setCombineRelation(codeIds);
|
|
@@ -249,12 +241,11 @@
|
|
|
249
241
|
let opFlag = CodeSelectOp.CHANGE;
|
|
250
242
|
let diffValues = codeIds;
|
|
251
243
|
if (multiple.value) {
|
|
252
|
-
|
|
253
|
-
|
|
244
|
+
lastTagSnapshot.value = form?.initValues[props.name] || [];
|
|
245
|
+
opFlag = codeIds.length < lastTagSnapshot.value.length ? CodeSelectOp.DELETE : CodeSelectOp.ADD;
|
|
246
|
+
diffValues = lodashEs.xor(codeIds, lastTagSnapshot.value);
|
|
254
247
|
}
|
|
255
248
|
await services?.codeBlockService.setCombineRelation(id, diffValues, opFlag, props.prop);
|
|
256
|
-
lastTagSnapshot = codeIds;
|
|
257
|
-
shouldWatch = true;
|
|
258
249
|
};
|
|
259
250
|
const viewHandler = async () => {
|
|
260
251
|
if (props.model[props.name].length === 0) {
|
|
@@ -3835,7 +3826,7 @@
|
|
|
3835
3826
|
});
|
|
3836
3827
|
return (_ctx, _cache) => {
|
|
3837
3828
|
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
3838
|
-
return __props.menuData.length
|
|
3829
|
+
return __props.menuData.length ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
|
|
3839
3830
|
key: 0,
|
|
3840
3831
|
class: "magic-editor-content-menu",
|
|
3841
3832
|
ref_key: "menu",
|
|
@@ -3863,7 +3854,9 @@
|
|
|
3863
3854
|
onHide: hide
|
|
3864
3855
|
}, null, 8, ["menu-data"])
|
|
3865
3856
|
]))
|
|
3866
|
-
], 4))
|
|
3857
|
+
], 4)), [
|
|
3858
|
+
[vue.vShow, visible.value]
|
|
3859
|
+
]) : vue.createCommentVNode("", true);
|
|
3867
3860
|
};
|
|
3868
3861
|
}
|
|
3869
3862
|
});
|