mdwysiwyg 0.5.0 → 0.6.0

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/README.md CHANGED
@@ -141,7 +141,7 @@ Try it in your browser, no install required: **[ferkiernan.github.io/mdwysiwyg](
141
141
  | Sizing | Fixed (`width`/`height` props), user-resizable (`resizable`, default on) or growing with its content (`autoHeight`: no inner vertical scrollbar, `height` becomes the minimum) |
142
142
  | Toolbar | Shown by default; hide/show it at runtime with `showToolbar` (no content, caret or undo loss), or only while the editor has focus with `autoHideBar` |
143
143
  | Version history | Opt-in `historyUndo`: a version is saved after 3 s without changes; a clock icon right after the HTML button opens a history mode with ← Undo / Redo →, Confirm / Cancel (back to last version) and a right-hand list of versions with their time (click one to jump to it; document read-only while browsing; `Ctrl+Z` / `Ctrl+Shift+Z` map to Undo / Redo) |
144
- | Compare mode | `mode="compare"` + `compareOrientation` (`side-to-side` / `up-and-down`) + `compareContent`: read-only original next to an editable new version with changed words highlighted in yellow, and a second bar to accept, reject or restore the change (`onCompareDecision`) |
144
+ | Compare mode | `mode="compare"` + `compareContent` (+ optional `compareOrientation`: `side-to-side` by default, or `up-and-down`): read-only original next to an editable new version with changed words highlighted in yellow, and a second bar to accept, reject or restore the change (`onCompareDecision`) |
145
145
  | Compare scroll sync | In compare mode the two panes follow each other by matching content (top edge ↔ top edge; added/removed passages are crossed proportionally; vertical only). On by default; turn it off with `compareSyncScroll={false}` |
146
146
  | Theming | 47 CSS Custom Properties (`--mdw-*`) covering toolbar, content, tables, code and syntax highlighting, quotes, menus/dialogs, compare highlight and scrollbars; declare them on your class, a wrapper or `:root`, in any load order — see the [theming guide](https://github.com/ferkiernan/mdwysiwyg/blob/master/docs/THEMING.md) |
147
147
  | Imperative API | `ref` exposing `reset()`, `isModified()`, `insertMarkdown()` and `setMarkdown()` |
package/dist/index.cjs CHANGED
@@ -5432,7 +5432,7 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
5432
5432
  compareSyncScroll = true
5433
5433
  }, ref) {
5434
5434
  const historyEntryRef = (0, import_react19.useRef)(null);
5435
- const requestedContent = mode === "compare" && compareOrientation !== void 0 && compareContent !== void 0 ? compareContent : null;
5435
+ const requestedContent = mode === "compare" && compareContent !== void 0 ? compareContent : null;
5436
5436
  const [source, setSource] = (0, import_react19.useState)(requestedContent ?? initialContent);
5437
5437
  const [compareState, setCompareState] = (0, import_react19.useState)(
5438
5438
  () => requestedContent === null ? { key: null, session: null } : {
@@ -5672,8 +5672,16 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
5672
5672
  };
5673
5673
  const appliedSessionRef = (0, import_react19.useRef)(session);
5674
5674
  const canonicalForRef = (0, import_react19.useRef)(null);
5675
+ const decidedRef = (0, import_react19.useRef)(false);
5675
5676
  (0, import_react19.useLayoutEffect)(() => {
5676
5677
  if (session === null) {
5678
+ const ended = appliedSessionRef.current;
5679
+ if (ended !== null && !decidedRef.current && editor !== null) {
5680
+ const changed = sourceRef.current !== ended.original;
5681
+ loadContent(ended.original);
5682
+ if (changed) onChangeRef.current?.(ended.original);
5683
+ }
5684
+ decidedRef.current = false;
5677
5685
  appliedSessionRef.current = null;
5678
5686
  canonicalForRef.current = null;
5679
5687
  setProvidedCanonical(null);
@@ -5718,6 +5726,7 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
5718
5726
  const summary = session === null ? NO_DIFFERENCES2 : textDiff?.summary ?? renderedSummary;
5719
5727
  const modified = session !== null && source !== session.provided && source !== providedCanonical;
5720
5728
  const endCompare = () => {
5729
+ decidedRef.current = true;
5721
5730
  sessionRef.current = null;
5722
5731
  setCompareState((previous) => ({ ...previous, session: null }));
5723
5732
  };