slate-react 0.99.0 → 0.100.0-2023920121024
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/slate.d.ts +3 -1
- package/dist/components/slate.d.ts.map +1 -1
- package/dist/index.es.js +17 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +17 -4
- package/dist/slate-react.min.js +1 -1
- package/dist/utils/weak-maps.d.ts +27 -1
- package/dist/utils/weak-maps.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5275,7 +5275,7 @@ function useSelectorContext(editor) {
|
|
|
5275
5275
|
};
|
|
5276
5276
|
}
|
|
5277
5277
|
|
|
5278
|
-
var _excluded = ["editor", "children", "onChange", "initialValue"];
|
|
5278
|
+
var _excluded = ["editor", "children", "onChange", "onSelectionChange", "onValueChange", "initialValue"];
|
|
5279
5279
|
/**
|
|
5280
5280
|
* A wrapper around the provider to handle `onChange` events, because the editor
|
|
5281
5281
|
* is a mutable singleton so it won't ever register as "changed" otherwise.
|
|
@@ -5285,6 +5285,8 @@ var Slate = function Slate(props) {
|
|
|
5285
5285
|
var editor = props.editor,
|
|
5286
5286
|
children = props.children,
|
|
5287
5287
|
onChange = props.onChange,
|
|
5288
|
+
onSelectionChange = props.onSelectionChange,
|
|
5289
|
+
onValueChange = props.onValueChange,
|
|
5288
5290
|
initialValue = props.initialValue,
|
|
5289
5291
|
rest = _objectWithoutProperties(props, _excluded);
|
|
5290
5292
|
|
|
@@ -5312,11 +5314,22 @@ var Slate = function Slate(props) {
|
|
|
5312
5314
|
selectorContext = _useSelectorContext.selectorContext,
|
|
5313
5315
|
handleSelectorChange = _useSelectorContext.onChange;
|
|
5314
5316
|
|
|
5315
|
-
var onContextChange = React.useCallback(function () {
|
|
5317
|
+
var onContextChange = React.useCallback(function (options) {
|
|
5318
|
+
var _options$operation;
|
|
5319
|
+
|
|
5316
5320
|
if (onChange) {
|
|
5317
5321
|
onChange(editor.children);
|
|
5318
5322
|
}
|
|
5319
5323
|
|
|
5324
|
+
switch (options === null || options === void 0 ? void 0 : (_options$operation = options.operation) === null || _options$operation === void 0 ? void 0 : _options$operation.type) {
|
|
5325
|
+
case 'set_selection':
|
|
5326
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(editor.selection);
|
|
5327
|
+
break;
|
|
5328
|
+
|
|
5329
|
+
default:
|
|
5330
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(editor.children);
|
|
5331
|
+
}
|
|
5332
|
+
|
|
5320
5333
|
setContext(function (prevContext) {
|
|
5321
5334
|
return {
|
|
5322
5335
|
v: prevContext.v + 1,
|
|
@@ -5324,7 +5337,7 @@ var Slate = function Slate(props) {
|
|
|
5324
5337
|
};
|
|
5325
5338
|
});
|
|
5326
5339
|
handleSelectorChange(editor);
|
|
5327
|
-
}, [editor, handleSelectorChange, onChange]);
|
|
5340
|
+
}, [editor, handleSelectorChange, onChange, onSelectionChange, onValueChange]);
|
|
5328
5341
|
React.useEffect(function () {
|
|
5329
5342
|
EDITOR_TO_ON_CHANGE.set(editor, onContextChange);
|
|
5330
5343
|
return function () {
|
|
@@ -5822,7 +5835,7 @@ var withReact = function withReact(editor) {
|
|
|
5822
5835
|
var onContextChange = EDITOR_TO_ON_CHANGE.get(e);
|
|
5823
5836
|
|
|
5824
5837
|
if (onContextChange) {
|
|
5825
|
-
onContextChange();
|
|
5838
|
+
onContextChange(options);
|
|
5826
5839
|
}
|
|
5827
5840
|
|
|
5828
5841
|
onChange(options);
|