element-less 0.0.61 → 0.0.62

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.
@@ -1163,7 +1163,7 @@ class NodeRange {
1163
1163
  }
1164
1164
  }
1165
1165
  const emptyAttrs = /* @__PURE__ */ Object.create(null);
1166
- class Node {
1166
+ let Node$1 = class Node2 {
1167
1167
  /**
1168
1168
  @internal
1169
1169
  */
@@ -1293,14 +1293,14 @@ class Node {
1293
1293
  copy(content = null) {
1294
1294
  if (content == this.content)
1295
1295
  return this;
1296
- return new Node(this.type, this.attrs, content, this.marks);
1296
+ return new Node2(this.type, this.attrs, content, this.marks);
1297
1297
  }
1298
1298
  /**
1299
1299
  Create a copy of this node, with the given set of marks instead
1300
1300
  of the node's own marks.
1301
1301
  */
1302
1302
  mark(marks) {
1303
- return marks == this.marks ? this : new Node(this.type, this.attrs, this.content, marks);
1303
+ return marks == this.marks ? this : new Node2(this.type, this.attrs, this.content, marks);
1304
1304
  }
1305
1305
  /**
1306
1306
  Create a copy of this node with only the content between the
@@ -1563,9 +1563,9 @@ class Node {
1563
1563
  node.type.checkAttrs(node.attrs);
1564
1564
  return node;
1565
1565
  }
1566
- }
1567
- Node.prototype.text = void 0;
1568
- class TextNode extends Node {
1566
+ };
1567
+ Node$1.prototype.text = void 0;
1568
+ class TextNode extends Node$1 {
1569
1569
  /**
1570
1570
  @internal
1571
1571
  */
@@ -2152,7 +2152,7 @@ let NodeType$1 = class NodeType {
2152
2152
  create(attrs = null, content, marks) {
2153
2153
  if (this.isText)
2154
2154
  throw new Error("NodeType.create can't construct text nodes");
2155
- return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark$1.setFrom(marks));
2155
+ return new Node$1(this, this.computeAttrs(attrs), Fragment.from(content), Mark$1.setFrom(marks));
2156
2156
  }
2157
2157
  /**
2158
2158
  Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
@@ -2162,7 +2162,7 @@ let NodeType$1 = class NodeType {
2162
2162
  createChecked(attrs = null, content, marks) {
2163
2163
  content = Fragment.from(content);
2164
2164
  this.checkContent(content);
2165
- return new Node(this, this.computeAttrs(attrs), content, Mark$1.setFrom(marks));
2165
+ return new Node$1(this, this.computeAttrs(attrs), content, Mark$1.setFrom(marks));
2166
2166
  }
2167
2167
  /**
2168
2168
  Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
@@ -2185,7 +2185,7 @@ let NodeType$1 = class NodeType {
2185
2185
  let after = matched && matched.fillBefore(Fragment.empty, true);
2186
2186
  if (!after)
2187
2187
  return null;
2188
- return new Node(this, attrs, content.append(after), Mark$1.setFrom(marks));
2188
+ return new Node$1(this, attrs, content.append(after), Mark$1.setFrom(marks));
2189
2189
  }
2190
2190
  /**
2191
2191
  Returns true if the given fragment is valid content for this node
@@ -2381,7 +2381,7 @@ class Schema {
2381
2381
  let type = this.marks[prop], excl = type.spec.excludes;
2382
2382
  type.excluded = excl == null ? [type] : excl == "" ? [] : gatherMarks(this, excl.split(" "));
2383
2383
  }
2384
- this.nodeFromJSON = (json) => Node.fromJSON(this, json);
2384
+ this.nodeFromJSON = (json) => Node$1.fromJSON(this, json);
2385
2385
  this.markFromJSON = (json) => Mark$1.fromJSON(this, json);
2386
2386
  this.topNodeType = this.nodes[this.spec.topNode || "doc"];
2387
2387
  this.cached.wrappings = /* @__PURE__ */ Object.create(null);
@@ -2451,7 +2451,7 @@ function isTagRule(rule) {
2451
2451
  function isStyleRule(rule) {
2452
2452
  return rule.style != null;
2453
2453
  }
2454
- class DOMParser {
2454
+ let DOMParser$1 = class DOMParser2 {
2455
2455
  /**
2456
2456
  Create a parser that targets the given schema, using the given
2457
2457
  parsing rules.
@@ -2577,9 +2577,9 @@ class DOMParser {
2577
2577
  [priority](https://prosemirror.net/docs/ref/#model.GenericParseRule.priority).
2578
2578
  */
2579
2579
  static fromSchema(schema2) {
2580
- return schema2.cached.domParser || (schema2.cached.domParser = new DOMParser(schema2, DOMParser.schemaRules(schema2)));
2580
+ return schema2.cached.domParser || (schema2.cached.domParser = new DOMParser2(schema2, DOMParser2.schemaRules(schema2)));
2581
2581
  }
2582
- }
2582
+ };
2583
2583
  const blockTags = {
2584
2584
  address: true,
2585
2585
  article: true,
@@ -6023,7 +6023,7 @@ class EditorState {
6023
6023
  let instance2 = new EditorState($config);
6024
6024
  $config.fields.forEach((field) => {
6025
6025
  if (field.name == "doc") {
6026
- instance2.doc = Node.fromJSON(config.schema, json.doc);
6026
+ instance2.doc = Node$1.fromJSON(config.schema, json.doc);
6027
6027
  } else if (field.name == "selection") {
6028
6028
  instance2.selection = Selection.fromJSON(instance2.doc, json.selection);
6029
6029
  } else if (field.name == "storedMarks") {
@@ -9285,7 +9285,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
9285
9285
  dom = child;
9286
9286
  }
9287
9287
  if (!slice2) {
9288
- let parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
9288
+ let parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser$1.fromSchema(view.state.schema);
9289
9289
  slice2 = parser.parseSlice(dom, {
9290
9290
  preserveWhitespace: !!(asText || sliceData),
9291
9291
  context: $context,
@@ -11157,7 +11157,7 @@ function parseBetween(view, from_, to_) {
11157
11157
  }
11158
11158
  }
11159
11159
  let startDoc = view.state.doc;
11160
- let parser = view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
11160
+ let parser = view.someProp("domParser") || DOMParser$1.fromSchema(view.state.schema);
11161
11161
  let $from = startDoc.resolve(from2);
11162
11162
  let sel = null, doc2 = parser.parse(parent, {
11163
11163
  topNode: $from.parent,
@@ -12649,7 +12649,7 @@ function elementFromString(value) {
12649
12649
  return removeWhitespaces(html);
12650
12650
  }
12651
12651
  function createNodeFromContent(content, schema2, options2) {
12652
- if (content instanceof Node || content instanceof Fragment) {
12652
+ if (content instanceof Node$1 || content instanceof Fragment) {
12653
12653
  return content;
12654
12654
  }
12655
12655
  options2 = {
@@ -12705,9 +12705,9 @@ function createNodeFromContent(content, schema2, options2) {
12705
12705
  })
12706
12706
  });
12707
12707
  if (options2.slice) {
12708
- DOMParser.fromSchema(contentCheckSchema).parseSlice(elementFromString(content), options2.parseOptions);
12708
+ DOMParser$1.fromSchema(contentCheckSchema).parseSlice(elementFromString(content), options2.parseOptions);
12709
12709
  } else {
12710
- DOMParser.fromSchema(contentCheckSchema).parse(elementFromString(content), options2.parseOptions);
12710
+ DOMParser$1.fromSchema(contentCheckSchema).parse(elementFromString(content), options2.parseOptions);
12711
12711
  }
12712
12712
  if (options2.errorOnInvalidContent && hasInvalidContent) {
12713
12713
  throw new Error("[tiptap error]: Invalid HTML content", {
@@ -12715,7 +12715,7 @@ function createNodeFromContent(content, schema2, options2) {
12715
12715
  });
12716
12716
  }
12717
12717
  }
12718
- const parser = DOMParser.fromSchema(schema2);
12718
+ const parser = DOMParser$1.fromSchema(schema2);
12719
12719
  if (options2.slice) {
12720
12720
  return parser.parseSlice(elementFromString(content), options2.parseOptions).content;
12721
12721
  }
@@ -23280,7 +23280,7 @@ var Mention = Node3.create({
23280
23280
  if (!empty2) {
23281
23281
  return false;
23282
23282
  }
23283
- let mentionNode = new Node();
23283
+ let mentionNode = new Node$1();
23284
23284
  let mentionPos = 0;
23285
23285
  state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
23286
23286
  if (node.type.name === this.name) {
@@ -26861,6 +26861,76 @@ const _sfc_main$2q = /* @__PURE__ */ Object.assign({ name: "ElsTiptapEditor" },
26861
26861
  getPlainText: () => getPlainTextWithMentions(),
26862
26862
  getMentions: () => currentMentions.value
26863
26863
  });
26864
+ const INLINE_TAG_MAP = {
26865
+ div: "span",
26866
+ p: "span"
26867
+ };
26868
+ const htmlNodeToSpec = (node) => {
26869
+ if (node.nodeType === Node.TEXT_NODE) return node.textContent || "";
26870
+ if (node.nodeType !== Node.ELEMENT_NODE) return "";
26871
+ const tag = INLINE_TAG_MAP[node.tagName.toLowerCase()] || node.tagName.toLowerCase();
26872
+ const attrs = {};
26873
+ Array.from(node.attributes).forEach((attr) => {
26874
+ const name2 = attr.name.toLowerCase();
26875
+ const value = attr.value;
26876
+ if (name2.startsWith("on")) return;
26877
+ if ((name2 === "src" || name2 === "href") && /^javascript:/i.test(value.trim())) return;
26878
+ attrs[attr.name] = value;
26879
+ });
26880
+ return [
26881
+ tag,
26882
+ attrs,
26883
+ ...Array.from(node.childNodes).map(htmlNodeToSpec).filter((child) => child !== "")
26884
+ ];
26885
+ };
26886
+ const htmlStringToMentionSpec = (html, HTMLAttributes) => {
26887
+ if (typeof window === "undefined" || typeof DOMParser === "undefined") {
26888
+ return [
26889
+ "span",
26890
+ { ...HTMLAttributes, contenteditable: "false" },
26891
+ html
26892
+ ];
26893
+ }
26894
+ const doc2 = new DOMParser().parseFromString(html, "text/html");
26895
+ const children = Array.from(doc2.body.childNodes).map(htmlNodeToSpec).filter((child) => child !== "");
26896
+ return [
26897
+ "span",
26898
+ { ...HTMLAttributes, contenteditable: "false" },
26899
+ ...children
26900
+ ];
26901
+ };
26902
+ const sanitizeHtmlElement = (element) => {
26903
+ Array.from(element.attributes).forEach((attr) => {
26904
+ const name2 = attr.name.toLowerCase();
26905
+ const value = attr.value;
26906
+ if (name2.startsWith("on")) {
26907
+ element.removeAttribute(attr.name);
26908
+ return;
26909
+ }
26910
+ if ((name2 === "src" || name2 === "href") && /^javascript:/i.test(value.trim())) {
26911
+ element.removeAttribute(attr.name);
26912
+ }
26913
+ });
26914
+ Array.from(element.children).forEach(sanitizeHtmlElement);
26915
+ };
26916
+ const appendHtmlString = (container, html) => {
26917
+ if (typeof window === "undefined" || typeof DOMParser === "undefined") {
26918
+ container.textContent = html;
26919
+ return;
26920
+ }
26921
+ const doc2 = new DOMParser().parseFromString(html, "text/html");
26922
+ Array.from(doc2.body.children).forEach(sanitizeHtmlElement);
26923
+ container.append(...Array.from(doc2.body.childNodes));
26924
+ };
26925
+ const appendRenderOptionContent = (container, option) => {
26926
+ const result = props2.renderOption ? props2.renderOption(option) : option[props2.labelField];
26927
+ const content = result && typeof result === "object" && "html" in result ? result.html : result;
26928
+ if (typeof content === "string") {
26929
+ appendHtmlString(container, content);
26930
+ return;
26931
+ }
26932
+ container.textContent = String(content ?? "");
26933
+ };
26864
26934
  const CustomMention = index_default.extend({
26865
26935
  draggable: true,
26866
26936
  addOptions() {
@@ -26884,7 +26954,9 @@ const _sfc_main$2q = /* @__PURE__ */ Object.assign({ name: "ElsTiptapEditor" },
26884
26954
  try {
26885
26955
  const result = renderMention(mentionData);
26886
26956
  if (result) {
26957
+ if (typeof result === "string") return htmlStringToMentionSpec(result, HTMLAttributes);
26887
26958
  if (Array.isArray(result)) return result;
26959
+ if (result.html && typeof result.html === "string") return htmlStringToMentionSpec(result.html, HTMLAttributes);
26888
26960
  if (result.html && Array.isArray(result.html)) return result.html;
26889
26961
  }
26890
26962
  } catch (error) {
@@ -27143,7 +27215,7 @@ const _sfc_main$2q = /* @__PURE__ */ Object.assign({ name: "ElsTiptapEditor" },
27143
27215
  div2.appendChild(badge);
27144
27216
  }
27145
27217
  const labelSpan = document.createElement("span");
27146
- labelSpan.textContent = props2.renderOption ? props2.renderOption(item) : item[props2.labelField];
27218
+ appendRenderOptionContent(labelSpan, item);
27147
27219
  div2.appendChild(labelSpan);
27148
27220
  if (item.type === "container") {
27149
27221
  const drillArrow = document.createElement("span");
@@ -27247,7 +27319,7 @@ const _sfc_main$2q = /* @__PURE__ */ Object.assign({ name: "ElsTiptapEditor" },
27247
27319
  };
27248
27320
  }
27249
27321
  });
27250
- const TipTapEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$2q, [["__scopeId", "data-v-7bfd3d3b"]]);
27322
+ const TipTapEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$2q, [["__scopeId", "data-v-329f0d4d"]]);
27251
27323
  const { saveAs } = pkg;
27252
27324
  function _toConsumableArray(e) {
27253
27325
  if (Array.isArray(e)) {
@@ -40010,6 +40082,7 @@ const _sfc_main$1Z = /* @__PURE__ */ defineComponent({
40010
40082
  let currSpanMethod;
40011
40083
  let currSummaryMethod;
40012
40084
  let currSortChange;
40085
+ let rowSortableInstance = null;
40013
40086
  let columnEditData = reactive([]);
40014
40087
  let columnSortData = reactive({});
40015
40088
  let columnMergeData = reactive([]);
@@ -40024,6 +40097,7 @@ const _sfc_main$1Z = /* @__PURE__ */ defineComponent({
40024
40097
  let mobilePageLayout = "total, prev, next, jumper";
40025
40098
  const bottomScroll = ref();
40026
40099
  const dataTable = ref();
40100
+ const tableRenderKey = ref(0);
40027
40101
  const tableForm = ref();
40028
40102
  const tableGlobalData = ref({
40029
40103
  isEdit: props2.isEdit
@@ -40198,13 +40272,15 @@ const _sfc_main$1Z = /* @__PURE__ */ defineComponent({
40198
40272
  group: props2.tagId,
40199
40273
  animation: 300,
40200
40274
  onAdd: (evt) => {
40201
- if (props2.dragCol.onAdd) {
40202
- props2.dragCol.onAdd(evt);
40275
+ const dragColOptions = props2.dragCol;
40276
+ if (dragColOptions == null ? void 0 : dragColOptions.onAdd) {
40277
+ dragColOptions.onAdd(evt);
40203
40278
  }
40204
40279
  },
40205
40280
  onEnd: (evt) => {
40206
- if (props2.dragCol.onEnd) {
40207
- props2.dragCol.onEnd(evt);
40281
+ const dragColOptions = props2.dragCol;
40282
+ if (dragColOptions == null ? void 0 : dragColOptions.onEnd) {
40283
+ dragColOptions.onEnd(evt);
40208
40284
  } else {
40209
40285
  const { oldIndex, newIndex } = evt;
40210
40286
  const [movedColumn] = tableColumns.value.splice(oldIndex, 1);
@@ -40217,33 +40293,276 @@ const _sfc_main$1Z = /* @__PURE__ */ defineComponent({
40217
40293
  }
40218
40294
  }
40219
40295
  function setRowDragSortable() {
40220
- if (props2.dragRow) {
40221
- new Sortable(dataTable.value.$el.querySelector(".el-table__body-wrapper tbody"), {
40222
- handle: ".els-table-drag",
40223
- draggable: ".el-table__row",
40224
- // 允许拖拽的项目类名
40225
- // 拖拽中 回调函数
40226
- onMove(customEvent) {
40296
+ if (!props2.dragRow) return;
40297
+ if (rowSortableInstance) {
40298
+ rowSortableInstance.destroy();
40299
+ rowSortableInstance = null;
40300
+ }
40301
+ const parentKeyMap = /* @__PURE__ */ new Map();
40302
+ const rowDataMap = /* @__PURE__ */ new Map();
40303
+ const getRowKey = (row) => String(row[dataKey.value]);
40304
+ const buildMaps = () => {
40305
+ parentKeyMap.clear();
40306
+ rowDataMap.clear();
40307
+ if (!dataKey.value) return;
40308
+ const traverse = (rows, parentKey) => {
40309
+ rows.forEach((row) => {
40310
+ var _a;
40311
+ const key = getRowKey(row);
40312
+ rowDataMap.set(key, row);
40313
+ if (parentKey !== void 0) parentKeyMap.set(key, parentKey);
40314
+ if ((_a = row.children) == null ? void 0 : _a.length) traverse(row.children, key);
40315
+ });
40316
+ };
40317
+ traverse(tableData);
40318
+ };
40319
+ buildMaps();
40320
+ const tbody = dataTable.value.$el.querySelector(".el-table__body-wrapper tbody");
40321
+ let hiddenRows = [];
40322
+ let rowDragStarted = false;
40323
+ const resetRowDragTable = () => {
40324
+ tableRenderKey.value++;
40325
+ nextTick(() => setRowDragSortable());
40326
+ };
40327
+ const getRowLevel = (tr2) => {
40328
+ var _a;
40329
+ const levelClass = Array.from(tr2.classList).find((className) => className.includes("el-table__row--level-"));
40330
+ const level = (_a = levelClass == null ? void 0 : levelClass.match(/el-table__row--level-(\d+)/)) == null ? void 0 : _a[1];
40331
+ return level ? Number(level) : 0;
40332
+ };
40333
+ const syncDomRowKeys = () => {
40334
+ if (!dataKey.value) return;
40335
+ const rows = Array.from(tbody.querySelectorAll("tr.el-table__row"));
40336
+ const levelRows = [];
40337
+ const levelChildIndex = [];
40338
+ let rootIndex = 0;
40339
+ rows.forEach((tr2) => {
40340
+ var _a;
40341
+ const level = getRowLevel(tr2);
40342
+ let row;
40343
+ if (level === 0) {
40344
+ row = tableData[rootIndex];
40345
+ rootIndex++;
40346
+ } else {
40347
+ const parent = levelRows[level - 1];
40348
+ const childIndex = levelChildIndex[level] ?? 0;
40349
+ row = (_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a[childIndex];
40350
+ levelChildIndex[level] = childIndex + 1;
40351
+ }
40352
+ if (row) {
40353
+ tr2.dataset.rowKey = getRowKey(row);
40354
+ levelRows[level] = row;
40355
+ levelChildIndex[level + 1] = 0;
40356
+ }
40357
+ });
40358
+ rowDragLog("sync-dom-row-keys", {
40359
+ domKeys: rows.map((tr2) => tr2.dataset.rowKey),
40360
+ rootDataKeys: getRootDataKeys()
40361
+ });
40362
+ };
40363
+ const getDomRowKeys = () => Array.from(tbody.querySelectorAll("tr.el-table__row")).map((tr2) => tr2.dataset.rowKey);
40364
+ const getRootDataKeys = () => tableData.map((row) => dataKey.value ? getRowKey(row) : "");
40365
+ const rowDragLog = (step, data = {}) => {
40366
+ console.log("[ElsTable row-drag]", step, data);
40367
+ };
40368
+ const isDescendantOf = (key, parentKey) => {
40369
+ let currParentKey = parentKeyMap.get(key);
40370
+ while (currParentKey !== void 0) {
40371
+ if (currParentKey === parentKey) return true;
40372
+ currParentKey = parentKeyMap.get(currParentKey);
40373
+ }
40374
+ return false;
40375
+ };
40376
+ const hideDescendantRows = (rowKey) => {
40377
+ clearHiddenRows();
40378
+ const rows = Array.from(tbody.querySelectorAll("tr.el-table__row"));
40379
+ hiddenRows = rows.filter((tr2) => {
40380
+ const key = tr2.dataset.rowKey;
40381
+ return key && isDescendantOf(key, rowKey);
40382
+ });
40383
+ hiddenRows.forEach((tr2) => {
40384
+ tr2.style.display = "none";
40385
+ });
40386
+ rowDragLog("hide-descendants", {
40387
+ rowKey,
40388
+ hiddenKeys: hiddenRows.map((tr2) => tr2.dataset.rowKey),
40389
+ domKeys: getDomRowKeys(),
40390
+ parentKeyMap: Array.from(parentKeyMap.entries())
40391
+ });
40392
+ };
40393
+ const clearHiddenRows = () => {
40394
+ const restoreKeys = hiddenRows.map((tr2) => tr2.dataset.rowKey);
40395
+ hiddenRows.forEach((tr2) => {
40396
+ tr2.style.display = "";
40397
+ });
40398
+ hiddenRows = [];
40399
+ if (restoreKeys.length) rowDragLog("restore-hidden-rows", { restoreKeys });
40400
+ };
40401
+ rowSortableInstance = new Sortable(tbody, {
40402
+ handle: ".els-table-drag",
40403
+ draggable: ".el-table__row",
40404
+ animation: 150,
40405
+ onChoose(dragEvent) {
40406
+ var _a, _b, _c;
40407
+ rowDragStarted = false;
40408
+ syncDomRowKeys();
40409
+ if (!dataKey.value) {
40410
+ rowDragLog("choose-no-row-key", { domKeys: getDomRowKeys() });
40411
+ return;
40412
+ }
40413
+ buildMaps();
40414
+ const draggedKey = dragEvent.item.dataset.rowKey;
40415
+ const row = draggedKey ? rowDataMap.get(draggedKey) : void 0;
40416
+ rowDragLog("choose", {
40417
+ draggedKey,
40418
+ hasRow: !!row,
40419
+ hasChildren: !!((_a = row == null ? void 0 : row.children) == null ? void 0 : _a.length),
40420
+ childrenKeys: (_b = row == null ? void 0 : row.children) == null ? void 0 : _b.map((child) => getRowKey(child)),
40421
+ rootDataKeys: getRootDataKeys(),
40422
+ domKeys: getDomRowKeys(),
40423
+ parentKeyMap: Array.from(parentKeyMap.entries())
40424
+ });
40425
+ if (!draggedKey) return;
40426
+ if (!((_c = row == null ? void 0 : row.children) == null ? void 0 : _c.length)) return;
40427
+ hideDescendantRows(draggedKey);
40428
+ },
40429
+ onUnchoose() {
40430
+ rowDragLog("unchoose", { rowDragStarted, domKeys: getDomRowKeys(), rootDataKeys: getRootDataKeys() });
40431
+ if (!rowDragStarted) clearHiddenRows();
40432
+ },
40433
+ onStart() {
40434
+ rowDragStarted = true;
40435
+ rowDragLog("start", { domKeys: getDomRowKeys(), rootDataKeys: getRootDataKeys() });
40436
+ },
40437
+ onMove(customEvent) {
40438
+ var _a, _b;
40439
+ if (!dataKey.value) {
40227
40440
  emits2("dragMove", customEvent);
40228
- },
40229
- onStart() {
40230
- },
40231
- // 拖拽结束,调整位置
40232
- onEnd(dragEvent) {
40233
- const newIndex = dragEvent.newIndex;
40234
- const oldIndex = dragEvent.oldIndex;
40235
- if (newIndex !== void 0 && oldIndex !== void 0) {
40236
- if (oldIndex > -1 && newIndex > -1) {
40237
- const startRow = tableData[oldIndex];
40238
- const endRow = tableData[newIndex];
40239
- const currRow = tableData.splice(oldIndex, 1)[0];
40240
- tableData.splice(newIndex, 0, currRow);
40241
- emits2("dragEnd", { startRow, endRow });
40441
+ return;
40442
+ }
40443
+ buildMaps();
40444
+ const draggedKey = customEvent.dragged.dataset.rowKey;
40445
+ const relatedKey = (_b = (_a = customEvent.related) == null ? void 0 : _a.dataset) == null ? void 0 : _b.rowKey;
40446
+ rowDragLog("move", {
40447
+ draggedKey,
40448
+ relatedKey,
40449
+ draggedIsChild: draggedKey ? parentKeyMap.has(draggedKey) : void 0,
40450
+ relatedIsChild: relatedKey ? parentKeyMap.has(relatedKey) : void 0,
40451
+ relatedIsDescendantOfDragged: draggedKey && relatedKey ? isDescendantOf(relatedKey, draggedKey) : void 0
40452
+ });
40453
+ if (!draggedKey || !relatedKey) {
40454
+ emits2("dragMove", customEvent);
40455
+ return;
40456
+ }
40457
+ if (isDescendantOf(relatedKey, draggedKey)) {
40458
+ rowDragLog("move-block-descendant", { draggedKey, relatedKey });
40459
+ return false;
40460
+ }
40461
+ emits2("dragMove", customEvent);
40462
+ },
40463
+ onEnd(dragEvent) {
40464
+ rowDragStarted = true;
40465
+ buildMaps();
40466
+ const draggedKey = dragEvent.item.dataset.rowKey;
40467
+ const restoreHiddenRows = () => resetRowDragTable();
40468
+ rowDragLog("end-start", {
40469
+ draggedKey,
40470
+ oldIndex: dragEvent.oldIndex,
40471
+ newIndex: dragEvent.newIndex,
40472
+ oldDraggableIndex: dragEvent.oldDraggableIndex,
40473
+ newDraggableIndex: dragEvent.newDraggableIndex,
40474
+ domKeys: getDomRowKeys(),
40475
+ rootDataKeys: getRootDataKeys(),
40476
+ parentKeyMap: Array.from(parentKeyMap.entries())
40477
+ });
40478
+ if (!draggedKey || !dataKey.value) {
40479
+ const oi = dragEvent.oldDraggableIndex;
40480
+ const ni = dragEvent.newDraggableIndex;
40481
+ if (oi > -1 && ni > -1 && oi !== ni) {
40482
+ const startRow = tableData[oi];
40483
+ const endRow = tableData[ni];
40484
+ tableData.splice(ni, 0, tableData.splice(oi, 1)[0]);
40485
+ emits2("dragEnd", { startRow, endRow });
40486
+ }
40487
+ restoreHiddenRows();
40488
+ return;
40489
+ }
40490
+ const allRows = Array.from(tbody.querySelectorAll("tr[data-row-key]"));
40491
+ const originalParentKey = parentKeyMap.get(draggedKey);
40492
+ if (originalParentKey === void 0) {
40493
+ const rootKeys = allRows.map((tr2) => tr2.dataset.rowKey).filter((k) => !parentKeyMap.has(k));
40494
+ const startRow = rowDataMap.get(draggedKey);
40495
+ const reordered = rootKeys.map((k) => rowDataMap.get(k)).filter(Boolean);
40496
+ rowDragLog("end-root", {
40497
+ draggedKey,
40498
+ rootKeys,
40499
+ reorderedKeys: reordered.map((row) => getRowKey(row)),
40500
+ tableDataLength: tableData.length,
40501
+ canSplice: reordered.length === tableData.length
40502
+ });
40503
+ if (reordered.length === tableData.length) {
40504
+ tableData.splice(0, tableData.length, ...reordered);
40505
+ rowDragLog("end-root-after-splice", { rootDataKeys: getRootDataKeys() });
40506
+ emits2("dragEnd", { startRow, endRow: reordered[rootKeys.indexOf(draggedKey)] });
40507
+ }
40508
+ restoreHiddenRows();
40509
+ return;
40510
+ }
40511
+ const originalParent = rowDataMap.get(originalParentKey);
40512
+ const siblings = originalParent == null ? void 0 : originalParent.children;
40513
+ if (!siblings) {
40514
+ restoreHiddenRows();
40515
+ return;
40516
+ }
40517
+ const sibKeySet = new Set(siblings.map((c) => getRowKey(c)));
40518
+ const parentDomPos = allRows.findIndex((tr2) => tr2.dataset.rowKey === originalParentKey);
40519
+ const consecutiveSibKeys = [];
40520
+ for (let i = parentDomPos + 1; i < allRows.length; i++) {
40521
+ const k = allRows[i].dataset.rowKey;
40522
+ if (!sibKeySet.has(k)) break;
40523
+ consecutiveSibKeys.push(k);
40524
+ }
40525
+ const movedToRoot = !consecutiveSibKeys.includes(draggedKey);
40526
+ rowDragLog("end-child", {
40527
+ draggedKey,
40528
+ originalParentKey,
40529
+ siblingsKeys: Array.from(sibKeySet),
40530
+ parentDomPos,
40531
+ consecutiveSibKeys,
40532
+ movedToRoot,
40533
+ domKeys: allRows.map((tr2) => tr2.dataset.rowKey)
40534
+ });
40535
+ if (!movedToRoot) {
40536
+ const childKeys = allRows.map((tr2) => tr2.dataset.rowKey).filter((k) => sibKeySet.has(k));
40537
+ const startRow = rowDataMap.get(draggedKey);
40538
+ const reordered = childKeys.map((k) => rowDataMap.get(k)).filter(Boolean);
40539
+ if (reordered.length === siblings.length) {
40540
+ siblings.splice(0, siblings.length, ...reordered);
40541
+ emits2("dragEnd", { startRow, endRow: reordered[childKeys.indexOf(draggedKey)] });
40542
+ }
40543
+ } else {
40544
+ const childRow = rowDataMap.get(draggedKey);
40545
+ const draggedDomPos = allRows.findIndex((tr2) => tr2.dataset.rowKey === draggedKey);
40546
+ const childIdx = siblings.findIndex((c) => getRowKey(c) === draggedKey);
40547
+ if (childIdx > -1) {
40548
+ siblings.splice(childIdx, 1);
40549
+ if (siblings.length === 0) originalParent.children = [];
40550
+ }
40551
+ let insertAfterTableIdx = -1;
40552
+ for (let i = draggedDomPos - 1; i >= 0; i--) {
40553
+ const k = allRows[i].dataset.rowKey;
40554
+ if (!parentKeyMap.has(k)) {
40555
+ insertAfterTableIdx = tableData.findIndex((r) => getRowKey(r) === k);
40556
+ break;
40242
40557
  }
40243
40558
  }
40559
+ tableData.splice(insertAfterTableIdx + 1, 0, childRow);
40560
+ buildMaps();
40561
+ emits2("dragEnd", { startRow: childRow, endRow: childRow });
40244
40562
  }
40245
- });
40246
- }
40563
+ restoreHiddenRows();
40564
+ }
40565
+ });
40247
40566
  }
40248
40567
  function setEditData(fields, isEdit) {
40249
40568
  if (!fields) {
@@ -41453,7 +41772,7 @@ const _sfc_main$1Z = /* @__PURE__ */ defineComponent({
41453
41772
  ref: tableForm
41454
41773
  }, {
41455
41774
  default: withCtx(() => [
41456
- withDirectives((openBlock(), createBlock(_component_el_table, mergeProps(unref(attrProps), {
41775
+ withDirectives((openBlock(), createBlock(_component_el_table, mergeProps({ key: tableRenderKey.value }, unref(attrProps), {
41457
41776
  data: tableData,
41458
41777
  "header-sticky-top": unref(currHeaderStickyTop),
41459
41778
  class: [!unref(isMobile) && _ctx.hasBottomFixdScroll ? unref(tagID) + " els-table-noScroll" : unref(tagID), { "els-drag-col": _ctx.dragCol }],
@@ -41651,7 +41970,7 @@ const _sfc_main$1Z = /* @__PURE__ */ defineComponent({
41651
41970
  };
41652
41971
  }
41653
41972
  });
41654
- const Table$1 = /* @__PURE__ */ _export_sfc$1(_sfc_main$1Z, [["__scopeId", "data-v-2628571f"]]);
41973
+ const Table$1 = /* @__PURE__ */ _export_sfc$1(_sfc_main$1Z, [["__scopeId", "data-v-d9cadba2"]]);
41655
41974
  const ElsTable = withInstall$1(Table$1);
41656
41975
  const treeProps = buildProps({
41657
41976
  ...formItemProps$1,
@@ -72877,7 +73196,7 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
72877
73196
  emits: /* @__PURE__ */ mergeModels(["removeItem"], ["update:children"]),
72878
73197
  setup(__props, { emit: __emit }) {
72879
73198
  const DynamicDesignerInnerItem = defineAsyncComponent(() => {
72880
- return import("./innerItem-BLwsIdXS.js");
73199
+ return import("./innerItem-D_eodwMh.js");
72881
73200
  });
72882
73201
  const { getValue: getValue2 } = useProps();
72883
73202
  const tagID = getValue2("tagID");
@@ -73616,7 +73935,8 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
73616
73935
  }
73617
73936
  }
73618
73937
  collect(designerObj.value);
73619
- return result;
73938
+ const seen = /* @__PURE__ */ new Set();
73939
+ return result.filter((f) => !seen.has(f.keyCode) && !!seen.add(f.keyCode));
73620
73940
  });
73621
73941
  function findItemContextDesigner(targetKeyID) {
73622
73942
  function traverse(items) {
@@ -73732,7 +74052,7 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
73732
74052
  };
73733
74053
  }
73734
74054
  });
73735
- const Designer = /* @__PURE__ */ _export_sfc$1(_sfc_main$1k, [["__scopeId", "data-v-abd9a30e"]]);
74055
+ const Designer = /* @__PURE__ */ _export_sfc$1(_sfc_main$1k, [["__scopeId", "data-v-e20fc7da"]]);
73736
74056
  const ElsDynamicDesigner = withInstall$1(Designer);
73737
74057
  const renderProps = buildProps({
73738
74058
  ...formItemProps$1,
@@ -73831,10 +74151,10 @@ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
73831
74151
  emits: ["update:modelValue"],
73832
74152
  setup(__props, { expose: __expose, emit: __emit }) {
73833
74153
  const DynamicRenderInner = defineAsyncComponent(() => {
73834
- return import("./inner-DDu1WQSi.js").then((n) => n.i);
74154
+ return import("./inner-DmSBxfiK.js").then((n) => n.i);
73835
74155
  });
73836
74156
  const DynamicRenderForm = defineAsyncComponent(() => {
73837
- return import("./inner-DDu1WQSi.js").then((n) => n.f);
74157
+ return import("./inner-DmSBxfiK.js").then((n) => n.f);
73838
74158
  });
73839
74159
  const props2 = __props;
73840
74160
  const { getValue: getValue2, setValue, formNodeProps } = useProps(props2);
@@ -74064,10 +74384,10 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
74064
74384
  emits: ["update:modelValue"],
74065
74385
  setup(__props, { expose: __expose, emit: __emit }) {
74066
74386
  const DynamicRenderInnerAsync = defineAsyncComponent(() => {
74067
- return import("./inner-DDu1WQSi.js").then((n) => n.i);
74387
+ return import("./inner-DmSBxfiK.js").then((n) => n.i);
74068
74388
  });
74069
74389
  const DynamicRenderFormAsync = defineAsyncComponent(() => {
74070
- return import("./inner-DDu1WQSi.js").then((n) => n.f);
74390
+ return import("./inner-DmSBxfiK.js").then((n) => n.f);
74071
74391
  });
74072
74392
  const props2 = __props;
74073
74393
  const { getValue: getValue2, setValue, formNodeProps } = useProps(props2);
@@ -77341,7 +77661,8 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
77341
77661
  }
77342
77662
  }
77343
77663
  collect(renderData.value);
77344
- return result;
77664
+ const seen = /* @__PURE__ */ new Set();
77665
+ return result.filter((f) => !seen.has(f.keyCode) && !!seen.add(f.keyCode));
77345
77666
  });
77346
77667
  function findItemContext(targetKeyID) {
77347
77668
  function traverse(items) {
@@ -78456,7 +78777,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
78456
78777
  };
78457
78778
  }
78458
78779
  });
78459
- const DesignerView = /* @__PURE__ */ _export_sfc$1(_sfc_main$u, [["__scopeId", "data-v-27c3a153"]]);
78780
+ const DesignerView = /* @__PURE__ */ _export_sfc$1(_sfc_main$u, [["__scopeId", "data-v-a9af3092"]]);
78460
78781
  const ElsDesignerView = withInstall$1(DesignerView);
78461
78782
  (function(Prism2) {
78462
78783
  var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
@@ -79195,31 +79516,31 @@ let AceEditor$1 = class AceEditor extends TBaseFormItem {
79195
79516
  __publicField(this, "editor", ref());
79196
79517
  onMounted(() => {
79197
79518
  if (props2.language === "json") {
79198
- const currModule = import("./mode-json-CMZrLYva.js").then((n) => n.m);
79519
+ const currModule = import("./mode-json-CmVf14v7.js").then((n) => n.m);
79199
79520
  currModule.then((res) => {
79200
79521
  ace.config.setModuleUrl("ace/mode/json", res);
79201
79522
  this.init();
79202
79523
  });
79203
79524
  } else if (props2.language === "javascript") {
79204
- const currModule = import("./mode-javascript-UYl8TiHR.js").then((n) => n.m);
79525
+ const currModule = import("./mode-javascript-CgNYP0ZB.js").then((n) => n.m);
79205
79526
  currModule.then((res) => {
79206
79527
  ace.config.setModuleUrl("ace/mode/javascript", res);
79207
79528
  this.init();
79208
79529
  });
79209
79530
  } else if (props2.language === "csharp") {
79210
- const currModule = import("./mode-csharp-BENJof50.js").then((n) => n.m);
79531
+ const currModule = import("./mode-csharp-DXxph2IU.js").then((n) => n.m);
79211
79532
  currModule.then((res) => {
79212
79533
  ace.config.setModuleUrl("ace/mode/csharp", res);
79213
79534
  this.init();
79214
79535
  });
79215
79536
  } else if (props2.language === "mysql") {
79216
- const currModule = import("./mode-mysql-CyyRKgQ3.js").then((n) => n.m);
79537
+ const currModule = import("./mode-mysql-CQl5Sngg.js").then((n) => n.m);
79217
79538
  currModule.then((res) => {
79218
79539
  ace.config.setModuleUrl("ace/mode/mysql", res);
79219
79540
  this.init();
79220
79541
  });
79221
79542
  } else if (props2.language === "css") {
79222
- const currModule = import("./mode-css-BJJAjdkv.js").then((n) => n.m);
79543
+ const currModule = import("./mode-css-DNuBwejm.js").then((n) => n.m);
79223
79544
  currModule.then((res) => {
79224
79545
  ace.config.setModuleUrl("ace/mode/css", res);
79225
79546
  this.init();