@trafica/editor 1.0.18 → 1.0.20
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/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles/editor.css +6 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7881,6 +7881,11 @@ function EditorCore({
|
|
|
7881
7881
|
onJSONChange(jsonSerializer.serialize(state.doc));
|
|
7882
7882
|
}
|
|
7883
7883
|
}, [state.doc]);
|
|
7884
|
+
react.useLayoutEffect(() => {
|
|
7885
|
+
const container = containerRef.current;
|
|
7886
|
+
if (!container || !state.selection) return;
|
|
7887
|
+
restoreSelection(container, state.selection);
|
|
7888
|
+
}, [state.selection]);
|
|
7884
7889
|
react.useEffect(() => {
|
|
7885
7890
|
const container = containerRef.current;
|
|
7886
7891
|
if (!container || readOnly) return;
|
|
@@ -7908,6 +7913,30 @@ function EditorCore({
|
|
|
7908
7913
|
}
|
|
7909
7914
|
}
|
|
7910
7915
|
}, [tableSelection, state.doc]);
|
|
7916
|
+
react.useEffect(() => {
|
|
7917
|
+
const container = containerRef.current;
|
|
7918
|
+
if (!container) return;
|
|
7919
|
+
container.querySelectorAll(".editor-cell-active").forEach((el) => {
|
|
7920
|
+
el.classList.remove("editor-cell-active");
|
|
7921
|
+
});
|
|
7922
|
+
if (!inTableCellPos) {
|
|
7923
|
+
setTableSelection(null);
|
|
7924
|
+
return;
|
|
7925
|
+
}
|
|
7926
|
+
if (tableSelection) {
|
|
7927
|
+
const { anchorCell, focusCell, tablePath } = tableSelection;
|
|
7928
|
+
const sameTable = JSON.stringify(tablePath) === JSON.stringify(inTableCellPos.tablePath);
|
|
7929
|
+
const singleCell = anchorCell[0] === focusCell[0] && anchorCell[1] === focusCell[1];
|
|
7930
|
+
if (!sameTable || singleCell) {
|
|
7931
|
+
setTableSelection(null);
|
|
7932
|
+
}
|
|
7933
|
+
}
|
|
7934
|
+
const cellPath = [...inTableCellPos.tablePath, inTableCellPos.row, inTableCellPos.col];
|
|
7935
|
+
const td = container.querySelector(
|
|
7936
|
+
`[data-block-path="${JSON.stringify(cellPath)}"]`
|
|
7937
|
+
);
|
|
7938
|
+
if (td) td.classList.add("editor-cell-active");
|
|
7939
|
+
}, [inTableCellPos, state.doc]);
|
|
7911
7940
|
react.useEffect(() => {
|
|
7912
7941
|
const onSelectionChange = () => {
|
|
7913
7942
|
if (isRenderingRef.current) return;
|
|
@@ -8018,6 +8047,9 @@ function EditorCore({
|
|
|
8018
8047
|
}
|
|
8019
8048
|
return;
|
|
8020
8049
|
}
|
|
8050
|
+
if (findCellPosition(doc, sel.anchor.path)) {
|
|
8051
|
+
e.preventDefault();
|
|
8052
|
+
}
|
|
8021
8053
|
}
|
|
8022
8054
|
}
|
|
8023
8055
|
const handled = engine.handleKeyDown(
|
|
@@ -8551,7 +8583,7 @@ function leafTextNode(el, end) {
|
|
|
8551
8583
|
function prettyPrintHTML(html) {
|
|
8552
8584
|
const blockOpen = new RegExp(`(<(?:${BLOCK_TAGS})(?:\\s[^>]*)?>)`, "gi");
|
|
8553
8585
|
const blockClose = new RegExp(`(<\\/(?:${BLOCK_TAGS})>)`, "gi");
|
|
8554
|
-
const spread = html.replace(blockOpen, "\n$1
|
|
8586
|
+
const spread = html.replace(blockOpen, "\n$1").replace(blockClose, "$1\n").replace(/<hr(\s[^>]*)?\/?>(\s*)/gi, "\n<hr />\n");
|
|
8555
8587
|
let depth = 0;
|
|
8556
8588
|
const result = [];
|
|
8557
8589
|
for (const raw of spread.split("\n")) {
|