slate-react 0.82.1 → 0.82.2-2022864247
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/components/element.d.ts.map +1 -1
- package/dist/index.es.js +15 -16
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +14 -15
- package/dist/slate-react.min.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/element.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,EAAgB,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,OAAO,CAAA;AAapE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAEnB;;GAEG;AAEH,QAAA,MAAM,OAAO;iBACE,KAAK,EAAE;aACX,YAAY;6BACG,kBAAkB,KAAK,WAAW;+BAC/B,sBAAsB,KAAK,WAAW;0BAC5C,eAAe,KAAK,WAAW;eACzC,KAAK,GAAG,IAAI;iBAuGxB,CAAA;AAED,QAAA,MAAM,eAAe;iBA9GN,KAAK,EAAE;aACX,YAAY;6BACG,kBAAkB,KAAK,WAAW;+BAC/B,sBAAsB,KAAK,WAAW;0BAC5C,eAAe,KAAK,WAAW;eACzC,KAAK,GAAG,IAAI;kBAoHvB,CAAA;AAEF;;GAEG;AAEH,eAAO,MAAM,cAAc,UAAW,kBAAkB,gBASvD,CAAA;AAED,eAAe,eAAe,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import getDirection from 'direction';
|
|
2
2
|
import debounce from 'lodash/debounce';
|
|
3
3
|
import throttle from 'lodash/throttle';
|
|
4
|
-
import React, { useLayoutEffect, useEffect, useRef, createContext, useContext, Component, useState,
|
|
4
|
+
import React, { useLayoutEffect, useEffect, useRef, createContext, useContext, useCallback, Component, useState, useReducer, useMemo } from 'react';
|
|
5
5
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
6
6
|
import { Editor, Scrubber, Transforms, Range, Path, Node, Text as Text$1, Element as Element$1, Point } from 'slate';
|
|
7
7
|
import { isKeyHotkey } from 'is-hotkey';
|
|
@@ -1360,11 +1360,23 @@ var Element = props => {
|
|
|
1360
1360
|
renderLeaf,
|
|
1361
1361
|
selection
|
|
1362
1362
|
} = props;
|
|
1363
|
-
var ref = useRef(null);
|
|
1364
1363
|
var editor = useSlateStatic();
|
|
1365
1364
|
var readOnly = useReadOnly();
|
|
1366
1365
|
var isInline = editor.isInline(element);
|
|
1367
1366
|
var key = ReactEditor.findKey(editor, element);
|
|
1367
|
+
var ref = useCallback(ref => {
|
|
1368
|
+
// Update element-related weak maps with the DOM element ref.
|
|
1369
|
+
var KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
|
|
1370
|
+
|
|
1371
|
+
if (ref) {
|
|
1372
|
+
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT.set(key, ref);
|
|
1373
|
+
NODE_TO_ELEMENT.set(element, ref);
|
|
1374
|
+
ELEMENT_TO_NODE.set(ref, element);
|
|
1375
|
+
} else {
|
|
1376
|
+
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT.delete(key);
|
|
1377
|
+
NODE_TO_ELEMENT.delete(element);
|
|
1378
|
+
}
|
|
1379
|
+
}, [editor, key, element]);
|
|
1368
1380
|
var children = useChildren({
|
|
1369
1381
|
decorations,
|
|
1370
1382
|
node: element,
|
|
@@ -1422,21 +1434,8 @@ var Element = props => {
|
|
|
1422
1434
|
}));
|
|
1423
1435
|
NODE_TO_INDEX.set(_text, 0);
|
|
1424
1436
|
NODE_TO_PARENT.set(_text, element);
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
useIsomorphicLayoutEffect(() => {
|
|
1429
|
-
var KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
|
|
1437
|
+
}
|
|
1430
1438
|
|
|
1431
|
-
if (ref.current) {
|
|
1432
|
-
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT.set(key, ref.current);
|
|
1433
|
-
NODE_TO_ELEMENT.set(element, ref.current);
|
|
1434
|
-
ELEMENT_TO_NODE.set(ref.current, element);
|
|
1435
|
-
} else {
|
|
1436
|
-
KEY_TO_ELEMENT === null || KEY_TO_ELEMENT === void 0 ? void 0 : KEY_TO_ELEMENT.delete(key);
|
|
1437
|
-
NODE_TO_ELEMENT.delete(element);
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
1439
|
return renderElement({
|
|
1441
1440
|
attributes,
|
|
1442
1441
|
children,
|