@bagelink/vue 0.0.1272 → 0.0.1276
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/FileUpload.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/composables/useCommands.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/index.cjs +15 -79
- package/dist/index.mjs +15 -79
- package/dist/style.css +56 -50
- package/package.json +1 -1
- package/src/components/form/inputs/FileUpload.vue +2 -1
- package/src/components/form/inputs/RichText/composables/useCommands.ts +0 -12
- package/src/components/form/inputs/RichText/composables/useEditor.ts +2 -51
- package/src/components/form/inputs/RichText/index.vue +18 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUpload.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/FileUpload.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileUpload.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/FileUpload.vue"],"names":[],"mappings":"AAstBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAYhD,KAAK,MAAM,GAAG,MAAM,WAAW,CAAA;AAE/B,KAAK,WAAW,GAAG;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;CACvB,CAAC;AAmKF,iBAAS,MAAM,SAkBd;AA8BD,KAAK,iBAAiB,GAAG;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CAChC,GAAG,WAAW,CAAC;AAKhB,iBAAS,cAAc;WAslBT,OAAO,IAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BArxBvC,MAAM;4BACJ,OAAO;uBACZ,MAAM;2BACF,OAAO;;YAuwBS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;0BA1wBpB,MAAM;4BACJ,OAAO;uBACZ,MAAM;2BACF,OAAO;;;YAwwBgB,GAAG;;;;EAerC;AA0BD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;6FAWnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCommands.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE;IAAE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE;uBAK5F,MAAM,UAAU,MAAM;;;
|
|
1
|
+
{"version":3,"file":"useCommands.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE;IAAE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE;uBAK5F,MAAM,UAAU,MAAM;;;EAkD1C"}
|
|
@@ -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;;;gBAsTiB,QAAQ;;;0BApPR,MAAM,GAAG,MAAM;;;;;;;;;EAwUlC"}
|
|
@@ -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":"AAsSA,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;;;;;;;;AAiW1G,wBASG"}
|
package/dist/index.cjs
CHANGED
|
@@ -25804,7 +25804,7 @@ const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
|
|
|
25804
25804
|
};
|
|
25805
25805
|
}
|
|
25806
25806
|
});
|
|
25807
|
-
const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-
|
|
25807
|
+
const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-50fd0597"]]);
|
|
25808
25808
|
const _hoisted_1$B = ["title"];
|
|
25809
25809
|
const _hoisted_2$p = { key: 0 };
|
|
25810
25810
|
const _hoisted_3$k = ["value", "placeholder"];
|
|
@@ -27394,10 +27394,8 @@ function useCommands(state2, debug) {
|
|
|
27394
27394
|
return {
|
|
27395
27395
|
execute: (command, value) => {
|
|
27396
27396
|
if (!state2.doc) return;
|
|
27397
|
-
console.log("[useCommands.execute] Starting command execution:", command, value);
|
|
27398
27397
|
debug == null ? void 0 : debug.logCommand(command, value);
|
|
27399
27398
|
if (["splitView", "codeView", "fullScreen"].includes(command)) {
|
|
27400
|
-
console.log("[useCommands.execute] Handling view state command:", command);
|
|
27401
27399
|
switch (command) {
|
|
27402
27400
|
case "splitView":
|
|
27403
27401
|
state2.isSplitView = !state2.isSplitView;
|
|
@@ -27410,25 +27408,16 @@ function useCommands(state2, debug) {
|
|
|
27410
27408
|
return;
|
|
27411
27409
|
}
|
|
27412
27410
|
}
|
|
27413
|
-
console.log("[useCommands.execute] Focusing editor");
|
|
27414
27411
|
state2.doc.body.focus();
|
|
27415
|
-
console.log("[useCommands.execute] Executing command");
|
|
27416
27412
|
executor.execute(command, value);
|
|
27417
27413
|
const newContent = state2.doc.body.innerHTML;
|
|
27418
|
-
console.log("[useCommands.execute] Checking content changes");
|
|
27419
|
-
console.log("[useCommands.execute] Old content length:", state2.content.length);
|
|
27420
|
-
console.log("[useCommands.execute] New content length:", newContent.length);
|
|
27421
27414
|
if (newContent !== state2.content) {
|
|
27422
|
-
console.log("[useCommands.execute] Content changed, updating state");
|
|
27423
27415
|
state2.content = newContent;
|
|
27424
27416
|
}
|
|
27425
|
-
console.log("[useCommands.execute] Checking selection changes");
|
|
27426
27417
|
const selection = state2.doc.getSelection();
|
|
27427
27418
|
if (selection == null ? void 0 : selection.rangeCount) {
|
|
27428
27419
|
const hasSelectionChanged = !state2.selection || state2.selection !== selection || state2.rangeCount !== selection.rangeCount;
|
|
27429
|
-
console.log("[useCommands.execute] Selection changed:", hasSelectionChanged);
|
|
27430
27420
|
if (hasSelectionChanged) {
|
|
27431
|
-
console.log("[useCommands.execute] Updating selection state");
|
|
27432
27421
|
state2.selection = selection;
|
|
27433
27422
|
state2.range = selection.getRangeAt(0).cloneRange();
|
|
27434
27423
|
state2.rangeCount = selection.rangeCount;
|
|
@@ -27625,7 +27614,6 @@ function useEditor() {
|
|
|
27625
27614
|
const updateState = {
|
|
27626
27615
|
styles: () => {
|
|
27627
27616
|
if (!state2.doc) return;
|
|
27628
|
-
console.log("[updateState.styles] Starting style update");
|
|
27629
27617
|
const styles = /* @__PURE__ */ new Set();
|
|
27630
27618
|
const styleTypes = [
|
|
27631
27619
|
"bold",
|
|
@@ -27648,82 +27636,59 @@ function useEditor() {
|
|
|
27648
27636
|
styles.add(style);
|
|
27649
27637
|
}
|
|
27650
27638
|
});
|
|
27651
|
-
console.log("[updateState.styles] New styles:", Array.from(styles));
|
|
27652
27639
|
state2.selectedStyles = styles;
|
|
27653
27640
|
},
|
|
27654
27641
|
content: (source) => {
|
|
27655
27642
|
if (!state2.doc) return;
|
|
27656
|
-
console.log("[updateState.content] Starting content update, source:", source);
|
|
27657
27643
|
const currentContent = state2.doc.body.innerHTML;
|
|
27658
|
-
console.log("[updateState.content] Current content length:", currentContent.length);
|
|
27659
|
-
console.log("[updateState.content] State content length:", state2.content.length);
|
|
27660
27644
|
if (currentContent !== state2.content) {
|
|
27661
|
-
console.log("[updateState.content] Content changed, pushing to undo stack");
|
|
27662
27645
|
state2.undoStack.push(state2.content);
|
|
27663
27646
|
state2.redoStack = [];
|
|
27664
27647
|
}
|
|
27665
27648
|
const selection = state2.doc.getSelection();
|
|
27666
27649
|
const range2 = (selection == null ? void 0 : selection.rangeCount) ? selection.getRangeAt(0).cloneRange() : null;
|
|
27667
|
-
console.log("[updateState.content] Has selection:", !!selection, "Has range:", !!range2);
|
|
27668
27650
|
if (source === "html") {
|
|
27669
|
-
console.log("[updateState.content] Processing HTML content");
|
|
27670
27651
|
const preserved = preserveIframes(state2.content);
|
|
27671
|
-
console.log("[updateState.content] Preserved iframes count:", preserved.iframes.length);
|
|
27672
27652
|
state2.doc.body.innerHTML = preserved.html;
|
|
27673
27653
|
setTimeout(() => {
|
|
27674
|
-
console.log("[updateState.content] Restoring iframes");
|
|
27675
27654
|
if (state2.doc) {
|
|
27676
27655
|
restoreIframes(state2.doc, state2.content, preserved.iframes);
|
|
27677
27656
|
if (range2 && selection) {
|
|
27678
27657
|
try {
|
|
27679
27658
|
selection.removeAllRanges();
|
|
27680
27659
|
selection.addRange(range2);
|
|
27681
|
-
console.log("[updateState.content] Selection restored");
|
|
27682
27660
|
} catch (e) {
|
|
27683
|
-
console.warn("[updateState.content] Could not restore selection:", e);
|
|
27684
27661
|
}
|
|
27685
27662
|
}
|
|
27686
27663
|
}
|
|
27687
27664
|
}, 0);
|
|
27688
27665
|
} else {
|
|
27689
|
-
console.log("[updateState.content] Setting text content");
|
|
27690
27666
|
state2.doc.body.textContent = state2.content;
|
|
27691
27667
|
}
|
|
27692
27668
|
},
|
|
27693
27669
|
selection: () => {
|
|
27694
27670
|
if (!state2.doc) return;
|
|
27695
|
-
console.log("[updateState.selection] Starting selection update");
|
|
27696
27671
|
const newSelection = state2.doc.getSelection();
|
|
27697
27672
|
if (!newSelection) {
|
|
27698
|
-
console.log("[updateState.selection] No selection available");
|
|
27699
27673
|
return;
|
|
27700
27674
|
}
|
|
27701
27675
|
try {
|
|
27702
27676
|
if (!state2.doc.body.contains(newSelection.anchorNode)) {
|
|
27703
|
-
console.log("[updateState.selection] Selection outside editor body, refocusing");
|
|
27704
27677
|
state2.doc.body.focus();
|
|
27705
27678
|
return;
|
|
27706
27679
|
}
|
|
27707
27680
|
const hasSelectionChanged = !state2.selection || state2.selection !== newSelection || state2.rangeCount !== newSelection.rangeCount || newSelection.rangeCount > 0 && state2.range && (state2.range.startContainer !== newSelection.getRangeAt(0).startContainer || state2.range.startOffset !== newSelection.getRangeAt(0).startOffset || state2.range.endContainer !== newSelection.getRangeAt(0).endContainer || state2.range.endOffset !== newSelection.getRangeAt(0).endOffset);
|
|
27708
|
-
console.log("[updateState.selection] Selection changed:", hasSelectionChanged);
|
|
27709
27681
|
if (hasSelectionChanged) {
|
|
27710
27682
|
state2.selection = newSelection;
|
|
27711
27683
|
state2.rangeCount = newSelection.rangeCount;
|
|
27712
27684
|
if (newSelection.rangeCount > 0) {
|
|
27713
27685
|
state2.range = newSelection.getRangeAt(0).cloneRange();
|
|
27714
|
-
console.log("[updateState.selection] New range:", {
|
|
27715
|
-
startOffset: state2.range.startOffset,
|
|
27716
|
-
endOffset: state2.range.endOffset,
|
|
27717
|
-
collapsed: state2.range.collapsed
|
|
27718
|
-
});
|
|
27719
27686
|
}
|
|
27720
27687
|
requestAnimationFrame(() => {
|
|
27721
|
-
console.log("[updateState.selection] Updating styles in RAF");
|
|
27722
27688
|
updateState.styles();
|
|
27723
27689
|
});
|
|
27724
27690
|
}
|
|
27725
27691
|
} catch (e) {
|
|
27726
|
-
console.warn("[updateState.selection] Selection error:", e);
|
|
27727
27692
|
state2.selection = null;
|
|
27728
27693
|
state2.range = null;
|
|
27729
27694
|
state2.rangeCount = 0;
|
|
@@ -27813,70 +27778,44 @@ function useEditor() {
|
|
|
27813
27778
|
}
|
|
27814
27779
|
};
|
|
27815
27780
|
function setupEventListeners(doc) {
|
|
27816
|
-
console.log("[setupEventListeners] Starting setup");
|
|
27817
27781
|
if (cleanupListeners) {
|
|
27818
|
-
console.log("[setupEventListeners] Cleaning up existing listeners");
|
|
27819
27782
|
cleanupListeners();
|
|
27820
27783
|
cleanupListeners = null;
|
|
27821
27784
|
}
|
|
27822
27785
|
let isUpdating = false;
|
|
27823
27786
|
let contentUpdateTimeout = null;
|
|
27824
27787
|
let selectionUpdateTimeout = null;
|
|
27825
|
-
let updateCount = 0;
|
|
27826
27788
|
const events = {
|
|
27827
27789
|
input: () => {
|
|
27828
|
-
|
|
27829
|
-
console.log(`[input event #${updateCount}] Starting, isUpdating:`, isUpdating);
|
|
27830
|
-
if (isUpdating) {
|
|
27831
|
-
console.log(`[input event #${updateCount}] Skipped - already updating`);
|
|
27832
|
-
return;
|
|
27833
|
-
}
|
|
27790
|
+
if (isUpdating) return;
|
|
27834
27791
|
isUpdating = true;
|
|
27835
27792
|
if (contentUpdateTimeout) {
|
|
27836
|
-
console.log(`[input event #${updateCount}] Clearing previous timeout`);
|
|
27837
27793
|
window.clearTimeout(contentUpdateTimeout);
|
|
27838
27794
|
}
|
|
27839
27795
|
contentUpdateTimeout = window.setTimeout(() => {
|
|
27840
|
-
console.log(`[input event #${updateCount}] Timeout fired`);
|
|
27841
27796
|
const newContent = doc.body.innerHTML;
|
|
27842
27797
|
if (newContent !== state2.content) {
|
|
27843
|
-
console.log(`[input event #${updateCount}] Content changed, updating state`);
|
|
27844
27798
|
state2.content = newContent;
|
|
27845
|
-
} else {
|
|
27846
|
-
console.log(`[input event #${updateCount}] Content unchanged`);
|
|
27847
27799
|
}
|
|
27848
27800
|
isUpdating = false;
|
|
27849
27801
|
}, 100);
|
|
27850
27802
|
},
|
|
27851
27803
|
selectionchange: () => {
|
|
27852
|
-
|
|
27853
|
-
console.log(`[selectionchange #${updateCount}] Starting, isUpdating:`, isUpdating);
|
|
27854
|
-
if (isUpdating) {
|
|
27855
|
-
console.log(`[selectionchange #${updateCount}] Skipped - already updating`);
|
|
27856
|
-
return;
|
|
27857
|
-
}
|
|
27804
|
+
if (isUpdating) return;
|
|
27858
27805
|
if (selectionUpdateTimeout) {
|
|
27859
|
-
console.log(`[selectionchange #${updateCount}] Clearing previous timeout`);
|
|
27860
27806
|
window.clearTimeout(selectionUpdateTimeout);
|
|
27861
27807
|
}
|
|
27862
27808
|
selectionUpdateTimeout = window.setTimeout(() => {
|
|
27863
|
-
console.log(`[selectionchange #${updateCount}] Timeout fired`);
|
|
27864
27809
|
if (!isUpdating) {
|
|
27865
27810
|
updateState.selection();
|
|
27866
|
-
} else {
|
|
27867
|
-
console.log(`[selectionchange #${updateCount}] Skipped - still updating`);
|
|
27868
27811
|
}
|
|
27869
27812
|
}, 150);
|
|
27870
27813
|
},
|
|
27871
27814
|
mouseup: () => {
|
|
27872
|
-
updateCount++;
|
|
27873
|
-
console.log(`[mouseup #${updateCount}] Starting, isUpdating:`, isUpdating);
|
|
27874
27815
|
if (isUpdating) return;
|
|
27875
27816
|
updateState.selection();
|
|
27876
27817
|
},
|
|
27877
27818
|
keyup: (e) => {
|
|
27878
|
-
updateCount++;
|
|
27879
|
-
console.log(`[keyup #${updateCount}] Key:`, e.key, "isUpdating:", isUpdating);
|
|
27880
27819
|
if (isUpdating) return;
|
|
27881
27820
|
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
27882
27821
|
updateState.selection();
|
|
@@ -27885,10 +27824,8 @@ function useEditor() {
|
|
|
27885
27824
|
};
|
|
27886
27825
|
Object.entries(events).forEach(([event, handler]) => {
|
|
27887
27826
|
doc.addEventListener(event, handler);
|
|
27888
|
-
console.log("[setupEventListeners] Added listener for:", event);
|
|
27889
27827
|
});
|
|
27890
27828
|
cleanupListeners = () => {
|
|
27891
|
-
console.log("[setupEventListeners] Cleaning up event listeners");
|
|
27892
27829
|
if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout);
|
|
27893
27830
|
if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout);
|
|
27894
27831
|
Object.entries(events).forEach(([event, handler]) => {
|
|
@@ -27898,9 +27835,7 @@ function useEditor() {
|
|
|
27898
27835
|
return cleanupListeners;
|
|
27899
27836
|
}
|
|
27900
27837
|
function init(doc) {
|
|
27901
|
-
console.log("[init] Starting initialization");
|
|
27902
27838
|
if (state2.hasInit) {
|
|
27903
|
-
console.log("[init] Already initialized, cleaning up first");
|
|
27904
27839
|
if (cleanupListeners) {
|
|
27905
27840
|
cleanupListeners();
|
|
27906
27841
|
cleanupListeners = null;
|
|
@@ -28092,9 +28027,7 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28092
28027
|
});
|
|
28093
28028
|
async function initEditor() {
|
|
28094
28029
|
var _a2;
|
|
28095
|
-
console.log("[initEditor] Starting, isInitializing:", isInitializing.value, "hasInitialized:", hasInitialized.value);
|
|
28096
28030
|
if (isInitializing.value || !iframe.value || hasInitialized.value) {
|
|
28097
|
-
console.log("[initEditor] Skipped - already initializing/initialized or no iframe");
|
|
28098
28031
|
return;
|
|
28099
28032
|
}
|
|
28100
28033
|
isInitializing.value = true;
|
|
@@ -28122,10 +28055,7 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28122
28055
|
</html>
|
|
28123
28056
|
`;
|
|
28124
28057
|
const doc = iframe.value.contentDocument || ((_a2 = iframe.value.contentWindow) == null ? void 0 : _a2.document);
|
|
28125
|
-
if (!doc)
|
|
28126
|
-
console.warn("[initEditor] No document found");
|
|
28127
|
-
return;
|
|
28128
|
-
}
|
|
28058
|
+
if (!doc) return;
|
|
28129
28059
|
doc.open();
|
|
28130
28060
|
doc.write(htmlContent);
|
|
28131
28061
|
doc.close();
|
|
@@ -28164,7 +28094,7 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28164
28094
|
doc.body.focus();
|
|
28165
28095
|
hasInitialized.value = true;
|
|
28166
28096
|
} catch (error) {
|
|
28167
|
-
console.error("
|
|
28097
|
+
console.error("Error during editor initialization:", error);
|
|
28168
28098
|
} finally {
|
|
28169
28099
|
isInitializing.value = false;
|
|
28170
28100
|
}
|
|
@@ -28172,7 +28102,6 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28172
28102
|
vue.watch(() => props2.modelValue, (newValue, oldValue) => {
|
|
28173
28103
|
if (newValue !== editor.state.content) {
|
|
28174
28104
|
if (!oldValue || Math.abs(newValue.length - oldValue.length) > 50) {
|
|
28175
|
-
console.log("[watch] Significant content change, resetting initialization state");
|
|
28176
28105
|
hasInitialized.value = false;
|
|
28177
28106
|
editor.state.content = newValue;
|
|
28178
28107
|
editor.updateState.content("html");
|
|
@@ -28186,6 +28115,12 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28186
28115
|
}
|
|
28187
28116
|
emit2("update:modelValue", newValue);
|
|
28188
28117
|
});
|
|
28118
|
+
vue.watch(() => editor.state.isSplitView, (isEnabled) => {
|
|
28119
|
+
var _a2;
|
|
28120
|
+
if (isEnabled) {
|
|
28121
|
+
editor.state.content = ((_a2 = editor.state.doc) == null ? void 0 : _a2.body.innerHTML) || "";
|
|
28122
|
+
}
|
|
28123
|
+
});
|
|
28189
28124
|
return (_ctx, _cache) => {
|
|
28190
28125
|
var _a2, _b;
|
|
28191
28126
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
|
|
@@ -28209,8 +28144,8 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28209
28144
|
ref: iframe,
|
|
28210
28145
|
class: "editableContent",
|
|
28211
28146
|
title: "Editor",
|
|
28147
|
+
srcdoc: "",
|
|
28212
28148
|
sandbox: "allow-same-origin allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-scripts allow-top-navigation allow-top-navigation-by-user-activation",
|
|
28213
|
-
src: "about:blank",
|
|
28214
28149
|
onLoad: initEditor
|
|
28215
28150
|
}, null, 544)
|
|
28216
28151
|
]),
|
|
@@ -28221,7 +28156,8 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28221
28156
|
_cache[0] || (_cache[0] = ($event) => vue.unref(editor).state.content = $event),
|
|
28222
28157
|
_cache[1] || (_cache[1] = ($event) => vue.unref(editor).updateState.content("html"))
|
|
28223
28158
|
],
|
|
28224
|
-
language: "html"
|
|
28159
|
+
language: "html",
|
|
28160
|
+
class: "code-editor"
|
|
28225
28161
|
}, null, 8, ["modelValue"])) : vue.createCommentVNode("", true)
|
|
28226
28162
|
], 2),
|
|
28227
28163
|
_ctx.debug ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$e, [
|
|
@@ -28268,7 +28204,7 @@ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
|
28268
28204
|
};
|
|
28269
28205
|
}
|
|
28270
28206
|
});
|
|
28271
|
-
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-
|
|
28207
|
+
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-0aa61b83"]]);
|
|
28272
28208
|
const _hoisted_1$r = { class: "flex gap-05" };
|
|
28273
28209
|
const _hoisted_2$h = ["disabled"];
|
|
28274
28210
|
const _hoisted_3$d = { key: 1 };
|
package/dist/index.mjs
CHANGED
|
@@ -25802,7 +25802,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
25802
25802
|
};
|
|
25803
25803
|
}
|
|
25804
25804
|
});
|
|
25805
|
-
const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-
|
|
25805
|
+
const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-50fd0597"]]);
|
|
25806
25806
|
const _hoisted_1$B = ["title"];
|
|
25807
25807
|
const _hoisted_2$p = { key: 0 };
|
|
25808
25808
|
const _hoisted_3$k = ["value", "placeholder"];
|
|
@@ -27392,10 +27392,8 @@ function useCommands(state2, debug) {
|
|
|
27392
27392
|
return {
|
|
27393
27393
|
execute: (command, value) => {
|
|
27394
27394
|
if (!state2.doc) return;
|
|
27395
|
-
console.log("[useCommands.execute] Starting command execution:", command, value);
|
|
27396
27395
|
debug == null ? void 0 : debug.logCommand(command, value);
|
|
27397
27396
|
if (["splitView", "codeView", "fullScreen"].includes(command)) {
|
|
27398
|
-
console.log("[useCommands.execute] Handling view state command:", command);
|
|
27399
27397
|
switch (command) {
|
|
27400
27398
|
case "splitView":
|
|
27401
27399
|
state2.isSplitView = !state2.isSplitView;
|
|
@@ -27408,25 +27406,16 @@ function useCommands(state2, debug) {
|
|
|
27408
27406
|
return;
|
|
27409
27407
|
}
|
|
27410
27408
|
}
|
|
27411
|
-
console.log("[useCommands.execute] Focusing editor");
|
|
27412
27409
|
state2.doc.body.focus();
|
|
27413
|
-
console.log("[useCommands.execute] Executing command");
|
|
27414
27410
|
executor.execute(command, value);
|
|
27415
27411
|
const newContent = state2.doc.body.innerHTML;
|
|
27416
|
-
console.log("[useCommands.execute] Checking content changes");
|
|
27417
|
-
console.log("[useCommands.execute] Old content length:", state2.content.length);
|
|
27418
|
-
console.log("[useCommands.execute] New content length:", newContent.length);
|
|
27419
27412
|
if (newContent !== state2.content) {
|
|
27420
|
-
console.log("[useCommands.execute] Content changed, updating state");
|
|
27421
27413
|
state2.content = newContent;
|
|
27422
27414
|
}
|
|
27423
|
-
console.log("[useCommands.execute] Checking selection changes");
|
|
27424
27415
|
const selection = state2.doc.getSelection();
|
|
27425
27416
|
if (selection == null ? void 0 : selection.rangeCount) {
|
|
27426
27417
|
const hasSelectionChanged = !state2.selection || state2.selection !== selection || state2.rangeCount !== selection.rangeCount;
|
|
27427
|
-
console.log("[useCommands.execute] Selection changed:", hasSelectionChanged);
|
|
27428
27418
|
if (hasSelectionChanged) {
|
|
27429
|
-
console.log("[useCommands.execute] Updating selection state");
|
|
27430
27419
|
state2.selection = selection;
|
|
27431
27420
|
state2.range = selection.getRangeAt(0).cloneRange();
|
|
27432
27421
|
state2.rangeCount = selection.rangeCount;
|
|
@@ -27623,7 +27612,6 @@ function useEditor() {
|
|
|
27623
27612
|
const updateState = {
|
|
27624
27613
|
styles: () => {
|
|
27625
27614
|
if (!state2.doc) return;
|
|
27626
|
-
console.log("[updateState.styles] Starting style update");
|
|
27627
27615
|
const styles = /* @__PURE__ */ new Set();
|
|
27628
27616
|
const styleTypes = [
|
|
27629
27617
|
"bold",
|
|
@@ -27646,82 +27634,59 @@ function useEditor() {
|
|
|
27646
27634
|
styles.add(style);
|
|
27647
27635
|
}
|
|
27648
27636
|
});
|
|
27649
|
-
console.log("[updateState.styles] New styles:", Array.from(styles));
|
|
27650
27637
|
state2.selectedStyles = styles;
|
|
27651
27638
|
},
|
|
27652
27639
|
content: (source) => {
|
|
27653
27640
|
if (!state2.doc) return;
|
|
27654
|
-
console.log("[updateState.content] Starting content update, source:", source);
|
|
27655
27641
|
const currentContent = state2.doc.body.innerHTML;
|
|
27656
|
-
console.log("[updateState.content] Current content length:", currentContent.length);
|
|
27657
|
-
console.log("[updateState.content] State content length:", state2.content.length);
|
|
27658
27642
|
if (currentContent !== state2.content) {
|
|
27659
|
-
console.log("[updateState.content] Content changed, pushing to undo stack");
|
|
27660
27643
|
state2.undoStack.push(state2.content);
|
|
27661
27644
|
state2.redoStack = [];
|
|
27662
27645
|
}
|
|
27663
27646
|
const selection = state2.doc.getSelection();
|
|
27664
27647
|
const range2 = (selection == null ? void 0 : selection.rangeCount) ? selection.getRangeAt(0).cloneRange() : null;
|
|
27665
|
-
console.log("[updateState.content] Has selection:", !!selection, "Has range:", !!range2);
|
|
27666
27648
|
if (source === "html") {
|
|
27667
|
-
console.log("[updateState.content] Processing HTML content");
|
|
27668
27649
|
const preserved = preserveIframes(state2.content);
|
|
27669
|
-
console.log("[updateState.content] Preserved iframes count:", preserved.iframes.length);
|
|
27670
27650
|
state2.doc.body.innerHTML = preserved.html;
|
|
27671
27651
|
setTimeout(() => {
|
|
27672
|
-
console.log("[updateState.content] Restoring iframes");
|
|
27673
27652
|
if (state2.doc) {
|
|
27674
27653
|
restoreIframes(state2.doc, state2.content, preserved.iframes);
|
|
27675
27654
|
if (range2 && selection) {
|
|
27676
27655
|
try {
|
|
27677
27656
|
selection.removeAllRanges();
|
|
27678
27657
|
selection.addRange(range2);
|
|
27679
|
-
console.log("[updateState.content] Selection restored");
|
|
27680
27658
|
} catch (e) {
|
|
27681
|
-
console.warn("[updateState.content] Could not restore selection:", e);
|
|
27682
27659
|
}
|
|
27683
27660
|
}
|
|
27684
27661
|
}
|
|
27685
27662
|
}, 0);
|
|
27686
27663
|
} else {
|
|
27687
|
-
console.log("[updateState.content] Setting text content");
|
|
27688
27664
|
state2.doc.body.textContent = state2.content;
|
|
27689
27665
|
}
|
|
27690
27666
|
},
|
|
27691
27667
|
selection: () => {
|
|
27692
27668
|
if (!state2.doc) return;
|
|
27693
|
-
console.log("[updateState.selection] Starting selection update");
|
|
27694
27669
|
const newSelection = state2.doc.getSelection();
|
|
27695
27670
|
if (!newSelection) {
|
|
27696
|
-
console.log("[updateState.selection] No selection available");
|
|
27697
27671
|
return;
|
|
27698
27672
|
}
|
|
27699
27673
|
try {
|
|
27700
27674
|
if (!state2.doc.body.contains(newSelection.anchorNode)) {
|
|
27701
|
-
console.log("[updateState.selection] Selection outside editor body, refocusing");
|
|
27702
27675
|
state2.doc.body.focus();
|
|
27703
27676
|
return;
|
|
27704
27677
|
}
|
|
27705
27678
|
const hasSelectionChanged = !state2.selection || state2.selection !== newSelection || state2.rangeCount !== newSelection.rangeCount || newSelection.rangeCount > 0 && state2.range && (state2.range.startContainer !== newSelection.getRangeAt(0).startContainer || state2.range.startOffset !== newSelection.getRangeAt(0).startOffset || state2.range.endContainer !== newSelection.getRangeAt(0).endContainer || state2.range.endOffset !== newSelection.getRangeAt(0).endOffset);
|
|
27706
|
-
console.log("[updateState.selection] Selection changed:", hasSelectionChanged);
|
|
27707
27679
|
if (hasSelectionChanged) {
|
|
27708
27680
|
state2.selection = newSelection;
|
|
27709
27681
|
state2.rangeCount = newSelection.rangeCount;
|
|
27710
27682
|
if (newSelection.rangeCount > 0) {
|
|
27711
27683
|
state2.range = newSelection.getRangeAt(0).cloneRange();
|
|
27712
|
-
console.log("[updateState.selection] New range:", {
|
|
27713
|
-
startOffset: state2.range.startOffset,
|
|
27714
|
-
endOffset: state2.range.endOffset,
|
|
27715
|
-
collapsed: state2.range.collapsed
|
|
27716
|
-
});
|
|
27717
27684
|
}
|
|
27718
27685
|
requestAnimationFrame(() => {
|
|
27719
|
-
console.log("[updateState.selection] Updating styles in RAF");
|
|
27720
27686
|
updateState.styles();
|
|
27721
27687
|
});
|
|
27722
27688
|
}
|
|
27723
27689
|
} catch (e) {
|
|
27724
|
-
console.warn("[updateState.selection] Selection error:", e);
|
|
27725
27690
|
state2.selection = null;
|
|
27726
27691
|
state2.range = null;
|
|
27727
27692
|
state2.rangeCount = 0;
|
|
@@ -27811,70 +27776,44 @@ function useEditor() {
|
|
|
27811
27776
|
}
|
|
27812
27777
|
};
|
|
27813
27778
|
function setupEventListeners(doc) {
|
|
27814
|
-
console.log("[setupEventListeners] Starting setup");
|
|
27815
27779
|
if (cleanupListeners) {
|
|
27816
|
-
console.log("[setupEventListeners] Cleaning up existing listeners");
|
|
27817
27780
|
cleanupListeners();
|
|
27818
27781
|
cleanupListeners = null;
|
|
27819
27782
|
}
|
|
27820
27783
|
let isUpdating = false;
|
|
27821
27784
|
let contentUpdateTimeout = null;
|
|
27822
27785
|
let selectionUpdateTimeout = null;
|
|
27823
|
-
let updateCount = 0;
|
|
27824
27786
|
const events = {
|
|
27825
27787
|
input: () => {
|
|
27826
|
-
|
|
27827
|
-
console.log(`[input event #${updateCount}] Starting, isUpdating:`, isUpdating);
|
|
27828
|
-
if (isUpdating) {
|
|
27829
|
-
console.log(`[input event #${updateCount}] Skipped - already updating`);
|
|
27830
|
-
return;
|
|
27831
|
-
}
|
|
27788
|
+
if (isUpdating) return;
|
|
27832
27789
|
isUpdating = true;
|
|
27833
27790
|
if (contentUpdateTimeout) {
|
|
27834
|
-
console.log(`[input event #${updateCount}] Clearing previous timeout`);
|
|
27835
27791
|
window.clearTimeout(contentUpdateTimeout);
|
|
27836
27792
|
}
|
|
27837
27793
|
contentUpdateTimeout = window.setTimeout(() => {
|
|
27838
|
-
console.log(`[input event #${updateCount}] Timeout fired`);
|
|
27839
27794
|
const newContent = doc.body.innerHTML;
|
|
27840
27795
|
if (newContent !== state2.content) {
|
|
27841
|
-
console.log(`[input event #${updateCount}] Content changed, updating state`);
|
|
27842
27796
|
state2.content = newContent;
|
|
27843
|
-
} else {
|
|
27844
|
-
console.log(`[input event #${updateCount}] Content unchanged`);
|
|
27845
27797
|
}
|
|
27846
27798
|
isUpdating = false;
|
|
27847
27799
|
}, 100);
|
|
27848
27800
|
},
|
|
27849
27801
|
selectionchange: () => {
|
|
27850
|
-
|
|
27851
|
-
console.log(`[selectionchange #${updateCount}] Starting, isUpdating:`, isUpdating);
|
|
27852
|
-
if (isUpdating) {
|
|
27853
|
-
console.log(`[selectionchange #${updateCount}] Skipped - already updating`);
|
|
27854
|
-
return;
|
|
27855
|
-
}
|
|
27802
|
+
if (isUpdating) return;
|
|
27856
27803
|
if (selectionUpdateTimeout) {
|
|
27857
|
-
console.log(`[selectionchange #${updateCount}] Clearing previous timeout`);
|
|
27858
27804
|
window.clearTimeout(selectionUpdateTimeout);
|
|
27859
27805
|
}
|
|
27860
27806
|
selectionUpdateTimeout = window.setTimeout(() => {
|
|
27861
|
-
console.log(`[selectionchange #${updateCount}] Timeout fired`);
|
|
27862
27807
|
if (!isUpdating) {
|
|
27863
27808
|
updateState.selection();
|
|
27864
|
-
} else {
|
|
27865
|
-
console.log(`[selectionchange #${updateCount}] Skipped - still updating`);
|
|
27866
27809
|
}
|
|
27867
27810
|
}, 150);
|
|
27868
27811
|
},
|
|
27869
27812
|
mouseup: () => {
|
|
27870
|
-
updateCount++;
|
|
27871
|
-
console.log(`[mouseup #${updateCount}] Starting, isUpdating:`, isUpdating);
|
|
27872
27813
|
if (isUpdating) return;
|
|
27873
27814
|
updateState.selection();
|
|
27874
27815
|
},
|
|
27875
27816
|
keyup: (e) => {
|
|
27876
|
-
updateCount++;
|
|
27877
|
-
console.log(`[keyup #${updateCount}] Key:`, e.key, "isUpdating:", isUpdating);
|
|
27878
27817
|
if (isUpdating) return;
|
|
27879
27818
|
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
27880
27819
|
updateState.selection();
|
|
@@ -27883,10 +27822,8 @@ function useEditor() {
|
|
|
27883
27822
|
};
|
|
27884
27823
|
Object.entries(events).forEach(([event, handler]) => {
|
|
27885
27824
|
doc.addEventListener(event, handler);
|
|
27886
|
-
console.log("[setupEventListeners] Added listener for:", event);
|
|
27887
27825
|
});
|
|
27888
27826
|
cleanupListeners = () => {
|
|
27889
|
-
console.log("[setupEventListeners] Cleaning up event listeners");
|
|
27890
27827
|
if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout);
|
|
27891
27828
|
if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout);
|
|
27892
27829
|
Object.entries(events).forEach(([event, handler]) => {
|
|
@@ -27896,9 +27833,7 @@ function useEditor() {
|
|
|
27896
27833
|
return cleanupListeners;
|
|
27897
27834
|
}
|
|
27898
27835
|
function init(doc) {
|
|
27899
|
-
console.log("[init] Starting initialization");
|
|
27900
27836
|
if (state2.hasInit) {
|
|
27901
|
-
console.log("[init] Already initialized, cleaning up first");
|
|
27902
27837
|
if (cleanupListeners) {
|
|
27903
27838
|
cleanupListeners();
|
|
27904
27839
|
cleanupListeners = null;
|
|
@@ -28090,9 +28025,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28090
28025
|
});
|
|
28091
28026
|
async function initEditor() {
|
|
28092
28027
|
var _a2;
|
|
28093
|
-
console.log("[initEditor] Starting, isInitializing:", isInitializing.value, "hasInitialized:", hasInitialized.value);
|
|
28094
28028
|
if (isInitializing.value || !iframe.value || hasInitialized.value) {
|
|
28095
|
-
console.log("[initEditor] Skipped - already initializing/initialized or no iframe");
|
|
28096
28029
|
return;
|
|
28097
28030
|
}
|
|
28098
28031
|
isInitializing.value = true;
|
|
@@ -28120,10 +28053,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28120
28053
|
</html>
|
|
28121
28054
|
`;
|
|
28122
28055
|
const doc = iframe.value.contentDocument || ((_a2 = iframe.value.contentWindow) == null ? void 0 : _a2.document);
|
|
28123
|
-
if (!doc)
|
|
28124
|
-
console.warn("[initEditor] No document found");
|
|
28125
|
-
return;
|
|
28126
|
-
}
|
|
28056
|
+
if (!doc) return;
|
|
28127
28057
|
doc.open();
|
|
28128
28058
|
doc.write(htmlContent);
|
|
28129
28059
|
doc.close();
|
|
@@ -28162,7 +28092,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28162
28092
|
doc.body.focus();
|
|
28163
28093
|
hasInitialized.value = true;
|
|
28164
28094
|
} catch (error) {
|
|
28165
|
-
console.error("
|
|
28095
|
+
console.error("Error during editor initialization:", error);
|
|
28166
28096
|
} finally {
|
|
28167
28097
|
isInitializing.value = false;
|
|
28168
28098
|
}
|
|
@@ -28170,7 +28100,6 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28170
28100
|
watch(() => props2.modelValue, (newValue, oldValue) => {
|
|
28171
28101
|
if (newValue !== editor.state.content) {
|
|
28172
28102
|
if (!oldValue || Math.abs(newValue.length - oldValue.length) > 50) {
|
|
28173
|
-
console.log("[watch] Significant content change, resetting initialization state");
|
|
28174
28103
|
hasInitialized.value = false;
|
|
28175
28104
|
editor.state.content = newValue;
|
|
28176
28105
|
editor.updateState.content("html");
|
|
@@ -28184,6 +28113,12 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28184
28113
|
}
|
|
28185
28114
|
emit2("update:modelValue", newValue);
|
|
28186
28115
|
});
|
|
28116
|
+
watch(() => editor.state.isSplitView, (isEnabled) => {
|
|
28117
|
+
var _a2;
|
|
28118
|
+
if (isEnabled) {
|
|
28119
|
+
editor.state.content = ((_a2 = editor.state.doc) == null ? void 0 : _a2.body.innerHTML) || "";
|
|
28120
|
+
}
|
|
28121
|
+
});
|
|
28187
28122
|
return (_ctx, _cache) => {
|
|
28188
28123
|
var _a2, _b;
|
|
28189
28124
|
return openBlock(), createElementBlock("div", _hoisted_1$s, [
|
|
@@ -28207,8 +28142,8 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28207
28142
|
ref: iframe,
|
|
28208
28143
|
class: "editableContent",
|
|
28209
28144
|
title: "Editor",
|
|
28145
|
+
srcdoc: "",
|
|
28210
28146
|
sandbox: "allow-same-origin allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-scripts allow-top-navigation allow-top-navigation-by-user-activation",
|
|
28211
|
-
src: "about:blank",
|
|
28212
28147
|
onLoad: initEditor
|
|
28213
28148
|
}, null, 544)
|
|
28214
28149
|
]),
|
|
@@ -28219,7 +28154,8 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28219
28154
|
_cache[0] || (_cache[0] = ($event) => unref(editor).state.content = $event),
|
|
28220
28155
|
_cache[1] || (_cache[1] = ($event) => unref(editor).updateState.content("html"))
|
|
28221
28156
|
],
|
|
28222
|
-
language: "html"
|
|
28157
|
+
language: "html",
|
|
28158
|
+
class: "code-editor"
|
|
28223
28159
|
}, null, 8, ["modelValue"])) : createCommentVNode("", true)
|
|
28224
28160
|
], 2),
|
|
28225
28161
|
_ctx.debug ? (openBlock(), createElementBlock("div", _hoisted_3$e, [
|
|
@@ -28266,7 +28202,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
28266
28202
|
};
|
|
28267
28203
|
}
|
|
28268
28204
|
});
|
|
28269
|
-
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-
|
|
28205
|
+
const RichText = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-0aa61b83"]]);
|
|
28270
28206
|
const _hoisted_1$r = { class: "flex gap-05" };
|
|
28271
28207
|
const _hoisted_2$h = ["disabled"];
|
|
28272
28208
|
const _hoisted_3$d = { key: 1 };
|
package/dist/style.css
CHANGED
|
@@ -1638,7 +1638,7 @@ pre code.hljs{
|
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
1640
1640
|
|
|
1641
|
-
.fileUploadWrap[data-v-
|
|
1641
|
+
.fileUploadWrap[data-v-50fd0597] {
|
|
1642
1642
|
outline: 1px solid var(--border-color);
|
|
1643
1643
|
border-radius: var(--input-border-radius);
|
|
1644
1644
|
text-align: center;
|
|
@@ -1650,7 +1650,7 @@ pre code.hljs{
|
|
|
1650
1650
|
background: var(--input-bg);
|
|
1651
1651
|
height: 215px;
|
|
1652
1652
|
}
|
|
1653
|
-
.bagel-input .fileUploadWrap.fileDropZone[data-v-
|
|
1653
|
+
.bagel-input .fileUploadWrap.fileDropZone[data-v-50fd0597] {
|
|
1654
1654
|
background: var(--input-bg);
|
|
1655
1655
|
display: flex;
|
|
1656
1656
|
align-items: center;
|
|
@@ -1658,14 +1658,14 @@ pre code.hljs{
|
|
|
1658
1658
|
color: var(--bgl-gray);
|
|
1659
1659
|
flex-direction: column;
|
|
1660
1660
|
}
|
|
1661
|
-
.fileUploadWrap.dragover[data-v-
|
|
1662
|
-
.fileUploadWrap[data-v-
|
|
1661
|
+
.fileUploadWrap.dragover[data-v-50fd0597],
|
|
1662
|
+
.fileUploadWrap[data-v-50fd0597]:hover {
|
|
1663
1663
|
box-shadow: inset 0 0 10px #00000012;
|
|
1664
1664
|
}
|
|
1665
|
-
.fileUploadWrap[style*='height: auto;'][data-v-
|
|
1665
|
+
.fileUploadWrap[style*='height: auto;'][data-v-50fd0597] {
|
|
1666
1666
|
min-height: 215px;
|
|
1667
1667
|
}
|
|
1668
|
-
.multi-image-item-preview[data-v-
|
|
1668
|
+
.multi-image-item-preview[data-v-50fd0597] {
|
|
1669
1669
|
border: 1px solid var(--border-color) !important;
|
|
1670
1670
|
border-radius: var(--input-border-radius);
|
|
1671
1671
|
margin: 0.5rem !important;
|
|
@@ -1679,12 +1679,12 @@ pre code.hljs{
|
|
|
1679
1679
|
gap: 1rem;
|
|
1680
1680
|
align-items: center;
|
|
1681
1681
|
}
|
|
1682
|
-
.multi-image-item-preview p[data-v-
|
|
1682
|
+
.multi-image-item-preview p[data-v-50fd0597] {
|
|
1683
1683
|
overflow: hidden;
|
|
1684
1684
|
text-overflow: ellipsis;
|
|
1685
1685
|
white-space: nowrap;
|
|
1686
1686
|
}
|
|
1687
|
-
.multi-preview[data-v-
|
|
1687
|
+
.multi-preview[data-v-50fd0597] {
|
|
1688
1688
|
width: 40px;
|
|
1689
1689
|
height: 40px;
|
|
1690
1690
|
border-radius: var(--input-border-radius);
|
|
@@ -1695,17 +1695,17 @@ pre code.hljs{
|
|
|
1695
1695
|
align-items: center;
|
|
1696
1696
|
display: flex;
|
|
1697
1697
|
}
|
|
1698
|
-
.bgl-single-preview[data-v-
|
|
1698
|
+
.bgl-single-preview[data-v-50fd0597] {
|
|
1699
1699
|
height: 100%;
|
|
1700
1700
|
position: relative;
|
|
1701
1701
|
}
|
|
1702
|
-
.bgl-single-preview + .fileUploadPlaceHolder[data-v-
|
|
1702
|
+
.bgl-single-preview + .fileUploadPlaceHolder[data-v-50fd0597] {
|
|
1703
1703
|
position: absolute;
|
|
1704
1704
|
inset: 0;
|
|
1705
1705
|
margin: auto;
|
|
1706
1706
|
top: calc(50% - 2rem);
|
|
1707
1707
|
}
|
|
1708
|
-
.single-image-item-preview[data-v-
|
|
1708
|
+
.single-image-item-preview[data-v-50fd0597] {
|
|
1709
1709
|
height: 100%;
|
|
1710
1710
|
min-height: 100%;
|
|
1711
1711
|
position: relative;
|
|
@@ -1713,13 +1713,13 @@ pre code.hljs{
|
|
|
1713
1713
|
align-items: center;
|
|
1714
1714
|
justify-content: center;
|
|
1715
1715
|
}
|
|
1716
|
-
.fileUploadWrap[style*='height: auto'] .single-image-item-preview[data-v-
|
|
1716
|
+
.fileUploadWrap[style*='height: auto'] .single-image-item-preview[data-v-50fd0597] {
|
|
1717
1717
|
min-height: 215px;
|
|
1718
1718
|
}
|
|
1719
|
-
.fileUploadWrap[style*='height: auto'] .single-preview[data-v-
|
|
1719
|
+
.fileUploadWrap[style*='height: auto'] .single-preview[data-v-50fd0597] {
|
|
1720
1720
|
margin: 0rem !important;
|
|
1721
1721
|
}
|
|
1722
|
-
.single-preview[data-v-
|
|
1722
|
+
.single-preview[data-v-50fd0597] {
|
|
1723
1723
|
border-radius: var(--input-border-radius);
|
|
1724
1724
|
margin: 1rem;
|
|
1725
1725
|
padding: 0px;
|
|
@@ -1727,9 +1727,10 @@ pre code.hljs{
|
|
|
1727
1727
|
height: calc(100% - 2rem);
|
|
1728
1728
|
object-fit: cover;
|
|
1729
1729
|
background: var(--bgl-gray-light);
|
|
1730
|
-
width: 90
|
|
1730
|
+
width: calc(90% - 2rem);
|
|
1731
|
+
min-width: 5rem;
|
|
1731
1732
|
}
|
|
1732
|
-
.single-image-item-preview[data-v-
|
|
1733
|
+
.single-image-item-preview[data-v-50fd0597]:hover::after {
|
|
1733
1734
|
content: 'zoom_in';
|
|
1734
1735
|
font-size: 32px;
|
|
1735
1736
|
font-family: 'Material Symbols Outlined', serif;
|
|
@@ -1739,20 +1740,20 @@ pre code.hljs{
|
|
|
1739
1740
|
z-index: 9;
|
|
1740
1741
|
pointer-events: none;
|
|
1741
1742
|
}
|
|
1742
|
-
.single-image-item-preview:hover img[data-v-
|
|
1743
|
+
.single-image-item-preview:hover img[data-v-50fd0597] {
|
|
1743
1744
|
filter: brightness(70%);
|
|
1744
1745
|
}
|
|
1745
|
-
.bgl_fill-image.single-image-item-preview[data-v-
|
|
1746
|
+
.bgl_fill-image.single-image-item-preview[data-v-50fd0597] {
|
|
1746
1747
|
height: 100%;
|
|
1747
1748
|
}
|
|
1748
|
-
.bgl_fill-image.single-image-item-preview .single-preview[data-v-
|
|
1749
|
+
.bgl_fill-image.single-image-item-preview .single-preview[data-v-50fd0597] {
|
|
1749
1750
|
border-radius: unset;
|
|
1750
1751
|
object-fit: cover;
|
|
1751
1752
|
box-shadow: unset;
|
|
1752
1753
|
width: 100%;
|
|
1753
1754
|
height: auto;
|
|
1754
1755
|
}
|
|
1755
|
-
.single-image-item-preview .pie[data-v-
|
|
1756
|
+
.single-image-item-preview .pie[data-v-50fd0597] {
|
|
1756
1757
|
transform-origin: top;
|
|
1757
1758
|
transform: scale(1.4);
|
|
1758
1759
|
position: absolute;
|
|
@@ -1766,31 +1767,31 @@ pre code.hljs{
|
|
|
1766
1767
|
border: none !important;
|
|
1767
1768
|
padding: 0 !important;
|
|
1768
1769
|
}
|
|
1769
|
-
.bgl_oval-upload[data-v-
|
|
1770
|
+
.bgl_oval-upload[data-v-50fd0597] {
|
|
1770
1771
|
border-radius: 100% !important;
|
|
1771
1772
|
overflow: hidden;
|
|
1772
1773
|
}
|
|
1773
|
-
.bgl_oval-upload p[data-v-
|
|
1774
|
+
.bgl_oval-upload p[data-v-50fd0597] {
|
|
1774
1775
|
padding: 0.75rem !important;
|
|
1775
1776
|
font-size: 12px;
|
|
1776
1777
|
}
|
|
1777
|
-
.bgl_oval-upload .fileUploadPlaceHolder[data-v-
|
|
1778
|
+
.bgl_oval-upload .fileUploadPlaceHolder[data-v-50fd0597] {
|
|
1778
1779
|
top: 0;
|
|
1779
1780
|
}
|
|
1780
|
-
.bgl_oval-upload .pie[data-v-
|
|
1781
|
+
.bgl_oval-upload .pie[data-v-50fd0597] {
|
|
1781
1782
|
transform: scale(1);
|
|
1782
1783
|
}
|
|
1783
|
-
.bgl_oval-upload span.bgl_icon-font.color-primary[data-v-
|
|
1784
|
+
.bgl_oval-upload span.bgl_icon-font.color-primary[data-v-50fd0597] {
|
|
1784
1785
|
transform: scale(0.4) !important;
|
|
1785
1786
|
}
|
|
1786
|
-
.bgl_oval-upload .single-image-item-preview[data-v-
|
|
1787
|
+
.bgl_oval-upload .single-image-item-preview[data-v-50fd0597] {
|
|
1787
1788
|
height: 100%;
|
|
1788
1789
|
}
|
|
1789
|
-
.bgl_oval-upload .single-preview[data-v-
|
|
1790
|
+
.bgl_oval-upload .single-preview[data-v-50fd0597] {
|
|
1790
1791
|
margin: 0;
|
|
1791
1792
|
height: 100% !important;
|
|
1792
1793
|
}
|
|
1793
|
-
.pie[data-v-
|
|
1794
|
+
.pie[data-v-50fd0597] {
|
|
1794
1795
|
width: 30px;
|
|
1795
1796
|
height: 30px;
|
|
1796
1797
|
position: relative;
|
|
@@ -1798,7 +1799,7 @@ pre code.hljs{
|
|
|
1798
1799
|
align-items: center;
|
|
1799
1800
|
justify-content: center;
|
|
1800
1801
|
}
|
|
1801
|
-
.pie[data-v-
|
|
1802
|
+
.pie[data-v-50fd0597]:before {
|
|
1802
1803
|
content: '';
|
|
1803
1804
|
position: absolute;
|
|
1804
1805
|
border-radius: 50%;
|
|
@@ -1816,26 +1817,26 @@ pre code.hljs{
|
|
|
1816
1817
|
#000 calc(100% - var(--b))
|
|
1817
1818
|
);
|
|
1818
1819
|
}
|
|
1819
|
-
.pie .success[data-v-
|
|
1820
|
+
.pie .success[data-v-50fd0597] {
|
|
1820
1821
|
transform: scale(0);
|
|
1821
1822
|
opacity: 0;
|
|
1822
1823
|
transition: all 0.3s ease-in-out;
|
|
1823
1824
|
}
|
|
1824
|
-
.pie .progress[data-v-
|
|
1825
|
+
.pie .progress[data-v-50fd0597] {
|
|
1825
1826
|
position: absolute;
|
|
1826
1827
|
font-size: 10px;
|
|
1827
1828
|
}
|
|
1828
|
-
.pie.complete .progress[data-v-
|
|
1829
|
+
.pie.complete .progress[data-v-50fd0597] {
|
|
1829
1830
|
display: none;
|
|
1830
1831
|
}
|
|
1831
|
-
.pie.complete .success[data-v-
|
|
1832
|
+
.pie.complete .success[data-v-50fd0597] {
|
|
1832
1833
|
transform: scale(1.3);
|
|
1833
1834
|
opacity: 1;
|
|
1834
1835
|
}
|
|
1835
|
-
.pie.complete[data-v-
|
|
1836
|
+
.pie.complete[data-v-50fd0597]:before {
|
|
1836
1837
|
background: conic-gradient(var(--bgl-green) calc(var(--p) * 1%), #0000 0);
|
|
1837
1838
|
}
|
|
1838
|
-
.pie.complete[data-v-
|
|
1839
|
+
.pie.complete[data-v-50fd0597] {
|
|
1839
1840
|
color: var(--bgl-green);
|
|
1840
1841
|
}
|
|
1841
1842
|
|
|
@@ -2055,29 +2056,34 @@ input[type="range"][data-v-25d991e5]:active::-webkit-slider-thumb {
|
|
|
2055
2056
|
.content-area p,
|
|
2056
2057
|
.content-area span,
|
|
2057
2058
|
.content-area li{
|
|
2058
|
-
line-height: 1.65;
|
|
2059
|
+
line-height: 1.65;
|
|
2060
|
+
}
|
|
2061
|
+
.code-editor {
|
|
2062
|
+
flex: 1;
|
|
2063
|
+
min-height: 240px !important;
|
|
2064
|
+
height: 100%;
|
|
2059
2065
|
}
|
|
2060
2066
|
|
|
2061
|
-
.rich-text-editor[data-v-
|
|
2067
|
+
.rich-text-editor[data-v-0aa61b83] {
|
|
2062
2068
|
background: var(--input-bg);
|
|
2063
2069
|
border: 1px solid var(--border-color);
|
|
2064
2070
|
transition: all 0.3s ease;
|
|
2065
2071
|
}
|
|
2066
|
-
.editor-container[data-v-
|
|
2072
|
+
.editor-container[data-v-0aa61b83] {
|
|
2067
2073
|
display: flex;
|
|
2068
2074
|
gap: 1rem;
|
|
2069
2075
|
}
|
|
2070
|
-
.content-area[data-v-
|
|
2071
|
-
.preview-area[data-v-
|
|
2076
|
+
.content-area[data-v-0aa61b83],
|
|
2077
|
+
.preview-area[data-v-0aa61b83] {
|
|
2072
2078
|
flex: 1;
|
|
2073
2079
|
min-height: 200px;
|
|
2074
2080
|
background: var(--bgl-richtext-color);
|
|
2075
2081
|
}
|
|
2076
|
-
.split-view[data-v-
|
|
2082
|
+
.split-view[data-v-0aa61b83] {
|
|
2077
2083
|
display: grid;
|
|
2078
2084
|
grid-template-columns: 1fr 1fr;
|
|
2079
2085
|
}
|
|
2080
|
-
.editableContent[data-v-
|
|
2086
|
+
.editableContent[data-v-0aa61b83] {
|
|
2081
2087
|
width: 100%;
|
|
2082
2088
|
min-height: 240px;
|
|
2083
2089
|
height: 100%;
|
|
@@ -2085,7 +2091,7 @@ line-height: 1.65;
|
|
|
2085
2091
|
outline: none;
|
|
2086
2092
|
background: transparent;
|
|
2087
2093
|
}
|
|
2088
|
-
.html-editor[data-v-
|
|
2094
|
+
.html-editor[data-v-0aa61b83] {
|
|
2089
2095
|
width: 100%;
|
|
2090
2096
|
height: 100%;
|
|
2091
2097
|
min-height: 200px;
|
|
@@ -2096,12 +2102,12 @@ line-height: 1.65;
|
|
|
2096
2102
|
color: white;
|
|
2097
2103
|
background-color: var(--bgl-black);
|
|
2098
2104
|
}
|
|
2099
|
-
.preview-area[data-v-
|
|
2105
|
+
.preview-area[data-v-0aa61b83] {
|
|
2100
2106
|
font-family: monospace;
|
|
2101
2107
|
white-space: pre-wrap;
|
|
2102
2108
|
overflow-x: auto;
|
|
2103
2109
|
}
|
|
2104
|
-
.fullscreen-mode[data-v-
|
|
2110
|
+
.fullscreen-mode[data-v-0aa61b83] {
|
|
2105
2111
|
position: fixed;
|
|
2106
2112
|
top: 0;
|
|
2107
2113
|
left: 0;
|
|
@@ -2110,18 +2116,18 @@ line-height: 1.65;
|
|
|
2110
2116
|
z-index: 9999;
|
|
2111
2117
|
padding: 2rem;
|
|
2112
2118
|
}
|
|
2113
|
-
.fullscreen-mode .editor-container[data-v-
|
|
2119
|
+
.fullscreen-mode .editor-container[data-v-0aa61b83] {
|
|
2114
2120
|
height: calc(100vh - 4rem);
|
|
2115
2121
|
}
|
|
2116
|
-
.fullscreen-mode .content-area[data-v-
|
|
2117
|
-
.fullscreen-mode .preview-area[data-v-
|
|
2122
|
+
.fullscreen-mode .content-area[data-v-0aa61b83],
|
|
2123
|
+
.fullscreen-mode .preview-area[data-v-0aa61b83] {
|
|
2118
2124
|
height: 100%;
|
|
2119
2125
|
overflow-y: auto;
|
|
2120
2126
|
}
|
|
2121
|
-
.fullscreen-mode .code-editor[data-v-
|
|
2127
|
+
.fullscreen-mode .code-editor[data-v-0aa61b83]{
|
|
2122
2128
|
height: 100% !important;
|
|
2123
2129
|
}
|
|
2124
|
-
.debug-controls[data-v-
|
|
2130
|
+
.debug-controls[data-v-0aa61b83] {
|
|
2125
2131
|
display: flex;
|
|
2126
2132
|
gap: 0.5rem;
|
|
2127
2133
|
justify-content: flex-end;
|
package/package.json
CHANGED
|
@@ -598,7 +598,8 @@ function drop(e: DragEvent) {
|
|
|
598
598
|
height: calc(100% - 2rem);
|
|
599
599
|
object-fit: cover;
|
|
600
600
|
background: var(--bgl-gray-light);
|
|
601
|
-
width: 90
|
|
601
|
+
width: calc(90% - 2rem);
|
|
602
|
+
min-width: 5rem;
|
|
602
603
|
}
|
|
603
604
|
.single-image-item-preview:hover::after {
|
|
604
605
|
content: 'zoom_in';
|
|
@@ -9,14 +9,11 @@ export function useCommands(state: EditorState, debug?: { logCommand: (command:
|
|
|
9
9
|
execute: (command: string, value?: string) => {
|
|
10
10
|
if (!state.doc) return
|
|
11
11
|
|
|
12
|
-
console.log('[useCommands.execute] Starting command execution:', command, value)
|
|
13
|
-
|
|
14
12
|
// Log command if debug is enabled
|
|
15
13
|
debug?.logCommand(command, value)
|
|
16
14
|
|
|
17
15
|
// Handle view state commands directly
|
|
18
16
|
if (['splitView', 'codeView', 'fullScreen'].includes(command)) {
|
|
19
|
-
console.log('[useCommands.execute] Handling view state command:', command)
|
|
20
17
|
switch (command) {
|
|
21
18
|
case 'splitView':
|
|
22
19
|
state.isSplitView = !state.isSplitView
|
|
@@ -31,34 +28,25 @@ export function useCommands(state: EditorState, debug?: { logCommand: (command:
|
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
// Focus the editor before executing command
|
|
34
|
-
console.log('[useCommands.execute] Focusing editor')
|
|
35
31
|
state.doc.body.focus()
|
|
36
32
|
|
|
37
33
|
// Execute the command
|
|
38
|
-
console.log('[useCommands.execute] Executing command')
|
|
39
34
|
executor.execute(command, value)
|
|
40
35
|
|
|
41
36
|
// Update content state only if it has changed
|
|
42
37
|
const newContent = state.doc.body.innerHTML
|
|
43
|
-
console.log('[useCommands.execute] Checking content changes')
|
|
44
|
-
console.log('[useCommands.execute] Old content length:', state.content.length)
|
|
45
|
-
console.log('[useCommands.execute] New content length:', newContent.length)
|
|
46
38
|
if (newContent !== state.content) {
|
|
47
|
-
console.log('[useCommands.execute] Content changed, updating state')
|
|
48
39
|
state.content = newContent
|
|
49
40
|
}
|
|
50
41
|
|
|
51
42
|
// Update selection state if needed
|
|
52
|
-
console.log('[useCommands.execute] Checking selection changes')
|
|
53
43
|
const selection = state.doc.getSelection()
|
|
54
44
|
if (selection?.rangeCount) {
|
|
55
45
|
const hasSelectionChanged = !state.selection
|
|
56
46
|
|| state.selection !== selection
|
|
57
47
|
|| state.rangeCount !== selection.rangeCount
|
|
58
48
|
|
|
59
|
-
console.log('[useCommands.execute] Selection changed:', hasSelectionChanged)
|
|
60
49
|
if (hasSelectionChanged) {
|
|
61
|
-
console.log('[useCommands.execute] Updating selection state')
|
|
62
50
|
state.selection = selection
|
|
63
51
|
state.range = selection.getRangeAt(0).cloneRange()
|
|
64
52
|
state.rangeCount = selection.rangeCount
|
|
@@ -58,7 +58,6 @@ export function useEditor() {
|
|
|
58
58
|
const updateState = {
|
|
59
59
|
styles: () => {
|
|
60
60
|
if (!state.doc) return
|
|
61
|
-
console.log('[updateState.styles] Starting style update')
|
|
62
61
|
const styles = new Set<string>()
|
|
63
62
|
const styleTypes = [
|
|
64
63
|
'bold',
|
|
@@ -81,19 +80,14 @@ export function useEditor() {
|
|
|
81
80
|
styles.add(style)
|
|
82
81
|
}
|
|
83
82
|
})
|
|
84
|
-
console.log('[updateState.styles] New styles:', Array.from(styles))
|
|
85
83
|
state.selectedStyles = styles
|
|
86
84
|
},
|
|
87
85
|
content: (source: 'html' | 'text') => {
|
|
88
86
|
if (!state.doc) return
|
|
89
|
-
console.log('[updateState.content] Starting content update, source:', source)
|
|
90
87
|
|
|
91
88
|
// Only push to undo stack if content has changed
|
|
92
89
|
const currentContent = state.doc.body.innerHTML
|
|
93
|
-
console.log('[updateState.content] Current content length:', currentContent.length)
|
|
94
|
-
console.log('[updateState.content] State content length:', state.content.length)
|
|
95
90
|
if (currentContent !== state.content) {
|
|
96
|
-
console.log('[updateState.content] Content changed, pushing to undo stack')
|
|
97
91
|
state.undoStack.push(state.content)
|
|
98
92
|
state.redoStack = []
|
|
99
93
|
}
|
|
@@ -101,18 +95,14 @@ export function useEditor() {
|
|
|
101
95
|
// Store current selection
|
|
102
96
|
const selection = state.doc.getSelection()
|
|
103
97
|
const range = selection?.rangeCount ? selection.getRangeAt(0).cloneRange() : null
|
|
104
|
-
console.log('[updateState.content] Has selection:', !!selection, 'Has range:', !!range)
|
|
105
98
|
|
|
106
99
|
if (source === 'html') {
|
|
107
|
-
console.log('[updateState.content] Processing HTML content')
|
|
108
100
|
// Preserve iframes before setting content
|
|
109
101
|
const preserved = preserveIframes(state.content)
|
|
110
|
-
console.log('[updateState.content] Preserved iframes count:', preserved.iframes.length)
|
|
111
102
|
state.doc.body.innerHTML = preserved.html
|
|
112
103
|
|
|
113
104
|
// Restore iframes after a short delay to ensure the document is ready
|
|
114
105
|
setTimeout(() => {
|
|
115
|
-
console.log('[updateState.content] Restoring iframes')
|
|
116
106
|
if (state.doc) {
|
|
117
107
|
restoreIframes(state.doc, state.content, preserved.iframes)
|
|
118
108
|
|
|
@@ -121,30 +111,24 @@ export function useEditor() {
|
|
|
121
111
|
try {
|
|
122
112
|
selection.removeAllRanges()
|
|
123
113
|
selection.addRange(range)
|
|
124
|
-
console.log('[updateState.content] Selection restored')
|
|
125
114
|
} catch (e) {
|
|
126
|
-
console.warn('[updateState.content] Could not restore selection:', e)
|
|
127
115
|
}
|
|
128
116
|
}
|
|
129
117
|
}
|
|
130
118
|
}, 0)
|
|
131
119
|
} else {
|
|
132
|
-
console.log('[updateState.content] Setting text content')
|
|
133
120
|
state.doc.body.textContent = state.content
|
|
134
121
|
}
|
|
135
122
|
},
|
|
136
123
|
selection: () => {
|
|
137
124
|
if (!state.doc) return
|
|
138
|
-
console.log('[updateState.selection] Starting selection update')
|
|
139
125
|
const newSelection = state.doc.getSelection()
|
|
140
126
|
if (!newSelection) {
|
|
141
|
-
console.log('[updateState.selection] No selection available')
|
|
142
127
|
return
|
|
143
128
|
}
|
|
144
129
|
|
|
145
130
|
try {
|
|
146
131
|
if (!state.doc.body.contains(newSelection.anchorNode)) {
|
|
147
|
-
console.log('[updateState.selection] Selection outside editor body, refocusing')
|
|
148
132
|
state.doc.body.focus()
|
|
149
133
|
return
|
|
150
134
|
}
|
|
@@ -160,28 +144,20 @@ export function useEditor() {
|
|
|
160
144
|
|| state.range.endOffset !== newSelection.getRangeAt(0).endOffset
|
|
161
145
|
))
|
|
162
146
|
|
|
163
|
-
console.log('[updateState.selection] Selection changed:', hasSelectionChanged)
|
|
164
147
|
if (hasSelectionChanged) {
|
|
165
148
|
state.selection = newSelection
|
|
166
149
|
state.rangeCount = newSelection.rangeCount
|
|
167
150
|
|
|
168
151
|
if (newSelection.rangeCount > 0) {
|
|
169
152
|
state.range = newSelection.getRangeAt(0).cloneRange()
|
|
170
|
-
console.log('[updateState.selection] New range:', {
|
|
171
|
-
startOffset: state.range.startOffset,
|
|
172
|
-
endOffset: state.range.endOffset,
|
|
173
|
-
collapsed: state.range.collapsed
|
|
174
|
-
})
|
|
175
153
|
}
|
|
176
154
|
|
|
177
155
|
// Update styles less frequently
|
|
178
156
|
requestAnimationFrame(() => {
|
|
179
|
-
console.log('[updateState.selection] Updating styles in RAF')
|
|
180
157
|
updateState.styles()
|
|
181
158
|
})
|
|
182
159
|
}
|
|
183
160
|
} catch (e) {
|
|
184
|
-
console.warn('[updateState.selection] Selection error:', e)
|
|
185
161
|
state.selection = null
|
|
186
162
|
state.range = null
|
|
187
163
|
state.rangeCount = 0
|
|
@@ -275,10 +251,8 @@ export function useEditor() {
|
|
|
275
251
|
}
|
|
276
252
|
|
|
277
253
|
function setupEventListeners(doc: Document) {
|
|
278
|
-
console.log('[setupEventListeners] Starting setup')
|
|
279
254
|
// Clean up existing listeners if they exist
|
|
280
255
|
if (cleanupListeners) {
|
|
281
|
-
console.log('[setupEventListeners] Cleaning up existing listeners')
|
|
282
256
|
cleanupListeners()
|
|
283
257
|
cleanupListeners = null
|
|
284
258
|
}
|
|
@@ -291,62 +265,43 @@ export function useEditor() {
|
|
|
291
265
|
const events = {
|
|
292
266
|
input: () => {
|
|
293
267
|
updateCount++
|
|
294
|
-
|
|
295
|
-
if (isUpdating) {
|
|
296
|
-
console.log(`[input event #${updateCount}] Skipped - already updating`)
|
|
297
|
-
return
|
|
298
|
-
}
|
|
268
|
+
if (isUpdating) return
|
|
299
269
|
isUpdating = true
|
|
300
270
|
|
|
301
271
|
// Clear any pending content updates
|
|
302
272
|
if (contentUpdateTimeout) {
|
|
303
|
-
console.log(`[input event #${updateCount}] Clearing previous timeout`)
|
|
304
273
|
window.clearTimeout(contentUpdateTimeout)
|
|
305
274
|
}
|
|
306
275
|
|
|
307
276
|
contentUpdateTimeout = window.setTimeout(() => {
|
|
308
|
-
console.log(`[input event #${updateCount}] Timeout fired`)
|
|
309
277
|
const newContent = doc.body.innerHTML
|
|
310
278
|
if (newContent !== state.content) {
|
|
311
|
-
console.log(`[input event #${updateCount}] Content changed, updating state`)
|
|
312
279
|
state.content = newContent
|
|
313
|
-
} else {
|
|
314
|
-
console.log(`[input event #${updateCount}] Content unchanged`)
|
|
315
280
|
}
|
|
316
281
|
isUpdating = false
|
|
317
282
|
}, 100)
|
|
318
283
|
},
|
|
319
284
|
selectionchange: () => {
|
|
320
285
|
updateCount++
|
|
321
|
-
|
|
322
|
-
if (isUpdating) {
|
|
323
|
-
console.log(`[selectionchange #${updateCount}] Skipped - already updating`)
|
|
324
|
-
return
|
|
325
|
-
}
|
|
286
|
+
if (isUpdating) return
|
|
326
287
|
|
|
327
288
|
if (selectionUpdateTimeout) {
|
|
328
|
-
console.log(`[selectionchange #${updateCount}] Clearing previous timeout`)
|
|
329
289
|
window.clearTimeout(selectionUpdateTimeout)
|
|
330
290
|
}
|
|
331
291
|
|
|
332
292
|
selectionUpdateTimeout = window.setTimeout(() => {
|
|
333
|
-
console.log(`[selectionchange #${updateCount}] Timeout fired`)
|
|
334
293
|
if (!isUpdating) {
|
|
335
294
|
updateState.selection()
|
|
336
|
-
} else {
|
|
337
|
-
console.log(`[selectionchange #${updateCount}] Skipped - still updating`)
|
|
338
295
|
}
|
|
339
296
|
}, 150)
|
|
340
297
|
},
|
|
341
298
|
mouseup: () => {
|
|
342
299
|
updateCount++
|
|
343
|
-
console.log(`[mouseup #${updateCount}] Starting, isUpdating:`, isUpdating)
|
|
344
300
|
if (isUpdating) return
|
|
345
301
|
updateState.selection()
|
|
346
302
|
},
|
|
347
303
|
keyup: (e: KeyboardEvent) => {
|
|
348
304
|
updateCount++
|
|
349
|
-
console.log(`[keyup #${updateCount}] Key:`, e.key, 'isUpdating:', isUpdating)
|
|
350
305
|
if (isUpdating) return
|
|
351
306
|
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
|
|
352
307
|
updateState.selection()
|
|
@@ -357,12 +312,10 @@ export function useEditor() {
|
|
|
357
312
|
// Only add listeners if they haven't been added yet
|
|
358
313
|
Object.entries(events).forEach(([event, handler]) => {
|
|
359
314
|
doc.addEventListener(event, handler as EventListener)
|
|
360
|
-
console.log('[setupEventListeners] Added listener for:', event)
|
|
361
315
|
})
|
|
362
316
|
|
|
363
317
|
// Store cleanup function
|
|
364
318
|
cleanupListeners = () => {
|
|
365
|
-
console.log('[setupEventListeners] Cleaning up event listeners')
|
|
366
319
|
if (contentUpdateTimeout) window.clearTimeout(contentUpdateTimeout)
|
|
367
320
|
if (selectionUpdateTimeout) window.clearTimeout(selectionUpdateTimeout)
|
|
368
321
|
Object.entries(events).forEach(([event, handler]) => {
|
|
@@ -374,9 +327,7 @@ export function useEditor() {
|
|
|
374
327
|
}
|
|
375
328
|
|
|
376
329
|
function init(doc: Document) {
|
|
377
|
-
console.log('[init] Starting initialization')
|
|
378
330
|
if (state.hasInit) {
|
|
379
|
-
console.log('[init] Already initialized, cleaning up first')
|
|
380
331
|
if (cleanupListeners) {
|
|
381
332
|
cleanupListeners()
|
|
382
333
|
cleanupListeners = null
|
|
@@ -32,9 +32,7 @@ onUnmounted(() => {
|
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
async function initEditor() {
|
|
35
|
-
console.log('[initEditor] Starting, isInitializing:', isInitializing.value, 'hasInitialized:', hasInitialized.value)
|
|
36
35
|
if (isInitializing.value || !iframe.value || hasInitialized.value) {
|
|
37
|
-
console.log('[initEditor] Skipped - already initializing/initialized or no iframe')
|
|
38
36
|
return
|
|
39
37
|
}
|
|
40
38
|
|
|
@@ -69,10 +67,7 @@ async function initEditor() {
|
|
|
69
67
|
|
|
70
68
|
// Write the complete HTML document to the iframe
|
|
71
69
|
const doc = iframe.value.contentDocument || iframe.value.contentWindow?.document
|
|
72
|
-
if (!doc)
|
|
73
|
-
console.warn('[initEditor] No document found')
|
|
74
|
-
return
|
|
75
|
-
}
|
|
70
|
+
if (!doc) return
|
|
76
71
|
|
|
77
72
|
// First write the content
|
|
78
73
|
doc.open()
|
|
@@ -122,7 +117,8 @@ async function initEditor() {
|
|
|
122
117
|
doc.body.focus()
|
|
123
118
|
hasInitialized.value = true
|
|
124
119
|
} catch (error) {
|
|
125
|
-
|
|
120
|
+
// Keep only this error log for debugging critical issues
|
|
121
|
+
console.error('Error during editor initialization:', error)
|
|
126
122
|
} finally {
|
|
127
123
|
isInitializing.value = false
|
|
128
124
|
}
|
|
@@ -133,7 +129,6 @@ watch(() => props.modelValue, (newValue, oldValue) => {
|
|
|
133
129
|
if (newValue !== editor.state.content) {
|
|
134
130
|
// Only reset if content change is significant (not just minor edits)
|
|
135
131
|
if (!oldValue || Math.abs(newValue.length - oldValue.length) > 50) {
|
|
136
|
-
console.log('[watch] Significant content change, resetting initialization state')
|
|
137
132
|
hasInitialized.value = false
|
|
138
133
|
editor.state.content = newValue
|
|
139
134
|
editor.updateState.content('html')
|
|
@@ -147,6 +142,12 @@ watch(() => editor.state.content, (newValue) => {
|
|
|
147
142
|
}
|
|
148
143
|
emit('update:modelValue', newValue)
|
|
149
144
|
})
|
|
145
|
+
|
|
146
|
+
watch(() => editor.state.isSplitView, (isEnabled) => {
|
|
147
|
+
if (isEnabled) {
|
|
148
|
+
editor.state.content = editor.state.doc?.body.innerHTML || ''
|
|
149
|
+
}
|
|
150
|
+
})
|
|
150
151
|
</script>
|
|
151
152
|
|
|
152
153
|
<template>
|
|
@@ -164,8 +165,8 @@ watch(() => editor.state.content, (newValue) => {
|
|
|
164
165
|
ref="iframe"
|
|
165
166
|
class="editableContent"
|
|
166
167
|
title="Editor"
|
|
168
|
+
srcdoc=""
|
|
167
169
|
sandbox="allow-same-origin allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-scripts allow-top-navigation allow-top-navigation-by-user-activation"
|
|
168
|
-
src="about:blank"
|
|
169
170
|
@load="initEditor"
|
|
170
171
|
/>
|
|
171
172
|
</div>
|
|
@@ -173,6 +174,7 @@ watch(() => editor.state.content, (newValue) => {
|
|
|
173
174
|
v-if="editor.state.isSplitView"
|
|
174
175
|
v-model="editor.state.content"
|
|
175
176
|
language="html"
|
|
177
|
+
class="code-editor"
|
|
176
178
|
@update:modelValue="editor.updateState.content('html')"
|
|
177
179
|
/>
|
|
178
180
|
</div>
|
|
@@ -198,7 +200,13 @@ watch(() => editor.state.content, (newValue) => {
|
|
|
198
200
|
.content-area p,
|
|
199
201
|
.content-area span,
|
|
200
202
|
.content-area li{
|
|
201
|
-
line-height: 1.65;
|
|
203
|
+
line-height: 1.65;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.code-editor {
|
|
207
|
+
flex: 1;
|
|
208
|
+
min-height: 240px !important;
|
|
209
|
+
height: 100%;
|
|
202
210
|
}
|
|
203
211
|
</style>
|
|
204
212
|
|