@bagelink/vue 0.0.1292 → 0.0.1296
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/components/form/inputs/NumberInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/composables/useEditor.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/media.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/table.d.ts.map +1 -1
- package/dist/index.cjs +56 -34
- package/dist/index.mjs +56 -34
- package/dist/style.css +20 -20
- package/package.json +1 -1
- package/src/components/form/inputs/NumberInput.vue +1 -0
- package/src/components/form/inputs/RichText/composables/useEditor.ts +18 -35
- package/src/components/form/inputs/RichText/index.vue +0 -6
- package/src/components/form/inputs/RichText/utils/media.ts +3 -0
- package/src/components/form/inputs/RichText/utils/table.ts +52 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/NumberInput.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NumberInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/NumberInput.vue"],"names":[],"mappings":"AAuOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAI7C,KAAK,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAA;AAEzD,UAAU,gBAAgB;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,QAAQ,CAAA;IACpB,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;;;;;;AA6VD,wBAQG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useEditor.ts"],"names":[],"mappings":"AAmCA,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eALR,UAAU;;;;;;;;;;;;qDAlBI,CAAC;;+CAG9B,CAAD;;;;2CAGC,CAAC;;;
|
|
1
|
+
{"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useEditor.ts"],"names":[],"mappings":"AAmCA,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eALR,UAAU;;;;;;;;;;;;qDAlBI,CAAC;;+CAG9B,CAAD;;;;2CAGC,CAAC;;;gBAkSiB,QAAQ;;;0BAhOR,MAAM,GAAG,MAAM;;;;;;;;;EAuTlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/inputs/RichText/index.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/inputs/RichText/index.vue"],"names":[],"mappings":"AAgSA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAQpD,KAAK,WAAW,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;;;;;;;;AA2V1G,wBASG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QAyClE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QAoBjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,QA2DlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/utils/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,QAoBzE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAoBrD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAuBpD;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,QAkB/E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAerC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,QAevC;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,QAsBtE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,QAyBxC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,QAsB3F"}
|
package/dist/index.cjs
CHANGED
|
@@ -17420,6 +17420,7 @@ const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
|
|
|
17420
17420
|
readonly: _ctx.disabled,
|
|
17421
17421
|
inputmode: "decimal",
|
|
17422
17422
|
autocomplete: "off",
|
|
17423
|
+
pattern: "^-?\\d*\\.?\\d*$",
|
|
17423
17424
|
autocorrect: "off",
|
|
17424
17425
|
spellcheck: "false",
|
|
17425
17426
|
onInput: inputHandler,
|
|
@@ -17485,7 +17486,7 @@ const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
|
|
|
17485
17486
|
};
|
|
17486
17487
|
}
|
|
17487
17488
|
});
|
|
17488
|
-
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$H, [["__scopeId", "data-v-
|
|
17489
|
+
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$H, [["__scopeId", "data-v-8f9331b5"]]);
|
|
17489
17490
|
const _hoisted_1$z = ["value", "autofocus", "onKeydown", "onPaste"];
|
|
17490
17491
|
const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
|
|
17491
17492
|
__name: "OTP",
|
|
@@ -18469,6 +18470,7 @@ function insertImage(modal, state2) {
|
|
|
18469
18470
|
})() : img;
|
|
18470
18471
|
range2.collapse(false);
|
|
18471
18472
|
range2.insertNode(node);
|
|
18473
|
+
state2.content = doc.body.innerHTML;
|
|
18472
18474
|
}
|
|
18473
18475
|
}
|
|
18474
18476
|
});
|
|
@@ -18488,6 +18490,7 @@ function insertLink(modal, state2) {
|
|
|
18488
18490
|
anchor.href = data2.url;
|
|
18489
18491
|
if (data2.openInNewTab) anchor.target = "_blank";
|
|
18490
18492
|
range2.surroundContents(anchor);
|
|
18493
|
+
state2.content = doc.body.innerHTML;
|
|
18491
18494
|
}
|
|
18492
18495
|
}
|
|
18493
18496
|
});
|
|
@@ -18535,6 +18538,7 @@ function insertEmbed(modal, state2) {
|
|
|
18535
18538
|
wrapper.appendChild(iframe);
|
|
18536
18539
|
range2.deleteContents();
|
|
18537
18540
|
range2.insertNode(wrapper);
|
|
18541
|
+
state2.content = doc.body.innerHTML;
|
|
18538
18542
|
}
|
|
18539
18543
|
});
|
|
18540
18544
|
}
|
|
@@ -18556,6 +18560,7 @@ function insertTable(rows, cols, state2) {
|
|
|
18556
18560
|
} else {
|
|
18557
18561
|
state2.doc.body.appendChild(table);
|
|
18558
18562
|
}
|
|
18563
|
+
state2.content = state2.doc.body.innerHTML;
|
|
18559
18564
|
}
|
|
18560
18565
|
function mergeCells(range2, doc) {
|
|
18561
18566
|
var _a;
|
|
@@ -18569,6 +18574,10 @@ function mergeCells(range2, doc) {
|
|
|
18569
18574
|
const actualCell = doc.getElementById(cell.id);
|
|
18570
18575
|
actualCell == null ? void 0 : actualCell.remove();
|
|
18571
18576
|
});
|
|
18577
|
+
const state2 = doc.editorState;
|
|
18578
|
+
if (state2) {
|
|
18579
|
+
state2.content = doc.body.innerHTML;
|
|
18580
|
+
}
|
|
18572
18581
|
}
|
|
18573
18582
|
function splitCell(range2, doc) {
|
|
18574
18583
|
var _a;
|
|
@@ -18586,6 +18595,10 @@ function splitCell(range2, doc) {
|
|
|
18586
18595
|
newCells.slice(1).forEach((newCell) => {
|
|
18587
18596
|
newCells[0].insertAdjacentElement("afterend", newCell);
|
|
18588
18597
|
});
|
|
18598
|
+
const state2 = doc.editorState;
|
|
18599
|
+
if (state2) {
|
|
18600
|
+
state2.content = doc.body.innerHTML;
|
|
18601
|
+
}
|
|
18589
18602
|
}
|
|
18590
18603
|
function addRow(position, range2, doc) {
|
|
18591
18604
|
var _a;
|
|
@@ -18597,6 +18610,10 @@ function addRow(position, range2, doc) {
|
|
|
18597
18610
|
const newRow = row.cloneNode(true);
|
|
18598
18611
|
Array.from(newRow.cells).forEach((cell2) => cell2.innerHTML = " ");
|
|
18599
18612
|
row.insertAdjacentElement(position === "before" ? "beforebegin" : "afterend", newRow);
|
|
18613
|
+
const state2 = doc.editorState;
|
|
18614
|
+
if (state2) {
|
|
18615
|
+
state2.content = doc.body.innerHTML;
|
|
18616
|
+
}
|
|
18600
18617
|
}
|
|
18601
18618
|
function deleteRow(range2) {
|
|
18602
18619
|
var _a;
|
|
@@ -18604,7 +18621,12 @@ function deleteRow(range2) {
|
|
|
18604
18621
|
if (!cell) return;
|
|
18605
18622
|
const row = cell.parentElement;
|
|
18606
18623
|
if (!row) return;
|
|
18624
|
+
const doc = row.ownerDocument;
|
|
18607
18625
|
row.remove();
|
|
18626
|
+
const state2 = doc.editorState;
|
|
18627
|
+
if (state2) {
|
|
18628
|
+
state2.content = doc.body.innerHTML;
|
|
18629
|
+
}
|
|
18608
18630
|
}
|
|
18609
18631
|
function deleteTable(range2) {
|
|
18610
18632
|
var _a;
|
|
@@ -18612,7 +18634,12 @@ function deleteTable(range2) {
|
|
|
18612
18634
|
if (!cell) return;
|
|
18613
18635
|
const table = cell.closest("table");
|
|
18614
18636
|
if (!table) return;
|
|
18637
|
+
const doc = table.ownerDocument;
|
|
18615
18638
|
table.remove();
|
|
18639
|
+
const state2 = doc.editorState;
|
|
18640
|
+
if (state2) {
|
|
18641
|
+
state2.content = doc.body.innerHTML;
|
|
18642
|
+
}
|
|
18616
18643
|
}
|
|
18617
18644
|
function insertColumn(position, range2) {
|
|
18618
18645
|
var _a;
|
|
@@ -18628,6 +18655,10 @@ function insertColumn(position, range2) {
|
|
|
18628
18655
|
newCell.style.border = "1px solid var(--border-color)";
|
|
18629
18656
|
newCell.style.padding = "8px";
|
|
18630
18657
|
}
|
|
18658
|
+
const state2 = table.ownerDocument.editorState;
|
|
18659
|
+
if (state2) {
|
|
18660
|
+
state2.content = table.ownerDocument.body.innerHTML;
|
|
18661
|
+
}
|
|
18631
18662
|
}
|
|
18632
18663
|
function deleteColumn(range2) {
|
|
18633
18664
|
var _a;
|
|
@@ -18637,12 +18668,17 @@ function deleteColumn(range2) {
|
|
|
18637
18668
|
if (!table) return;
|
|
18638
18669
|
const columnIndex = cell.cellIndex;
|
|
18639
18670
|
const { rows } = table;
|
|
18671
|
+
const doc = table.ownerDocument;
|
|
18640
18672
|
for (let i2 = 0; i2 < rows.length; i2++) {
|
|
18641
18673
|
rows[i2].deleteCell(columnIndex);
|
|
18642
18674
|
}
|
|
18643
18675
|
if (rows[0].cells.length === 0) {
|
|
18644
18676
|
table.remove();
|
|
18645
18677
|
}
|
|
18678
|
+
const state2 = doc.editorState;
|
|
18679
|
+
if (state2) {
|
|
18680
|
+
state2.content = doc.body.innerHTML;
|
|
18681
|
+
}
|
|
18646
18682
|
}
|
|
18647
18683
|
function alignColumn(range2, alignment) {
|
|
18648
18684
|
var _a;
|
|
@@ -18658,6 +18694,10 @@ function alignColumn(range2, alignment) {
|
|
|
18658
18694
|
cell2.style.textAlign = alignment;
|
|
18659
18695
|
}
|
|
18660
18696
|
}
|
|
18697
|
+
const state2 = table.ownerDocument.editorState;
|
|
18698
|
+
if (state2) {
|
|
18699
|
+
state2.content = table.ownerDocument.body.innerHTML;
|
|
18700
|
+
}
|
|
18661
18701
|
}
|
|
18662
18702
|
function createCommand(name, execute, isActive) {
|
|
18663
18703
|
return {
|
|
@@ -19223,42 +19263,31 @@ function useEditor() {
|
|
|
19223
19263
|
cleanupListeners = null;
|
|
19224
19264
|
}
|
|
19225
19265
|
let isUpdating = false;
|
|
19226
|
-
let contentUpdateTimeout = null;
|
|
19227
|
-
let selectionUpdateTimeout = null;
|
|
19228
19266
|
const events = {
|
|
19229
19267
|
input: () => {
|
|
19230
19268
|
if (isUpdating) return;
|
|
19231
19269
|
isUpdating = true;
|
|
19232
|
-
|
|
19233
|
-
|
|
19270
|
+
const newContent = doc.body.innerHTML;
|
|
19271
|
+
if (newContent !== state2.content) {
|
|
19272
|
+
state2.content = newContent;
|
|
19234
19273
|
}
|
|
19235
|
-
|
|
19236
|
-
const newContent = doc.body.innerHTML;
|
|
19237
|
-
if (newContent !== state2.content) {
|
|
19238
|
-
state2.content = newContent;
|
|
19239
|
-
}
|
|
19240
|
-
isUpdating = false;
|
|
19241
|
-
}, 100);
|
|
19274
|
+
isUpdating = false;
|
|
19242
19275
|
},
|
|
19243
19276
|
selectionchange: () => {
|
|
19244
|
-
if (isUpdating)
|
|
19245
|
-
|
|
19246
|
-
window.clearTimeout(selectionUpdateTimeout);
|
|
19277
|
+
if (!isUpdating) {
|
|
19278
|
+
updateState.selection();
|
|
19247
19279
|
}
|
|
19248
|
-
selectionUpdateTimeout = window.setTimeout(() => {
|
|
19249
|
-
if (!isUpdating) {
|
|
19250
|
-
updateState.selection();
|
|
19251
|
-
}
|
|
19252
|
-
}, 150);
|
|
19253
19280
|
},
|
|
19254
19281
|
mouseup: () => {
|
|
19255
|
-
if (isUpdating)
|
|
19256
|
-
|
|
19282
|
+
if (!isUpdating) {
|
|
19283
|
+
updateState.selection();
|
|
19284
|
+
}
|
|
19257
19285
|
},
|
|
19258
19286
|
keyup: (e) => {
|
|
19259
|
-
if (isUpdating)
|
|
19260
|
-
|
|
19261
|
-
|
|
19287
|
+
if (!isUpdating) {
|
|
19288
|
+
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
19289
|
+
updateState.selection();
|
|
19290
|
+
}
|
|
19262
19291
|
}
|
|
19263
19292
|
}
|
|
19264
19293
|
};
|
|
@@ -19266,8 +19295,6 @@ function useEditor() {
|
|
|
19266
19295
|
doc.addEventListener(event, handler);
|
|
19267
19296
|
});
|
|
19268
19297
|
cleanupListeners = () => {
|
|
19269
|
-
if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout);
|
|
19270
|
-
if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout);
|
|
19271
19298
|
Object.entries(events).forEach(([event, handler]) => {
|
|
19272
19299
|
doc.removeEventListener(event, handler);
|
|
19273
19300
|
});
|
|
@@ -19283,6 +19310,7 @@ function useEditor() {
|
|
|
19283
19310
|
}
|
|
19284
19311
|
state2.doc = doc;
|
|
19285
19312
|
state2.hasInit = true;
|
|
19313
|
+
doc.editorState = state2;
|
|
19286
19314
|
if (state2.content) {
|
|
19287
19315
|
const preserved = preserveIframes(state2.content);
|
|
19288
19316
|
doc.body.innerHTML = preserved.html;
|
|
@@ -19555,12 +19583,6 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
19555
19583
|
}
|
|
19556
19584
|
emit2("update:modelValue", newValue);
|
|
19557
19585
|
});
|
|
19558
|
-
vue.watch(() => editor.state.isSplitView, (isEnabled) => {
|
|
19559
|
-
var _a;
|
|
19560
|
-
if (isEnabled) {
|
|
19561
|
-
editor.state.content = ((_a = editor.state.doc) == null ? void 0 : _a.body.innerHTML) || "";
|
|
19562
|
-
}
|
|
19563
|
-
});
|
|
19564
19586
|
return (_ctx, _cache) => {
|
|
19565
19587
|
var _a, _b;
|
|
19566
19588
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
|
|
@@ -19644,7 +19666,7 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
19644
19666
|
};
|
|
19645
19667
|
}
|
|
19646
19668
|
});
|
|
19647
|
-
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-
|
|
19669
|
+
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-30bcda4c"]]);
|
|
19648
19670
|
const _hoisted_1$r = { class: "flex gap-05" };
|
|
19649
19671
|
const _hoisted_2$h = ["disabled"];
|
|
19650
19672
|
const _hoisted_3$d = { key: 1 };
|
package/dist/index.mjs
CHANGED
|
@@ -17418,6 +17418,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
17418
17418
|
readonly: _ctx.disabled,
|
|
17419
17419
|
inputmode: "decimal",
|
|
17420
17420
|
autocomplete: "off",
|
|
17421
|
+
pattern: "^-?\\d*\\.?\\d*$",
|
|
17421
17422
|
autocorrect: "off",
|
|
17422
17423
|
spellcheck: "false",
|
|
17423
17424
|
onInput: inputHandler,
|
|
@@ -17483,7 +17484,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
17483
17484
|
};
|
|
17484
17485
|
}
|
|
17485
17486
|
});
|
|
17486
|
-
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$H, [["__scopeId", "data-v-
|
|
17487
|
+
const NumberInput = /* @__PURE__ */ _export_sfc(_sfc_main$H, [["__scopeId", "data-v-8f9331b5"]]);
|
|
17487
17488
|
const _hoisted_1$z = ["value", "autofocus", "onKeydown", "onPaste"];
|
|
17488
17489
|
const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
17489
17490
|
__name: "OTP",
|
|
@@ -18467,6 +18468,7 @@ function insertImage(modal, state2) {
|
|
|
18467
18468
|
})() : img;
|
|
18468
18469
|
range2.collapse(false);
|
|
18469
18470
|
range2.insertNode(node);
|
|
18471
|
+
state2.content = doc.body.innerHTML;
|
|
18470
18472
|
}
|
|
18471
18473
|
}
|
|
18472
18474
|
});
|
|
@@ -18486,6 +18488,7 @@ function insertLink(modal, state2) {
|
|
|
18486
18488
|
anchor.href = data2.url;
|
|
18487
18489
|
if (data2.openInNewTab) anchor.target = "_blank";
|
|
18488
18490
|
range2.surroundContents(anchor);
|
|
18491
|
+
state2.content = doc.body.innerHTML;
|
|
18489
18492
|
}
|
|
18490
18493
|
}
|
|
18491
18494
|
});
|
|
@@ -18533,6 +18536,7 @@ function insertEmbed(modal, state2) {
|
|
|
18533
18536
|
wrapper.appendChild(iframe);
|
|
18534
18537
|
range2.deleteContents();
|
|
18535
18538
|
range2.insertNode(wrapper);
|
|
18539
|
+
state2.content = doc.body.innerHTML;
|
|
18536
18540
|
}
|
|
18537
18541
|
});
|
|
18538
18542
|
}
|
|
@@ -18554,6 +18558,7 @@ function insertTable(rows, cols, state2) {
|
|
|
18554
18558
|
} else {
|
|
18555
18559
|
state2.doc.body.appendChild(table);
|
|
18556
18560
|
}
|
|
18561
|
+
state2.content = state2.doc.body.innerHTML;
|
|
18557
18562
|
}
|
|
18558
18563
|
function mergeCells(range2, doc) {
|
|
18559
18564
|
var _a;
|
|
@@ -18567,6 +18572,10 @@ function mergeCells(range2, doc) {
|
|
|
18567
18572
|
const actualCell = doc.getElementById(cell.id);
|
|
18568
18573
|
actualCell == null ? void 0 : actualCell.remove();
|
|
18569
18574
|
});
|
|
18575
|
+
const state2 = doc.editorState;
|
|
18576
|
+
if (state2) {
|
|
18577
|
+
state2.content = doc.body.innerHTML;
|
|
18578
|
+
}
|
|
18570
18579
|
}
|
|
18571
18580
|
function splitCell(range2, doc) {
|
|
18572
18581
|
var _a;
|
|
@@ -18584,6 +18593,10 @@ function splitCell(range2, doc) {
|
|
|
18584
18593
|
newCells.slice(1).forEach((newCell) => {
|
|
18585
18594
|
newCells[0].insertAdjacentElement("afterend", newCell);
|
|
18586
18595
|
});
|
|
18596
|
+
const state2 = doc.editorState;
|
|
18597
|
+
if (state2) {
|
|
18598
|
+
state2.content = doc.body.innerHTML;
|
|
18599
|
+
}
|
|
18587
18600
|
}
|
|
18588
18601
|
function addRow(position, range2, doc) {
|
|
18589
18602
|
var _a;
|
|
@@ -18595,6 +18608,10 @@ function addRow(position, range2, doc) {
|
|
|
18595
18608
|
const newRow = row.cloneNode(true);
|
|
18596
18609
|
Array.from(newRow.cells).forEach((cell2) => cell2.innerHTML = " ");
|
|
18597
18610
|
row.insertAdjacentElement(position === "before" ? "beforebegin" : "afterend", newRow);
|
|
18611
|
+
const state2 = doc.editorState;
|
|
18612
|
+
if (state2) {
|
|
18613
|
+
state2.content = doc.body.innerHTML;
|
|
18614
|
+
}
|
|
18598
18615
|
}
|
|
18599
18616
|
function deleteRow(range2) {
|
|
18600
18617
|
var _a;
|
|
@@ -18602,7 +18619,12 @@ function deleteRow(range2) {
|
|
|
18602
18619
|
if (!cell) return;
|
|
18603
18620
|
const row = cell.parentElement;
|
|
18604
18621
|
if (!row) return;
|
|
18622
|
+
const doc = row.ownerDocument;
|
|
18605
18623
|
row.remove();
|
|
18624
|
+
const state2 = doc.editorState;
|
|
18625
|
+
if (state2) {
|
|
18626
|
+
state2.content = doc.body.innerHTML;
|
|
18627
|
+
}
|
|
18606
18628
|
}
|
|
18607
18629
|
function deleteTable(range2) {
|
|
18608
18630
|
var _a;
|
|
@@ -18610,7 +18632,12 @@ function deleteTable(range2) {
|
|
|
18610
18632
|
if (!cell) return;
|
|
18611
18633
|
const table = cell.closest("table");
|
|
18612
18634
|
if (!table) return;
|
|
18635
|
+
const doc = table.ownerDocument;
|
|
18613
18636
|
table.remove();
|
|
18637
|
+
const state2 = doc.editorState;
|
|
18638
|
+
if (state2) {
|
|
18639
|
+
state2.content = doc.body.innerHTML;
|
|
18640
|
+
}
|
|
18614
18641
|
}
|
|
18615
18642
|
function insertColumn(position, range2) {
|
|
18616
18643
|
var _a;
|
|
@@ -18626,6 +18653,10 @@ function insertColumn(position, range2) {
|
|
|
18626
18653
|
newCell.style.border = "1px solid var(--border-color)";
|
|
18627
18654
|
newCell.style.padding = "8px";
|
|
18628
18655
|
}
|
|
18656
|
+
const state2 = table.ownerDocument.editorState;
|
|
18657
|
+
if (state2) {
|
|
18658
|
+
state2.content = table.ownerDocument.body.innerHTML;
|
|
18659
|
+
}
|
|
18629
18660
|
}
|
|
18630
18661
|
function deleteColumn(range2) {
|
|
18631
18662
|
var _a;
|
|
@@ -18635,12 +18666,17 @@ function deleteColumn(range2) {
|
|
|
18635
18666
|
if (!table) return;
|
|
18636
18667
|
const columnIndex = cell.cellIndex;
|
|
18637
18668
|
const { rows } = table;
|
|
18669
|
+
const doc = table.ownerDocument;
|
|
18638
18670
|
for (let i2 = 0; i2 < rows.length; i2++) {
|
|
18639
18671
|
rows[i2].deleteCell(columnIndex);
|
|
18640
18672
|
}
|
|
18641
18673
|
if (rows[0].cells.length === 0) {
|
|
18642
18674
|
table.remove();
|
|
18643
18675
|
}
|
|
18676
|
+
const state2 = doc.editorState;
|
|
18677
|
+
if (state2) {
|
|
18678
|
+
state2.content = doc.body.innerHTML;
|
|
18679
|
+
}
|
|
18644
18680
|
}
|
|
18645
18681
|
function alignColumn(range2, alignment) {
|
|
18646
18682
|
var _a;
|
|
@@ -18656,6 +18692,10 @@ function alignColumn(range2, alignment) {
|
|
|
18656
18692
|
cell2.style.textAlign = alignment;
|
|
18657
18693
|
}
|
|
18658
18694
|
}
|
|
18695
|
+
const state2 = table.ownerDocument.editorState;
|
|
18696
|
+
if (state2) {
|
|
18697
|
+
state2.content = table.ownerDocument.body.innerHTML;
|
|
18698
|
+
}
|
|
18659
18699
|
}
|
|
18660
18700
|
function createCommand(name, execute, isActive) {
|
|
18661
18701
|
return {
|
|
@@ -19221,42 +19261,31 @@ function useEditor() {
|
|
|
19221
19261
|
cleanupListeners = null;
|
|
19222
19262
|
}
|
|
19223
19263
|
let isUpdating = false;
|
|
19224
|
-
let contentUpdateTimeout = null;
|
|
19225
|
-
let selectionUpdateTimeout = null;
|
|
19226
19264
|
const events = {
|
|
19227
19265
|
input: () => {
|
|
19228
19266
|
if (isUpdating) return;
|
|
19229
19267
|
isUpdating = true;
|
|
19230
|
-
|
|
19231
|
-
|
|
19268
|
+
const newContent = doc.body.innerHTML;
|
|
19269
|
+
if (newContent !== state2.content) {
|
|
19270
|
+
state2.content = newContent;
|
|
19232
19271
|
}
|
|
19233
|
-
|
|
19234
|
-
const newContent = doc.body.innerHTML;
|
|
19235
|
-
if (newContent !== state2.content) {
|
|
19236
|
-
state2.content = newContent;
|
|
19237
|
-
}
|
|
19238
|
-
isUpdating = false;
|
|
19239
|
-
}, 100);
|
|
19272
|
+
isUpdating = false;
|
|
19240
19273
|
},
|
|
19241
19274
|
selectionchange: () => {
|
|
19242
|
-
if (isUpdating)
|
|
19243
|
-
|
|
19244
|
-
window.clearTimeout(selectionUpdateTimeout);
|
|
19275
|
+
if (!isUpdating) {
|
|
19276
|
+
updateState.selection();
|
|
19245
19277
|
}
|
|
19246
|
-
selectionUpdateTimeout = window.setTimeout(() => {
|
|
19247
|
-
if (!isUpdating) {
|
|
19248
|
-
updateState.selection();
|
|
19249
|
-
}
|
|
19250
|
-
}, 150);
|
|
19251
19278
|
},
|
|
19252
19279
|
mouseup: () => {
|
|
19253
|
-
if (isUpdating)
|
|
19254
|
-
|
|
19280
|
+
if (!isUpdating) {
|
|
19281
|
+
updateState.selection();
|
|
19282
|
+
}
|
|
19255
19283
|
},
|
|
19256
19284
|
keyup: (e) => {
|
|
19257
|
-
if (isUpdating)
|
|
19258
|
-
|
|
19259
|
-
|
|
19285
|
+
if (!isUpdating) {
|
|
19286
|
+
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
19287
|
+
updateState.selection();
|
|
19288
|
+
}
|
|
19260
19289
|
}
|
|
19261
19290
|
}
|
|
19262
19291
|
};
|
|
@@ -19264,8 +19293,6 @@ function useEditor() {
|
|
|
19264
19293
|
doc.addEventListener(event, handler);
|
|
19265
19294
|
});
|
|
19266
19295
|
cleanupListeners = () => {
|
|
19267
|
-
if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout);
|
|
19268
|
-
if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout);
|
|
19269
19296
|
Object.entries(events).forEach(([event, handler]) => {
|
|
19270
19297
|
doc.removeEventListener(event, handler);
|
|
19271
19298
|
});
|
|
@@ -19281,6 +19308,7 @@ function useEditor() {
|
|
|
19281
19308
|
}
|
|
19282
19309
|
state2.doc = doc;
|
|
19283
19310
|
state2.hasInit = true;
|
|
19311
|
+
doc.editorState = state2;
|
|
19284
19312
|
if (state2.content) {
|
|
19285
19313
|
const preserved = preserveIframes(state2.content);
|
|
19286
19314
|
doc.body.innerHTML = preserved.html;
|
|
@@ -19553,12 +19581,6 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
19553
19581
|
}
|
|
19554
19582
|
emit2("update:modelValue", newValue);
|
|
19555
19583
|
});
|
|
19556
|
-
watch(() => editor.state.isSplitView, (isEnabled) => {
|
|
19557
|
-
var _a;
|
|
19558
|
-
if (isEnabled) {
|
|
19559
|
-
editor.state.content = ((_a = editor.state.doc) == null ? void 0 : _a.body.innerHTML) || "";
|
|
19560
|
-
}
|
|
19561
|
-
});
|
|
19562
19584
|
return (_ctx, _cache) => {
|
|
19563
19585
|
var _a, _b;
|
|
19564
19586
|
return openBlock(), createElementBlock("div", _hoisted_1$s, [
|
|
@@ -19642,7 +19664,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
19642
19664
|
};
|
|
19643
19665
|
}
|
|
19644
19666
|
});
|
|
19645
|
-
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-
|
|
19667
|
+
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-30bcda4c"]]);
|
|
19646
19668
|
const _hoisted_1$r = { class: "flex gap-05" };
|
|
19647
19669
|
const _hoisted_2$h = ["disabled"];
|
|
19648
19670
|
const _hoisted_3$d = { key: 1 };
|
package/dist/style.css
CHANGED
|
@@ -1847,14 +1847,14 @@ pre code.hljs{
|
|
|
1847
1847
|
direction: ltr;
|
|
1848
1848
|
}
|
|
1849
1849
|
|
|
1850
|
-
.txtInputIconStart .iconStart[data-v-
|
|
1850
|
+
.txtInputIconStart .iconStart[data-v-8f9331b5] {
|
|
1851
1851
|
color: var(--input-color);
|
|
1852
1852
|
position: absolute;
|
|
1853
1853
|
inset-inline-start:calc(var(--input-height) / 3 - 0.25rem);
|
|
1854
1854
|
margin-top: calc(var(--input-height) / 2 );
|
|
1855
1855
|
line-height: 0;
|
|
1856
1856
|
}
|
|
1857
|
-
.textInputSpinnerWrap .spinner[data-v-
|
|
1857
|
+
.textInputSpinnerWrap .spinner[data-v-8f9331b5] {
|
|
1858
1858
|
color: var(--input-color);
|
|
1859
1859
|
position: absolute;
|
|
1860
1860
|
inset-inline-end: 0;
|
|
@@ -1864,18 +1864,18 @@ pre code.hljs{
|
|
|
1864
1864
|
flex-direction: column;
|
|
1865
1865
|
gap: 0;
|
|
1866
1866
|
}
|
|
1867
|
-
.top-bgl-ctrl-num-btn[data-v-
|
|
1867
|
+
.top-bgl-ctrl-num-btn[data-v-8f9331b5]{
|
|
1868
1868
|
margin-top: calc(var(--input-height) / 10) !important;
|
|
1869
1869
|
}
|
|
1870
|
-
.bgl-ctrl-num-btn[data-v-
|
|
1870
|
+
.bgl-ctrl-num-btn[data-v-8f9331b5]{
|
|
1871
1871
|
height: calc(var(--input-height) / 2.5) !important;
|
|
1872
1872
|
isolation: isolate;
|
|
1873
1873
|
}
|
|
1874
|
-
.bgl-big-ctrl-num-btn[data-v-
|
|
1874
|
+
.bgl-big-ctrl-num-btn[data-v-8f9331b5]{
|
|
1875
1875
|
width: 100% !important;
|
|
1876
1876
|
isolation: isolate;
|
|
1877
1877
|
}
|
|
1878
|
-
.bgl-number-input[data-v-
|
|
1878
|
+
.bgl-number-input[data-v-8f9331b5]{
|
|
1879
1879
|
padding-inline-end: 1.75rem !important;
|
|
1880
1880
|
}
|
|
1881
1881
|
|
|
@@ -2064,26 +2064,26 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
|
|
|
2064
2064
|
height: 100%;
|
|
2065
2065
|
}
|
|
2066
2066
|
|
|
2067
|
-
.rich-text-editor[data-v-
|
|
2067
|
+
.rich-text-editor[data-v-30bcda4c] {
|
|
2068
2068
|
background: var(--input-bg);
|
|
2069
2069
|
border: 1px solid var(--border-color);
|
|
2070
2070
|
transition: all 0.3s ease;
|
|
2071
2071
|
}
|
|
2072
|
-
.editor-container[data-v-
|
|
2072
|
+
.editor-container[data-v-30bcda4c] {
|
|
2073
2073
|
display: flex;
|
|
2074
2074
|
gap: 1rem;
|
|
2075
2075
|
}
|
|
2076
|
-
.content-area[data-v-
|
|
2077
|
-
.preview-area[data-v-
|
|
2076
|
+
.content-area[data-v-30bcda4c],
|
|
2077
|
+
.preview-area[data-v-30bcda4c] {
|
|
2078
2078
|
flex: 1;
|
|
2079
2079
|
min-height: 200px;
|
|
2080
2080
|
background: var(--bgl-richtext-color);
|
|
2081
2081
|
}
|
|
2082
|
-
.split-view[data-v-
|
|
2082
|
+
.split-view[data-v-30bcda4c] {
|
|
2083
2083
|
display: grid;
|
|
2084
2084
|
grid-template-columns: 1fr 1fr;
|
|
2085
2085
|
}
|
|
2086
|
-
.editableContent[data-v-
|
|
2086
|
+
.editableContent[data-v-30bcda4c] {
|
|
2087
2087
|
width: 100%;
|
|
2088
2088
|
min-height: 240px;
|
|
2089
2089
|
height: 100%;
|
|
@@ -2091,7 +2091,7 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
|
|
|
2091
2091
|
outline: none;
|
|
2092
2092
|
background: transparent;
|
|
2093
2093
|
}
|
|
2094
|
-
.html-editor[data-v-
|
|
2094
|
+
.html-editor[data-v-30bcda4c] {
|
|
2095
2095
|
width: 100%;
|
|
2096
2096
|
height: 100%;
|
|
2097
2097
|
min-height: 200px;
|
|
@@ -2102,12 +2102,12 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
|
|
|
2102
2102
|
color: white;
|
|
2103
2103
|
background-color: var(--bgl-black);
|
|
2104
2104
|
}
|
|
2105
|
-
.preview-area[data-v-
|
|
2105
|
+
.preview-area[data-v-30bcda4c] {
|
|
2106
2106
|
font-family: monospace;
|
|
2107
2107
|
white-space: pre-wrap;
|
|
2108
2108
|
overflow-x: auto;
|
|
2109
2109
|
}
|
|
2110
|
-
.fullscreen-mode[data-v-
|
|
2110
|
+
.fullscreen-mode[data-v-30bcda4c] {
|
|
2111
2111
|
position: fixed;
|
|
2112
2112
|
top: 0;
|
|
2113
2113
|
left: 0;
|
|
@@ -2116,18 +2116,18 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
|
|
|
2116
2116
|
z-index: 9999;
|
|
2117
2117
|
padding: 2rem;
|
|
2118
2118
|
}
|
|
2119
|
-
.fullscreen-mode .editor-container[data-v-
|
|
2119
|
+
.fullscreen-mode .editor-container[data-v-30bcda4c] {
|
|
2120
2120
|
height: calc(100vh - 4rem);
|
|
2121
2121
|
}
|
|
2122
|
-
.fullscreen-mode .content-area[data-v-
|
|
2123
|
-
.fullscreen-mode .preview-area[data-v-
|
|
2122
|
+
.fullscreen-mode .content-area[data-v-30bcda4c],
|
|
2123
|
+
.fullscreen-mode .preview-area[data-v-30bcda4c] {
|
|
2124
2124
|
height: 100%;
|
|
2125
2125
|
overflow-y: auto;
|
|
2126
2126
|
}
|
|
2127
|
-
.fullscreen-mode .code-editor[data-v-
|
|
2127
|
+
.fullscreen-mode .code-editor[data-v-30bcda4c]{
|
|
2128
2128
|
height: 100% !important;
|
|
2129
2129
|
}
|
|
2130
|
-
.debug-controls[data-v-
|
|
2130
|
+
.debug-controls[data-v-30bcda4c] {
|
|
2131
2131
|
display: flex;
|
|
2132
2132
|
gap: 0.5rem;
|
|
2133
2133
|
justify-content: flex-end;
|
package/package.json
CHANGED
|
@@ -258,53 +258,35 @@ export function useEditor() {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
let isUpdating = false
|
|
261
|
-
let contentUpdateTimeout: number | null = null
|
|
262
|
-
let selectionUpdateTimeout: number | null = null
|
|
263
|
-
let updateCount = 0
|
|
264
261
|
|
|
265
262
|
const events = {
|
|
266
263
|
input: () => {
|
|
267
|
-
updateCount++
|
|
268
264
|
if (isUpdating) return
|
|
269
265
|
isUpdating = true
|
|
270
266
|
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
|
|
267
|
+
// Immediately update content
|
|
268
|
+
const newContent = doc.body.innerHTML
|
|
269
|
+
if (newContent !== state.content) {
|
|
270
|
+
state.content = newContent
|
|
274
271
|
}
|
|
275
272
|
|
|
276
|
-
|
|
277
|
-
const newContent = doc.body.innerHTML
|
|
278
|
-
if (newContent !== state.content) {
|
|
279
|
-
state.content = newContent
|
|
280
|
-
}
|
|
281
|
-
isUpdating = false
|
|
282
|
-
}, 100)
|
|
273
|
+
isUpdating = false
|
|
283
274
|
},
|
|
284
275
|
selectionchange: () => {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (selectionUpdateTimeout) {
|
|
289
|
-
window.clearTimeout(selectionUpdateTimeout)
|
|
276
|
+
if (!isUpdating) {
|
|
277
|
+
updateState.selection()
|
|
290
278
|
}
|
|
291
|
-
|
|
292
|
-
selectionUpdateTimeout = window.setTimeout(() => {
|
|
293
|
-
if (!isUpdating) {
|
|
294
|
-
updateState.selection()
|
|
295
|
-
}
|
|
296
|
-
}, 150)
|
|
297
279
|
},
|
|
298
280
|
mouseup: () => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
281
|
+
if (!isUpdating) {
|
|
282
|
+
updateState.selection()
|
|
283
|
+
}
|
|
302
284
|
},
|
|
303
285
|
keyup: (e: KeyboardEvent) => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
286
|
+
if (!isUpdating) {
|
|
287
|
+
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
|
|
288
|
+
updateState.selection()
|
|
289
|
+
}
|
|
308
290
|
}
|
|
309
291
|
}
|
|
310
292
|
}
|
|
@@ -316,8 +298,6 @@ export function useEditor() {
|
|
|
316
298
|
|
|
317
299
|
// Store cleanup function
|
|
318
300
|
cleanupListeners = () => {
|
|
319
|
-
if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout)
|
|
320
|
-
if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout)
|
|
321
301
|
Object.entries(events).forEach(([event, handler]) => {
|
|
322
302
|
doc.removeEventListener(event, handler as EventListener)
|
|
323
303
|
})
|
|
@@ -335,7 +315,10 @@ export function useEditor() {
|
|
|
335
315
|
}
|
|
336
316
|
|
|
337
317
|
state.doc = doc
|
|
338
|
-
state.hasInit = true
|
|
318
|
+
state.hasInit = true as const
|
|
319
|
+
|
|
320
|
+
// Store state reference in document for table operations
|
|
321
|
+
(doc as any).editorState = state
|
|
339
322
|
|
|
340
323
|
// Initial setup without triggering updates
|
|
341
324
|
if (state.content) {
|
|
@@ -142,12 +142,6 @@ watch(() => editor.state.content, (newValue) => {
|
|
|
142
142
|
}
|
|
143
143
|
emit('update:modelValue', newValue)
|
|
144
144
|
})
|
|
145
|
-
|
|
146
|
-
watch(() => editor.state.isSplitView, (isEnabled) => {
|
|
147
|
-
if (isEnabled) {
|
|
148
|
-
editor.state.content = editor.state.doc?.body.innerHTML || ''
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
145
|
</script>
|
|
152
146
|
|
|
153
147
|
<template>
|
|
@@ -41,6 +41,7 @@ export function insertImage(modal: typeof Modal, state: EditorState) {
|
|
|
41
41
|
|
|
42
42
|
range.collapse(false)
|
|
43
43
|
range.insertNode(node)
|
|
44
|
+
state.content = doc.body.innerHTML
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
})
|
|
@@ -62,6 +63,7 @@ export function insertLink(modal: typeof Modal, state: EditorState) {
|
|
|
62
63
|
anchor.href = data.url
|
|
63
64
|
if (data.openInNewTab) anchor.target = '_blank'
|
|
64
65
|
range.surroundContents(anchor)
|
|
66
|
+
state.content = doc.body.innerHTML
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
})
|
|
@@ -123,6 +125,7 @@ export function insertEmbed(modal: typeof Modal, state: EditorState) {
|
|
|
123
125
|
|
|
124
126
|
range.deleteContents()
|
|
125
127
|
range.insertNode(wrapper)
|
|
128
|
+
state.content = doc.body.innerHTML
|
|
126
129
|
}
|
|
127
130
|
})
|
|
128
131
|
}
|
|
@@ -19,6 +19,7 @@ export function insertTable(rows: number, cols: number, state: EditorState) {
|
|
|
19
19
|
} else {
|
|
20
20
|
state.doc.body.appendChild(table)
|
|
21
21
|
}
|
|
22
|
+
state.content = state.doc.body.innerHTML
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function mergeCells(range: Range, doc: Document) {
|
|
@@ -35,6 +36,12 @@ export function mergeCells(range: Range, doc: Document) {
|
|
|
35
36
|
const actualCell = doc.getElementById(cell.id)
|
|
36
37
|
actualCell?.remove()
|
|
37
38
|
})
|
|
39
|
+
|
|
40
|
+
// Update state content
|
|
41
|
+
const state = (doc as any).editorState as EditorState
|
|
42
|
+
if (state) {
|
|
43
|
+
state.content = doc.body.innerHTML
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
export function splitCell(range: Range, doc: Document) {
|
|
@@ -54,6 +61,12 @@ export function splitCell(range: Range, doc: Document) {
|
|
|
54
61
|
newCells.slice(1).forEach((newCell) => {
|
|
55
62
|
newCells[0].insertAdjacentElement('afterend', newCell)
|
|
56
63
|
})
|
|
64
|
+
|
|
65
|
+
// Update state content
|
|
66
|
+
const state = (doc as any).editorState as EditorState
|
|
67
|
+
if (state) {
|
|
68
|
+
state.content = doc.body.innerHTML
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
export function addRow(position: 'before' | 'after', range: Range, doc: Document) {
|
|
@@ -68,6 +81,12 @@ export function addRow(position: 'before' | 'after', range: Range, doc: Document
|
|
|
68
81
|
Array.from(newRow.cells).forEach(cell => cell.innerHTML = ' ')
|
|
69
82
|
|
|
70
83
|
row.insertAdjacentElement(position === 'before' ? 'beforebegin' : 'afterend', newRow)
|
|
84
|
+
|
|
85
|
+
// Update state content
|
|
86
|
+
const state = (doc as any).editorState as EditorState
|
|
87
|
+
if (state) {
|
|
88
|
+
state.content = doc.body.innerHTML
|
|
89
|
+
}
|
|
71
90
|
}
|
|
72
91
|
|
|
73
92
|
export function deleteRow(range: Range) {
|
|
@@ -77,7 +96,14 @@ export function deleteRow(range: Range) {
|
|
|
77
96
|
const row = cell.parentElement
|
|
78
97
|
if (!row) return
|
|
79
98
|
|
|
99
|
+
const doc = row.ownerDocument
|
|
80
100
|
row.remove()
|
|
101
|
+
|
|
102
|
+
// Update state content
|
|
103
|
+
const state = (doc as any).editorState as EditorState
|
|
104
|
+
if (state) {
|
|
105
|
+
state.content = doc.body.innerHTML
|
|
106
|
+
}
|
|
81
107
|
}
|
|
82
108
|
|
|
83
109
|
export function deleteTable(range: Range) {
|
|
@@ -87,7 +113,14 @@ export function deleteTable(range: Range) {
|
|
|
87
113
|
const table = cell.closest('table')
|
|
88
114
|
if (!table) return
|
|
89
115
|
|
|
116
|
+
const doc = table.ownerDocument
|
|
90
117
|
table.remove()
|
|
118
|
+
|
|
119
|
+
// Update state content
|
|
120
|
+
const state = (doc as any).editorState as EditorState
|
|
121
|
+
if (state) {
|
|
122
|
+
state.content = doc.body.innerHTML
|
|
123
|
+
}
|
|
91
124
|
}
|
|
92
125
|
|
|
93
126
|
export function insertColumn(position: 'before' | 'after', range: Range) {
|
|
@@ -106,6 +139,12 @@ export function insertColumn(position: 'before' | 'after', range: Range) {
|
|
|
106
139
|
newCell.style.border = '1px solid var(--border-color)'
|
|
107
140
|
newCell.style.padding = '8px'
|
|
108
141
|
}
|
|
142
|
+
|
|
143
|
+
// Update state content
|
|
144
|
+
const state = (table.ownerDocument as any).editorState as EditorState
|
|
145
|
+
if (state) {
|
|
146
|
+
state.content = table.ownerDocument.body.innerHTML
|
|
147
|
+
}
|
|
109
148
|
}
|
|
110
149
|
|
|
111
150
|
export function deleteColumn(range: Range) {
|
|
@@ -117,6 +156,7 @@ export function deleteColumn(range: Range) {
|
|
|
117
156
|
|
|
118
157
|
const columnIndex = cell.cellIndex
|
|
119
158
|
const { rows } = table
|
|
159
|
+
const doc = table.ownerDocument
|
|
120
160
|
|
|
121
161
|
for (let i = 0; i < rows.length; i++) {
|
|
122
162
|
rows[i].deleteCell(columnIndex)
|
|
@@ -126,6 +166,12 @@ export function deleteColumn(range: Range) {
|
|
|
126
166
|
if (rows[0].cells.length === 0) {
|
|
127
167
|
table.remove()
|
|
128
168
|
}
|
|
169
|
+
|
|
170
|
+
// Update state content
|
|
171
|
+
const state = (doc as any).editorState as EditorState
|
|
172
|
+
if (state) {
|
|
173
|
+
state.content = doc.body.innerHTML
|
|
174
|
+
}
|
|
129
175
|
}
|
|
130
176
|
|
|
131
177
|
export function alignColumn(range: Range, alignment: 'left' | 'center' | 'right' | 'justify') {
|
|
@@ -144,4 +190,10 @@ export function alignColumn(range: Range, alignment: 'left' | 'center' | 'right'
|
|
|
144
190
|
cell.style.textAlign = alignment
|
|
145
191
|
}
|
|
146
192
|
}
|
|
193
|
+
|
|
194
|
+
// Update state content
|
|
195
|
+
const state = (table.ownerDocument as any).editorState as EditorState
|
|
196
|
+
if (state) {
|
|
197
|
+
state.content = table.ownerDocument.body.innerHTML
|
|
198
|
+
}
|
|
147
199
|
}
|