@kaitify/core 0.0.2-beta.16 → 0.0.2-beta.17

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.
@@ -2978,7 +2978,20 @@ const formatPlaceholderMerge = ({ editor, node }) => {
2978
2978
  };
2979
2979
  const formatLineBreakSpaceText = ({ editor, node }) => {
2980
2980
  if (node.isText() && !node.isEmpty()) {
2981
- node.textContent = node.textContent.replace(/\r\n/g, "\n").replace(/\u00A0/g, " ").replace(/\uFEFF/g, getZeroWidthText());
2981
+ const originalText = node.textContent;
2982
+ node.textContent = originalText.replace(/\r\n/g, "\n").replace(/\u00A0/g, " ").replace(/\uFEFF/g, getZeroWidthText());
2983
+ if (editor.selection.focused()) {
2984
+ if (editor.selection.start.node.isEqual(node)) {
2985
+ const preText = originalText.slice(0, editor.selection.start.offset);
2986
+ const crlfCount = (preText.match(/\r\n/g) || []).length;
2987
+ editor.selection.start.offset -= crlfCount;
2988
+ }
2989
+ if (editor.selection.end.node.isEqual(node)) {
2990
+ const preText = originalText.slice(0, editor.selection.end.offset);
2991
+ const crlfCount = (preText.match(/\r\n/g) || []).length;
2992
+ editor.selection.end.offset -= crlfCount;
2993
+ }
2994
+ }
2982
2995
  let startPrevNumber = 0;
2983
2996
  let endPrevNumber = 0;
2984
2997
  const regExp = new RegExp(`\\n(?!${getZeroWidthText()})`, "g");