wysimark-lite 0.17.1 → 0.17.3

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
@@ -966,7 +966,10 @@ function serializeImageShared(image) {
966
966
 
967
967
  // src/convert/serialize/serialize-image-block/index.ts
968
968
  function serializeImageBlock(element) {
969
- return serializeImageShared(element);
969
+ const imageMarkdown = serializeImageShared(element);
970
+ return imageMarkdown ? `${imageMarkdown}
971
+
972
+ ` : "";
970
973
  }
971
974
 
972
975
  // src/convert/serialize/serialize-line/serialize-line.ts
@@ -8660,6 +8663,7 @@ function Editable2({
8660
8663
  const ignoreNextChangeRef = useRef13(false);
8661
8664
  const initialValueRef = useRef13(void 0);
8662
8665
  const prevValueRef = useRef13(void 0);
8666
+ const lastEmittedValueRef = useRef13(void 0);
8663
8667
  const onThrottledSlateChange = useCallback16(
8664
8668
  throttle3(
8665
8669
  () => {
@@ -8668,6 +8672,7 @@ function Editable2({
8668
8672
  markdown,
8669
8673
  children: editor.children
8670
8674
  };
8675
+ lastEmittedValueRef.current = markdown;
8671
8676
  onChange(markdown);
8672
8677
  },
8673
8678
  throttleInMs,
@@ -8692,14 +8697,22 @@ function Editable2({
8692
8697
  // Store the original unescaped value
8693
8698
  children
8694
8699
  };
8700
+ lastEmittedValueRef.current = value;
8695
8701
  } else {
8696
- if (value !== editor.wysimark.prevValue.markdown) {
8697
- ignoreNextChangeRef.current = true;
8698
- const valueToProcess = isRawMode ? value : escapeUrlSlashes(value);
8699
- const documentValue = parse(valueToProcess);
8700
- editor.children = documentValue;
8701
- editor.selection = null;
8702
- Transforms45.select(editor, Editor63.start(editor, [0]));
8702
+ if (isRawMode) {
8703
+ editor.wysimark.prevValue.markdown = value;
8704
+ lastEmittedValueRef.current = value;
8705
+ } else {
8706
+ const diffFromPrevValue = value !== editor.wysimark.prevValue.markdown;
8707
+ const diffFromLastEmitted = value !== lastEmittedValueRef.current;
8708
+ if (diffFromPrevValue && diffFromLastEmitted) {
8709
+ ignoreNextChangeRef.current = true;
8710
+ const valueToProcess = escapeUrlSlashes(value);
8711
+ const documentValue = parse(valueToProcess);
8712
+ editor.children = documentValue;
8713
+ editor.selection = null;
8714
+ Transforms45.select(editor, Editor63.start(editor, [0]));
8715
+ }
8703
8716
  }
8704
8717
  }
8705
8718
  const onSinkeEditableMouseDown = useCallback16(() => {
@@ -8721,9 +8734,8 @@ function Editable2({
8721
8734
  }
8722
8735
  }, [editor, rawText]);
8723
8736
  const updateRawTextFromEditor = useCallback16(() => {
8724
- const currentMarkdown = editor.getMarkdown();
8725
- setRawText(currentMarkdown);
8726
- }, [editor]);
8737
+ setRawText(value);
8738
+ }, [value]);
8727
8739
  const handleRawModeToggle = useCallback16(() => {
8728
8740
  if (isRawMode) {
8729
8741
  applyRawTextToEditor();