@mdxeditor/editor 1.13.1 → 1.13.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.
@@ -14,6 +14,7 @@ const DiffViewer = () => {
14
14
  const CmMergeView = ({ oldMarkdown, newMarkdown, onUpdate }) => {
15
15
  const cmMergeViewRef = React__default.useRef(null);
16
16
  const [cmExtensions] = diffSourcePluginHooks.useEmitterValues("cmExtensions");
17
+ const triggerOnBlur = corePluginHooks.usePublisher("onBlur");
17
18
  const ref = React__default.useCallback(
18
19
  (el) => {
19
20
  var _a;
@@ -41,6 +42,12 @@ const CmMergeView = ({ oldMarkdown, newMarkdown, onUpdate }) => {
41
42
  EditorView.updateListener.of(({ state }) => {
42
43
  const md = state.doc.toString();
43
44
  onUpdate(md);
45
+ }),
46
+ EditorView.focusChangeEffect.of((_, focused) => {
47
+ if (!focused) {
48
+ triggerOnBlur(new FocusEvent("blur"));
49
+ }
50
+ return null;
44
51
  })
45
52
  ]
46
53
  }
@@ -50,7 +57,7 @@ const CmMergeView = ({ oldMarkdown, newMarkdown, onUpdate }) => {
50
57
  cmMergeViewRef.current = null;
51
58
  }
52
59
  },
53
- [newMarkdown, oldMarkdown, onUpdate, cmExtensions]
60
+ [newMarkdown, oldMarkdown, onUpdate, cmExtensions, triggerOnBlur]
54
61
  );
55
62
  return /* @__PURE__ */ React__default.createElement("div", { ref });
56
63
  };
@@ -17,6 +17,7 @@ const SourceEditor = () => {
17
17
  const [markdown2, readOnly] = corePluginHooks.useEmitterValues("markdown", "readOnly");
18
18
  const [cmExtensions] = diffSourcePluginHooks.useEmitterValues("cmExtensions");
19
19
  const updateMarkdown = diffSourcePluginHooks.usePublisher("markdownSourceEditorValue");
20
+ const triggerOnBlur = corePluginHooks.usePublisher("onBlur");
20
21
  const editorViewRef = React__default.useRef(null);
21
22
  const ref = React__default.useCallback(
22
23
  (el) => {
@@ -28,6 +29,12 @@ const SourceEditor = () => {
28
29
  ...COMMON_STATE_CONFIG_EXTENSIONS,
29
30
  EditorView.updateListener.of(({ state }) => {
30
31
  updateMarkdown(state.doc.toString());
32
+ }),
33
+ EditorView.focusChangeEffect.of((_, focused) => {
34
+ if (!focused) {
35
+ triggerOnBlur(new FocusEvent("blur"));
36
+ }
37
+ return null;
31
38
  })
32
39
  ];
33
40
  if (readOnly) {
@@ -43,7 +50,7 @@ const SourceEditor = () => {
43
50
  editorViewRef.current = null;
44
51
  }
45
52
  },
46
- [markdown2, readOnly, updateMarkdown, cmExtensions]
53
+ [markdown2, readOnly, updateMarkdown, cmExtensions, triggerOnBlur]
47
54
  );
48
55
  return /* @__PURE__ */ React__default.createElement("div", { ref, className: "cm-sourceView" });
49
56
  };