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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Descendant } from 'slate';
|
|
2
|
+
import { Descendant, Selection } from 'slate';
|
|
3
3
|
import { ReactEditor } from '../plugin/react-editor';
|
|
4
4
|
/**
|
|
5
5
|
* A wrapper around the provider to handle `onChange` events, because the editor
|
|
@@ -10,5 +10,7 @@ export declare const Slate: (props: {
|
|
|
10
10
|
initialValue: Descendant[];
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
onChange?: ((value: Descendant[]) => void) | undefined;
|
|
13
|
+
onSelectionChange?: ((selection: Selection) => void) | undefined;
|
|
14
|
+
onValueChange?: ((value: Descendant[]) => void) | undefined;
|
|
13
15
|
}) => JSX.Element;
|
|
14
16
|
//# sourceMappingURL=slate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slate.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/slate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"slate.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/slate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAqC,SAAS,EAAE,MAAM,OAAO,CAAA;AAShF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;;GAGG;AAEH,eAAO,MAAM,KAAK;YACR,WAAW;kBACL,UAAU,EAAE;cAChB,MAAM,SAAS;wBACN,UAAU,EAAE,KAAK,IAAI;qCACR,SAAS,KAAK,IAAI;6BAC1B,UAAU,EAAE,KAAK,IAAI;iBAyG9C,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -4736,7 +4736,7 @@ function useSelectorContext(editor) {
|
|
|
4736
4736
|
};
|
|
4737
4737
|
}
|
|
4738
4738
|
|
|
4739
|
-
var _excluded = ["editor", "children", "onChange", "initialValue"];
|
|
4739
|
+
var _excluded = ["editor", "children", "onChange", "onSelectionChange", "onValueChange", "initialValue"];
|
|
4740
4740
|
/**
|
|
4741
4741
|
* A wrapper around the provider to handle `onChange` events, because the editor
|
|
4742
4742
|
* is a mutable singleton so it won't ever register as "changed" otherwise.
|
|
@@ -4747,6 +4747,8 @@ var Slate = props => {
|
|
|
4747
4747
|
editor,
|
|
4748
4748
|
children,
|
|
4749
4749
|
onChange,
|
|
4750
|
+
onSelectionChange,
|
|
4751
|
+
onValueChange,
|
|
4750
4752
|
initialValue
|
|
4751
4753
|
} = props,
|
|
4752
4754
|
rest = _objectWithoutProperties(props, _excluded);
|
|
@@ -4771,17 +4773,28 @@ var Slate = props => {
|
|
|
4771
4773
|
selectorContext,
|
|
4772
4774
|
onChange: handleSelectorChange
|
|
4773
4775
|
} = useSelectorContext(editor);
|
|
4774
|
-
var onContextChange = useCallback(
|
|
4776
|
+
var onContextChange = useCallback(options => {
|
|
4777
|
+
var _options$operation;
|
|
4778
|
+
|
|
4775
4779
|
if (onChange) {
|
|
4776
4780
|
onChange(editor.children);
|
|
4777
4781
|
}
|
|
4778
4782
|
|
|
4783
|
+
switch (options === null || options === void 0 ? void 0 : (_options$operation = options.operation) === null || _options$operation === void 0 ? void 0 : _options$operation.type) {
|
|
4784
|
+
case 'set_selection':
|
|
4785
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(editor.selection);
|
|
4786
|
+
break;
|
|
4787
|
+
|
|
4788
|
+
default:
|
|
4789
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(editor.children);
|
|
4790
|
+
}
|
|
4791
|
+
|
|
4779
4792
|
setContext(prevContext => ({
|
|
4780
4793
|
v: prevContext.v + 1,
|
|
4781
4794
|
editor
|
|
4782
4795
|
}));
|
|
4783
4796
|
handleSelectorChange(editor);
|
|
4784
|
-
}, [editor, handleSelectorChange, onChange]);
|
|
4797
|
+
}, [editor, handleSelectorChange, onChange, onSelectionChange, onValueChange]);
|
|
4785
4798
|
useEffect(() => {
|
|
4786
4799
|
EDITOR_TO_ON_CHANGE.set(editor, onContextChange);
|
|
4787
4800
|
return () => {
|
|
@@ -5229,7 +5242,7 @@ var withReact = function withReact(editor) {
|
|
|
5229
5242
|
var onContextChange = EDITOR_TO_ON_CHANGE.get(e);
|
|
5230
5243
|
|
|
5231
5244
|
if (onContextChange) {
|
|
5232
|
-
onContextChange();
|
|
5245
|
+
onContextChange(options);
|
|
5233
5246
|
}
|
|
5234
5247
|
|
|
5235
5248
|
onChange(options);
|