@trafica/editor 1.0.18 → 1.0.19

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.mjs CHANGED
@@ -7879,6 +7879,11 @@ function EditorCore({
7879
7879
  onJSONChange(jsonSerializer.serialize(state.doc));
7880
7880
  }
7881
7881
  }, [state.doc]);
7882
+ useLayoutEffect(() => {
7883
+ const container = containerRef.current;
7884
+ if (!container || !state.selection) return;
7885
+ restoreSelection(container, state.selection);
7886
+ }, [state.selection]);
7882
7887
  useEffect(() => {
7883
7888
  const container = containerRef.current;
7884
7889
  if (!container || readOnly) return;
@@ -7906,6 +7911,19 @@ function EditorCore({
7906
7911
  }
7907
7912
  }
7908
7913
  }, [tableSelection, state.doc]);
7914
+ useEffect(() => {
7915
+ const container = containerRef.current;
7916
+ if (!container) return;
7917
+ container.querySelectorAll(".editor-cell-active").forEach((el) => {
7918
+ el.classList.remove("editor-cell-active");
7919
+ });
7920
+ if (!inTableCellPos) return;
7921
+ const cellPath = [...inTableCellPos.tablePath, inTableCellPos.row, inTableCellPos.col];
7922
+ const td = container.querySelector(
7923
+ `[data-block-path="${JSON.stringify(cellPath)}"]`
7924
+ );
7925
+ if (td) td.classList.add("editor-cell-active");
7926
+ }, [inTableCellPos, state.doc]);
7909
7927
  useEffect(() => {
7910
7928
  const onSelectionChange = () => {
7911
7929
  if (isRenderingRef.current) return;
@@ -8016,6 +8034,9 @@ function EditorCore({
8016
8034
  }
8017
8035
  return;
8018
8036
  }
8037
+ if (findCellPosition(doc, sel.anchor.path)) {
8038
+ e.preventDefault();
8039
+ }
8019
8040
  }
8020
8041
  }
8021
8042
  const handled = engine.handleKeyDown(
@@ -8549,7 +8570,7 @@ function leafTextNode(el, end) {
8549
8570
  function prettyPrintHTML(html) {
8550
8571
  const blockOpen = new RegExp(`(<(?:${BLOCK_TAGS})(?:\\s[^>]*)?>)`, "gi");
8551
8572
  const blockClose = new RegExp(`(<\\/(?:${BLOCK_TAGS})>)`, "gi");
8552
- const spread = html.replace(blockOpen, "\n$1\n").replace(blockClose, "\n$1\n").replace(/<hr(\s[^>]*)?\/?>(\s*)/gi, "\n<hr />\n");
8573
+ const spread = html.replace(blockOpen, "\n$1").replace(blockClose, "$1\n").replace(/<hr(\s[^>]*)?\/?>(\s*)/gi, "\n<hr />\n");
8553
8574
  let depth = 0;
8554
8575
  const result = [];
8555
8576
  for (const raw of spread.split("\n")) {