slate-react 0.124.2 → 0.125.1-20260630183125
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/hooks/use-decorations.d.ts.map +1 -1
- package/dist/index.es.js +16 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +20 -0
- package/dist/slate-react.min.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-decorations.d.ts","sourceRoot":"","sources":["../../../../packages/slate-react/src/hooks/use-decorations.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"use-decorations.d.ts","sourceRoot":"","sources":["../../../../packages/slate-react/src/hooks/use-decorations.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAQ,SAAS,EAAE,MAAM,OAAO,CAAA;AAOnE,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAA;AAE1B;;;GAGG;AAEH,eAAO,MAAM,eAAe;oCACM,cAAc,EAAE;iCACnB,QAAQ,KAAK,MAAM,IAAI;EACzC,CAAA;AAEb,eAAO,MAAM,cAAc,SACnB,UAAU,qBACG,cAAc,EAAE,KAClC,cAAc,EA0BhB,CAAA;AAED,eAAO,MAAM,kBAAkB,uCACO,cAAc,EAAE;;iCAkCJ,QAAQ;CAYzD,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -1150,11 +1150,27 @@ var useDecorations = (node, parentDecorations) => {
|
|
|
1150
1150
|
return useMemo(() => [...decorations, ...parentDecorations], [decorations, parentDecorations]);
|
|
1151
1151
|
};
|
|
1152
1152
|
var useDecorateContext = decorateProp => {
|
|
1153
|
+
var [, forceUpdate] = useReducer(s => s + 1, 0);
|
|
1153
1154
|
var eventListeners = useRef(new Set());
|
|
1155
|
+
var hasMounted = useRef(false);
|
|
1154
1156
|
var latestDecorate = useRef(decorateProp);
|
|
1155
1157
|
useIsomorphicLayoutEffect(() => {
|
|
1156
1158
|
latestDecorate.current = decorateProp;
|
|
1157
1159
|
eventListeners.current.forEach(listener => listener());
|
|
1160
|
+
// Skip the forced re-render on the initial mount: there is no committed
|
|
1161
|
+
// DOM to restore the selection against yet, and forcing an extra render
|
|
1162
|
+
// here breaks contenteditable input in Firefox. Only later decoration
|
|
1163
|
+
// changes need to re-render Editable in the same batch as the text
|
|
1164
|
+
// components notified above, so its selection-restoration layout effect
|
|
1165
|
+
// runs after the decoration-induced DOM changes are committed. Without
|
|
1166
|
+
// that, the text components restructure the DOM in a separate pass where
|
|
1167
|
+
// Editable's layout effect never fires, potentially leaving the caret at
|
|
1168
|
+
// a wrong position.
|
|
1169
|
+
if (!hasMounted.current) {
|
|
1170
|
+
hasMounted.current = true;
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
forceUpdate();
|
|
1158
1174
|
}, [decorateProp]);
|
|
1159
1175
|
var decorate = useCallback(entry => latestDecorate.current(entry), []);
|
|
1160
1176
|
var addEventListener = useCallback(callback => {
|