@fileverse-dev/fortune-react 1.3.13-create-3 → 1.3.13-create-4

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.
@@ -9,14 +9,18 @@ exports.decrementColumn = decrementColumn;
9
9
  exports.decrementRow = decrementRow;
10
10
  exports.getCursorPosition = getCursorPosition;
11
11
  exports.getFunctionNameFromFormulaCaretSpans = getFunctionNameFromFormulaCaretSpans;
12
+ exports.getSelectionOffsets = getSelectionOffsets;
12
13
  exports.incrementColumn = incrementColumn;
13
14
  exports.incrementRow = incrementRow;
15
+ exports.isEditorUndoRedoKeyEvent = isEditorUndoRedoKeyEvent;
14
16
  exports.isLetterNumberPattern = isLetterNumberPattern;
15
17
  exports.moveCursorToEnd = moveCursorToEnd;
16
18
  exports.numberToColumn = numberToColumn;
17
19
  exports.removeLastSpan = removeLastSpan;
18
20
  exports.setCursorPosition = setCursorPosition;
21
+ exports.setSelectionOffsets = setSelectionOffsets;
19
22
  exports.shouldShowFormulaFunctionList = shouldShowFormulaFunctionList;
23
+ exports.shouldUseCustomEditorHistory = shouldUseCustomEditorHistory;
20
24
  function moveCursorToEnd(editableDiv) {
21
25
  editableDiv.focus();
22
26
  var range = document.createRange();
@@ -37,6 +41,44 @@ function getCursorPosition(editableDiv) {
37
41
  preRange.setEnd(range.endContainer, range.endOffset);
38
42
  return preRange.toString().length;
39
43
  }
44
+ function getSelectionOffsets(editableDiv) {
45
+ var selection = window.getSelection();
46
+ if (!selection || selection.rangeCount === 0) {
47
+ var caret = getCursorPosition(editableDiv);
48
+ return {
49
+ start: caret,
50
+ end: caret
51
+ };
52
+ }
53
+ var range = selection.getRangeAt(0);
54
+ if (!editableDiv.contains(range.startContainer) || !editableDiv.contains(range.endContainer)) {
55
+ var caret = getCursorPosition(editableDiv);
56
+ return {
57
+ start: caret,
58
+ end: caret
59
+ };
60
+ }
61
+ var startRange = range.cloneRange();
62
+ startRange.selectNodeContents(editableDiv);
63
+ startRange.setEnd(range.startContainer, range.startOffset);
64
+ var start = startRange.toString().length;
65
+ var endRange = range.cloneRange();
66
+ endRange.selectNodeContents(editableDiv);
67
+ endRange.setEnd(range.endContainer, range.endOffset);
68
+ var end = endRange.toString().length;
69
+ return {
70
+ start: Math.max(0, Math.min(start, end)),
71
+ end: Math.max(start, end)
72
+ };
73
+ }
74
+ function isEditorUndoRedoKeyEvent(e) {
75
+ if (!e.metaKey && !e.ctrlKey) return false;
76
+ if (e.code === "KeyZ" || e.code === "KeyY") return true;
77
+ return e.keyCode === 90 || e.keyCode === 89;
78
+ }
79
+ function shouldUseCustomEditorHistory(editorInnerTextTrimmed, historyActive) {
80
+ return historyActive || editorInnerTextTrimmed.length > 0;
81
+ }
40
82
  function setCursorPosition(editableDiv, targetOffset) {
41
83
  var _a, _b;
42
84
  editableDiv.focus();
@@ -63,6 +105,43 @@ function setCursorPosition(editableDiv, targetOffset) {
63
105
  selection.removeAllRanges();
64
106
  selection.addRange(range);
65
107
  }
108
+ function setSelectionOffsets(editableDiv, startOffset, endOffset) {
109
+ editableDiv.focus();
110
+ var selection = window.getSelection();
111
+ if (!selection) return;
112
+ var startTarget = Math.max(0, Math.min(startOffset, endOffset));
113
+ var endTarget = Math.max(startTarget, endOffset);
114
+ var walker = document.createTreeWalker(editableDiv, NodeFilter.SHOW_TEXT);
115
+ var resolve = function resolve(target) {
116
+ var _a, _b;
117
+ var remaining = target;
118
+ var node = walker.nextNode();
119
+ while (node) {
120
+ var len = (_b = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
121
+ if (remaining <= len) return {
122
+ node: node,
123
+ offset: remaining
124
+ };
125
+ remaining -= len;
126
+ node = walker.nextNode();
127
+ }
128
+ return null;
129
+ };
130
+ walker.currentNode = editableDiv;
131
+ var startPos = resolve(startTarget);
132
+ walker.currentNode = editableDiv;
133
+ var endPos = resolve(endTarget);
134
+ var range = document.createRange();
135
+ if (startPos && endPos) {
136
+ range.setStart(startPos.node, startPos.offset);
137
+ range.setEnd(endPos.node, endPos.offset);
138
+ } else {
139
+ range.selectNodeContents(editableDiv);
140
+ range.collapse(false);
141
+ }
142
+ selection.removeAllRanges();
143
+ selection.addRange(range);
144
+ }
66
145
  function buildFormulaSuggestionText(editableDiv, formulaName) {
67
146
  var fullText = editableDiv.innerText || "";
68
147
  var selection = window.getSelection();
@@ -19,8 +19,9 @@ var ColorPicker = function ColorPicker(_a) {
19
19
  return /*#__PURE__*/_react.default.createElement("div", {
20
20
  key: c,
21
21
  className: "fortune-toolbar-color-picker-item",
22
- onClick: function onClick() {
23
- return onPick(c);
22
+ onMouseDown: function onMouseDown(e) {
23
+ e.preventDefault();
24
+ onPick(c);
24
25
  },
25
26
  tabIndex: 0,
26
27
  style: {
@@ -13,11 +13,15 @@ var CustomColor = exports.CustomColor = function CustomColor(_a) {
13
13
  var onCustomPick = _a.onCustomPick,
14
14
  onColorPick = _a.onColorPick;
15
15
  return /*#__PURE__*/_react.default.createElement("div", {
16
- id: "fortune-custom-color"
16
+ id: "fortune-custom-color",
17
+ onMouseDown: function onMouseDown(e) {
18
+ e.preventDefault();
19
+ }
17
20
  }, /*#__PURE__*/_react.default.createElement("div", {
18
21
  className: "color-reset",
19
- onClick: function onClick() {
20
- return onCustomPick(undefined);
22
+ onMouseDown: function onMouseDown(e) {
23
+ e.preventDefault();
24
+ onCustomPick(undefined);
21
25
  },
22
26
  tabIndex: 0
23
27
  }, /*#__PURE__*/_react.default.createElement(_SVGIcon.default, {
@@ -472,6 +472,14 @@ var Toolbar = function Toolbar(_a) {
472
472
  settings = _f.settings,
473
473
  handleUndo = _f.handleUndo,
474
474
  handleRedo = _f.handleRedo;
475
+ var restoreEditorFocusAfterToolbarAction = (0, _react.useCallback)(function () {
476
+ if (context.luckysheetCellUpdate.length === 0) return;
477
+ requestAnimationFrame(function () {
478
+ var owner = (0, _fortuneCore.getFormulaEditorOwner)(context);
479
+ var target = owner === "fx" ? refs.fxInput.current : refs.cellInput.current;
480
+ target === null || target === void 0 ? void 0 : target.focus();
481
+ });
482
+ }, [context, refs.cellInput, refs.fxInput]);
475
483
  var contextRef = (0, _react.useRef)(context);
476
484
  var containerRef = (0, _react.useRef)(null);
477
485
  var _g = (0, _react.useState)(-1),
@@ -1721,7 +1729,8 @@ var Toolbar = function Toolbar(_a) {
1721
1729
  return /*#__PURE__*/_react.default.createElement("div", {
1722
1730
  ref: containerRef,
1723
1731
  className: "fortune-toolbar",
1724
- "aria-label": toolbar.toolbar
1732
+ "aria-label": toolbar.toolbar,
1733
+ onMouseUpCapture: restoreEditorFocusAfterToolbarAction
1725
1734
  }, /*#__PURE__*/_react.default.createElement(_dataVerificationPortal.default, {
1726
1735
  visible: showDataValidation
1727
1736
  }), /*#__PURE__*/_react.default.createElement(_conditionalFormatPortal.default, {
@@ -2,22 +2,22 @@ import { type RefObject } from "react";
2
2
  import { type Context } from "@fileverse-dev/fortune-core";
3
3
  import type { SetContextOptions } from "../context";
4
4
  export type FormulaHistoryEntry = {
5
- text: string;
5
+ html: string;
6
6
  caret: number;
7
- spanValues: string[];
8
7
  };
9
8
  export type FormulaEditorHistoryPrimary = "cell" | "fx";
10
9
  type SetContext = (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
11
- export declare function useFormulaEditorHistory(primaryRef: RefObject<HTMLDivElement | null>, cellInputRef: RefObject<HTMLDivElement | null>, fxInputRef: RefObject<HTMLDivElement | null>, setContext: SetContext, primary: FormulaEditorHistoryPrimary): {
10
+ export declare function useFormulaEditorHistory(primaryRef: RefObject<HTMLDivElement | null>, cellInputRef: RefObject<HTMLDivElement | null>, fxInputRef: RefObject<HTMLDivElement | null>, _setContext: SetContext, primary: FormulaEditorHistoryPrimary): {
12
11
  formulaHistoryRef: RefObject<{
13
12
  active: boolean;
14
13
  entries: FormulaHistoryEntry[];
15
14
  index: number;
16
15
  }>;
17
16
  preTextRef: RefObject<string>;
18
- preFormulaSpanValuesRef: RefObject<string[] | null>;
19
17
  resetFormulaHistory: () => void;
20
18
  handleFormulaHistoryUndoRedo: (isRedo: boolean) => boolean;
19
+ capturePreEditorHistoryState: () => void;
20
+ appendEditorHistoryFromPrimaryEditor: (getCaret: () => number) => void;
21
21
  capturePreFormulaState: () => void;
22
22
  appendFormulaHistoryFromPrimaryEditor: (getCaret: () => number) => void;
23
23
  };
@@ -5,50 +5,79 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useFormulaEditorHistory = useFormulaEditorHistory;
7
7
  var _react = require("react");
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
8
  var _fortuneCore = require("@fileverse-dev/fortune-core");
10
9
  var _helper = require("../components/SheetOverlay/helper");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
10
  var MAX_FORMULA_HISTORY = 100;
13
- function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, setContext, primary) {
11
+ function normalizeEditorHtmlSnapshot(html) {
12
+ var stripped = (html !== null && html !== void 0 ? html : "").replace(/\u200B/g, "").trim();
13
+ if (stripped === "" || stripped === "<br>" || stripped === "<div><br></div>" || stripped === "<div></div>") {
14
+ return "";
15
+ }
16
+ return html !== null && html !== void 0 ? html : "";
17
+ }
18
+ function historyForLog(entries, index) {
19
+ return entries.map(function (e, i) {
20
+ var _a, _b;
21
+ return {
22
+ i: i,
23
+ active: i === index,
24
+ len: ((_a = e.html) !== null && _a !== void 0 ? _a : "").length,
25
+ preview: ((_b = e.html) !== null && _b !== void 0 ? _b : "").replace(/\s+/g, " ").slice(0, 24)
26
+ };
27
+ });
28
+ }
29
+ function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, _setContext, primary) {
14
30
  var preTextRef = (0, _react.useRef)("");
15
- var preFormulaSpanValuesRef = (0, _react.useRef)(null);
31
+ var preHtmlRef = (0, _react.useRef)("");
32
+ var preCaretRef = (0, _react.useRef)(0);
33
+ var startedFromEmptyRef = (0, _react.useRef)(true);
16
34
  var formulaHistoryRef = (0, _react.useRef)({
17
35
  active: false,
18
36
  entries: [],
19
37
  index: -1
20
38
  });
39
+ var isApplyingHistoryRef = (0, _react.useRef)(false);
21
40
  var resetFormulaHistory = (0, _react.useCallback)(function () {
22
41
  formulaHistoryRef.current = {
23
42
  active: false,
24
43
  entries: [],
25
44
  index: -1
26
45
  };
27
- preFormulaSpanValuesRef.current = null;
46
+ preHtmlRef.current = "";
47
+ preCaretRef.current = 0;
48
+ startedFromEmptyRef.current = true;
28
49
  }, []);
29
50
  var pushFormulaHistoryEntry = (0, _react.useCallback)(function (entry) {
30
51
  var history = formulaHistoryRef.current;
31
52
  var current = history.entries[history.index];
32
- if (current && current.spanValues.length > 0 && entry.spanValues.length > 0 && _lodash.default.isEqual(current.spanValues, entry.spanValues)) {
33
- return;
34
- }
35
- if (current && current.spanValues.length === 0 && entry.spanValues.length === 0 && current.text === entry.text && current.caret === entry.caret) {
53
+ if (current && current.html === entry.html) {
54
+ console.log("[Hist:pushSkipDuplicate]", {
55
+ currentHtmlLen: current.html.length,
56
+ entryHtmlLen: entry.html.length,
57
+ index: history.index
58
+ });
36
59
  return;
37
60
  }
38
61
  var nextEntries = history.entries.slice(0, history.index + 1);
39
62
  nextEntries.push(entry);
40
- if (nextEntries.length > MAX_FORMULA_HISTORY) {
41
- nextEntries.shift();
42
- }
63
+ if (nextEntries.length > MAX_FORMULA_HISTORY) nextEntries.shift();
43
64
  history.entries = nextEntries;
44
65
  history.index = nextEntries.length - 1;
45
66
  history.active = true;
67
+ console.log("[Hist:push]", {
68
+ htmlLen: entry.html.length,
69
+ caret: entry.caret,
70
+ entriesLen: history.entries.length,
71
+ index: history.index,
72
+ entries: historyForLog(history.entries, history.index)
73
+ });
46
74
  }, []);
47
- var applyFormulaHistoryEntry = (0, _react.useCallback)(function (entry) {
75
+ var applyFormulaHistoryEntry = (0, _react.useCallback)(function (entry, preserveSelection) {
76
+ var _a, _b, _c, _d, _e;
48
77
  var primaryEl = primaryRef.current;
49
78
  if (!primaryEl) return;
50
- var safeText = (0, _fortuneCore.escapeScriptTag)(entry.text || "");
51
- var html = safeText.startsWith("=") ? (0, _fortuneCore.functionHTMLGenerate)(safeText) : (0, _fortuneCore.escapeHTMLTag)(safeText);
79
+ isApplyingHistoryRef.current = true;
80
+ var html = (0, _fortuneCore.escapeScriptTag)((_a = entry.html) !== null && _a !== void 0 ? _a : "");
52
81
  var cell = cellInputRef.current;
53
82
  var fx = fxInputRef.current;
54
83
  primaryEl.innerHTML = html;
@@ -57,70 +86,142 @@ function useFormulaEditorHistory(primaryRef, cellInputRef, fxInputRef, setContex
57
86
  } else if (cell) {
58
87
  cell.innerHTML = html;
59
88
  }
60
- (0, _helper.setCursorPosition)(primaryEl, Math.min(entry.caret, entry.text.length));
61
- setContext(function (draftCtx) {
62
- if (primary === "cell") {
63
- if (!cellInputRef.current) return;
64
- (0, _fortuneCore.handleFormulaInput)(draftCtx, fxInputRef.current, cellInputRef.current, 0);
65
- } else {
66
- if (!fxInputRef.current) return;
67
- (0, _fortuneCore.handleFormulaInput)(draftCtx, cellInputRef.current, fxInputRef.current, 0);
68
- }
89
+ var textLen = (_c = (_b = primaryEl.innerText) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
90
+ if (preserveSelection && preserveSelection.end > preserveSelection.start && textLen > 0) {
91
+ var start = Math.max(0, Math.min(preserveSelection.start, textLen));
92
+ var end = Math.max(start, Math.min(preserveSelection.end, textLen));
93
+ (0, _helper.setSelectionOffsets)(primaryEl, start, end);
94
+ } else {
95
+ (0, _helper.setCursorPosition)(primaryEl, Math.max(0, textLen));
96
+ }
97
+ console.log("[Hist:apply]", {
98
+ entryHtmlLen: ((_d = entry.html) !== null && _d !== void 0 ? _d : "").length,
99
+ afterHtmlLen: ((_e = primaryEl.innerHTML) !== null && _e !== void 0 ? _e : "").length,
100
+ afterTextLen: textLen
101
+ });
102
+ requestAnimationFrame(function () {
103
+ requestAnimationFrame(function () {
104
+ setTimeout(function () {
105
+ isApplyingHistoryRef.current = false;
106
+ }, 120);
107
+ });
69
108
  });
70
- }, [cellInputRef, fxInputRef, primary, primaryRef, setContext]);
109
+ }, [cellInputRef, fxInputRef, primary, primaryRef]);
71
110
  var handleFormulaHistoryUndoRedo = (0, _react.useCallback)(function (isRedo) {
111
+ var _a, _b, _c, _d;
72
112
  var history = formulaHistoryRef.current;
73
113
  if (!history.active || history.entries.length === 0) return false;
74
114
  var nextIndex = isRedo ? history.index + 1 : history.index - 1;
75
- if (nextIndex < 0 || nextIndex >= history.entries.length) return true;
115
+ if (nextIndex < 0 || nextIndex >= history.entries.length) {
116
+ console.log("[Hist:undoRedoBoundary]", {
117
+ isRedo: isRedo,
118
+ index: history.index,
119
+ entriesLen: history.entries.length,
120
+ nextIndex: nextIndex,
121
+ startedFromEmpty: startedFromEmptyRef.current,
122
+ liveHtmlLen: normalizeEditorHtmlSnapshot((_b = (_a = primaryRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML) !== null && _b !== void 0 ? _b : "").length,
123
+ entries: historyForLog(history.entries, history.index)
124
+ });
125
+ if (!isRedo && nextIndex < 0 && startedFromEmptyRef.current) {
126
+ var liveHtml = normalizeEditorHtmlSnapshot((_d = (_c = primaryRef.current) === null || _c === void 0 ? void 0 : _c.innerHTML) !== null && _d !== void 0 ? _d : "");
127
+ if (liveHtml !== "") {
128
+ history.entries[0] = {
129
+ html: "",
130
+ caret: 0
131
+ };
132
+ history.index = 0;
133
+ var currentSelection_1 = primaryRef.current ? (0, _helper.getSelectionOffsets)(primaryRef.current) : undefined;
134
+ applyFormulaHistoryEntry(history.entries[0], currentSelection_1);
135
+ console.log("[Hist:undoRedoForcedEmpty]", {
136
+ entriesLen: history.entries.length,
137
+ index: history.index,
138
+ entries: historyForLog(history.entries, history.index)
139
+ });
140
+ return true;
141
+ }
142
+ }
143
+ return false;
144
+ }
76
145
  history.index = nextIndex;
77
- applyFormulaHistoryEntry(history.entries[nextIndex]);
146
+ var entry = history.entries[nextIndex];
147
+ var currentSelection = primaryRef.current ? (0, _helper.getSelectionOffsets)(primaryRef.current) : undefined;
148
+ applyFormulaHistoryEntry(entry, currentSelection);
149
+ console.log("[Hist:undoRedoApplied]", {
150
+ isRedo: isRedo,
151
+ nextIndex: nextIndex,
152
+ entriesLen: history.entries.length,
153
+ entryHtmlLen: entry.html.length,
154
+ entries: historyForLog(history.entries, history.index)
155
+ });
78
156
  return true;
79
- }, [applyFormulaHistoryEntry]);
80
- var capturePreFormulaState = (0, _react.useCallback)(function () {
157
+ }, [applyFormulaHistoryEntry, primaryRef]);
158
+ var capturePreEditorHistoryState = (0, _react.useCallback)(function () {
159
+ var _a, _b, _c;
81
160
  var el = primaryRef.current;
82
161
  if (!el) return;
83
162
  preTextRef.current = el.innerText;
84
- preFormulaSpanValuesRef.current = Array.from(el.querySelectorAll("span.fortune-formula-functionrange-cell")).map(function (node) {
85
- var _a;
86
- return (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
163
+ preHtmlRef.current = el.innerHTML;
164
+ preCaretRef.current = (0, _helper.getCursorPosition)(el);
165
+ if (!formulaHistoryRef.current.active) {
166
+ startedFromEmptyRef.current = normalizeEditorHtmlSnapshot((_a = preHtmlRef.current) !== null && _a !== void 0 ? _a : "") === "";
167
+ }
168
+ console.log("[Hist:capturePre]", {
169
+ preHtmlLen: ((_b = preHtmlRef.current) !== null && _b !== void 0 ? _b : "").length,
170
+ preTextLen: ((_c = preTextRef.current) !== null && _c !== void 0 ? _c : "").length,
171
+ preCaret: preCaretRef.current,
172
+ startedFromEmpty: startedFromEmptyRef.current,
173
+ historyActive: formulaHistoryRef.current.active,
174
+ entriesLen: formulaHistoryRef.current.entries.length,
175
+ index: formulaHistoryRef.current.index
87
176
  });
88
177
  }, [primaryRef]);
89
- var appendFormulaHistoryFromPrimaryEditor = (0, _react.useCallback)(function (getCaret) {
178
+ var appendEditorHistoryFromPrimaryEditor = (0, _react.useCallback)(function (getCaret) {
90
179
  var _a, _b;
180
+ if (isApplyingHistoryRef.current) return;
91
181
  var el = primaryRef.current;
92
182
  if (!el) return;
93
- var currentText = el.innerText || "";
94
- if (currentText.startsWith("=")) {
95
- var caret = getCaret();
96
- var spanValues = Array.from(el.querySelectorAll("span.fortune-formula-functionrange-cell")).map(function (node) {
97
- var _a;
98
- return (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
99
- });
100
- if (!formulaHistoryRef.current.active) {
101
- var seedText = preTextRef.current || "";
102
- pushFormulaHistoryEntry({
103
- text: seedText,
104
- caret: Math.min(caret, seedText.length),
105
- spanValues: (_b = (_a = preFormulaSpanValuesRef.current) !== null && _a !== void 0 ? _a : spanValues) !== null && _b !== void 0 ? _b : []
106
- });
107
- }
183
+ var preHtmlSnapshot = normalizeEditorHtmlSnapshot((_a = preHtmlRef.current) !== null && _a !== void 0 ? _a : "");
184
+ var snapshotHtml = normalizeEditorHtmlSnapshot((_b = el.innerHTML) !== null && _b !== void 0 ? _b : "");
185
+ var caret = getCaret();
186
+ var history = formulaHistoryRef.current;
187
+ var wasInactive = !history.active || history.entries.length === 0;
188
+ console.log("[Hist:appendStart]", {
189
+ preHtmlLen: preHtmlSnapshot.length,
190
+ currentHtmlLen: snapshotHtml.length,
191
+ caret: caret,
192
+ wasInactive: wasInactive,
193
+ historyActive: history.active,
194
+ entriesLen: history.entries.length,
195
+ index: history.index,
196
+ entries: historyForLog(history.entries, history.index)
197
+ });
198
+ if (wasInactive) {
199
+ startedFromEmptyRef.current = preHtmlSnapshot === "";
200
+ var seedHtml = preHtmlSnapshot === snapshotHtml ? "" : preHtmlSnapshot !== null && preHtmlSnapshot !== void 0 ? preHtmlSnapshot : "";
108
201
  pushFormulaHistoryEntry({
109
- text: currentText,
110
- caret: caret,
111
- spanValues: spanValues
202
+ html: seedHtml,
203
+ caret: preCaretRef.current
204
+ });
205
+ } else {
206
+ console.log("[Hist:seedSkippedAlreadyActive]", {
207
+ index: history.index,
208
+ entriesLen: history.entries.length,
209
+ entries: historyForLog(history.entries, history.index)
112
210
  });
113
- } else if (formulaHistoryRef.current.active) {
114
- resetFormulaHistory();
115
211
  }
116
- }, [primaryRef, pushFormulaHistoryEntry, resetFormulaHistory]);
212
+ pushFormulaHistoryEntry({
213
+ html: snapshotHtml,
214
+ caret: caret
215
+ });
216
+ }, [primaryRef, pushFormulaHistoryEntry]);
117
217
  return {
118
218
  formulaHistoryRef: formulaHistoryRef,
119
219
  preTextRef: preTextRef,
120
- preFormulaSpanValuesRef: preFormulaSpanValuesRef,
121
220
  resetFormulaHistory: resetFormulaHistory,
122
221
  handleFormulaHistoryUndoRedo: handleFormulaHistoryUndoRedo,
123
- capturePreFormulaState: capturePreFormulaState,
124
- appendFormulaHistoryFromPrimaryEditor: appendFormulaHistoryFromPrimaryEditor
222
+ capturePreEditorHistoryState: capturePreEditorHistoryState,
223
+ appendEditorHistoryFromPrimaryEditor: appendEditorHistoryFromPrimaryEditor,
224
+ capturePreFormulaState: capturePreEditorHistoryState,
225
+ appendFormulaHistoryFromPrimaryEditor: appendEditorHistoryFromPrimaryEditor
125
226
  };
126
227
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.13-create-3",
3
+ "version": "1.3.13-create-4",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.3.13-create-3",
19
+ "@fileverse-dev/fortune-core": "1.3.13-create-4",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",