slate-react 0.76.0-20222247328 → 0.76.0
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-children.d.ts.map +1 -1
- package/dist/index.es.js +41 -43
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +64 -94
- package/dist/index.js.map +1 -1
- package/dist/plugin/with-react.d.ts.map +1 -1
- package/dist/slate-react.js +64 -94
- package/dist/slate-react.min.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-children.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/hooks/use-children.tsx"],"names":[],"mappings":";AACA,OAAO,EAAU,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAc,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"use-children.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/hooks/use-children.tsx"],"names":[],"mappings":";AACA,OAAO,EAAU,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAc,MAAM,OAAO,CAAA;AAOpE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACvB,MAAM,wBAAwB,CAAA;AAG/B;;GAEG;AAEH,QAAA,MAAM,WAAW;iBACF,KAAK,EAAE;UACd,QAAQ;6BACU,kBAAkB,KAAK,GAAG,CAAC,OAAO;+BAC/B,sBAAsB,KAAK,GAAG,CAAC,OAAO;0BAC5C,eAAe,KAAK,GAAG,CAAC,OAAO;eACzC,KAAK,GAAG,IAAI;mBAgExB,CAAA;AAED,eAAe,WAAW,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -595,19 +595,6 @@ var useSlateStatic = () => {
|
|
|
595
595
|
return editor;
|
|
596
596
|
};
|
|
597
597
|
|
|
598
|
-
/**
|
|
599
|
-
* A React context for sharing the `decorate` prop of the editable.
|
|
600
|
-
*/
|
|
601
|
-
|
|
602
|
-
var DecorateContext = /*#__PURE__*/createContext(() => []);
|
|
603
|
-
/**
|
|
604
|
-
* Get the current `decorate` prop of the editable.
|
|
605
|
-
*/
|
|
606
|
-
|
|
607
|
-
var useDecorate = () => {
|
|
608
|
-
return useContext(DecorateContext);
|
|
609
|
-
};
|
|
610
|
-
|
|
611
598
|
/**
|
|
612
599
|
* A React context for sharing the `selected` state of an element.
|
|
613
600
|
*/
|
|
@@ -634,7 +621,6 @@ var useChildren = props => {
|
|
|
634
621
|
renderLeaf,
|
|
635
622
|
selection
|
|
636
623
|
} = props;
|
|
637
|
-
useDecorate();
|
|
638
624
|
var editor = useSlateStatic();
|
|
639
625
|
var path = ReactEditor.findPath(editor, node);
|
|
640
626
|
var children = [];
|
|
@@ -646,7 +632,11 @@ var useChildren = props => {
|
|
|
646
632
|
var key = ReactEditor.findKey(editor, n);
|
|
647
633
|
var range = Editor.range(editor, p);
|
|
648
634
|
var sel = selection && Range.intersection(range, selection);
|
|
649
|
-
var ds = decorations.
|
|
635
|
+
var ds = decorations.reduce((acc, dec) => {
|
|
636
|
+
var intersection = Range.intersection(dec, range);
|
|
637
|
+
if (intersection) acc.push(intersection);
|
|
638
|
+
return acc;
|
|
639
|
+
}, []);
|
|
650
640
|
|
|
651
641
|
if (Element$1.isElement(n)) {
|
|
652
642
|
children.push( /*#__PURE__*/React.createElement(SelectedContext.Provider, {
|
|
@@ -809,6 +799,12 @@ var useSlate = () => {
|
|
|
809
799
|
return editor;
|
|
810
800
|
};
|
|
811
801
|
|
|
802
|
+
/**
|
|
803
|
+
* A React context for sharing the `decorate` prop of the editable.
|
|
804
|
+
*/
|
|
805
|
+
|
|
806
|
+
var DecorateContext = /*#__PURE__*/createContext(() => []);
|
|
807
|
+
|
|
812
808
|
/**
|
|
813
809
|
* Types.
|
|
814
810
|
*/
|
|
@@ -4214,7 +4210,9 @@ var withReact = editor => {
|
|
|
4214
4210
|
}
|
|
4215
4211
|
}
|
|
4216
4212
|
}
|
|
4217
|
-
};
|
|
4213
|
+
}; // This attempts to reset the NODE_TO_KEY entry to the correct value
|
|
4214
|
+
// as apply() changes the object reference and hence invalidates the NODE_TO_KEY entry
|
|
4215
|
+
|
|
4218
4216
|
|
|
4219
4217
|
e.apply = op => {
|
|
4220
4218
|
var matches = [];
|
|
@@ -4223,52 +4221,39 @@ var withReact = editor => {
|
|
|
4223
4221
|
case 'insert_text':
|
|
4224
4222
|
case 'remove_text':
|
|
4225
4223
|
case 'set_node':
|
|
4224
|
+
case 'split_node':
|
|
4226
4225
|
{
|
|
4227
|
-
|
|
4228
|
-
at: op.path
|
|
4229
|
-
})) {
|
|
4230
|
-
var key = ReactEditor.findKey(e, node);
|
|
4231
|
-
matches.push([path, key]);
|
|
4232
|
-
}
|
|
4233
|
-
|
|
4226
|
+
matches.push(...getMatches(e, op.path));
|
|
4234
4227
|
break;
|
|
4235
4228
|
}
|
|
4236
4229
|
|
|
4237
4230
|
case 'insert_node':
|
|
4238
4231
|
case 'remove_node':
|
|
4239
|
-
case 'merge_node':
|
|
4240
|
-
case 'split_node':
|
|
4241
4232
|
{
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
var _key = ReactEditor.findKey(e, _node);
|
|
4246
|
-
|
|
4247
|
-
matches.push([_path, _key]);
|
|
4248
|
-
}
|
|
4233
|
+
matches.push(...getMatches(e, Path.parent(op.path)));
|
|
4234
|
+
break;
|
|
4235
|
+
}
|
|
4249
4236
|
|
|
4237
|
+
case 'merge_node':
|
|
4238
|
+
{
|
|
4239
|
+
var prevPath = Path.previous(op.path);
|
|
4240
|
+
matches.push(...getMatches(e, prevPath));
|
|
4250
4241
|
break;
|
|
4251
4242
|
}
|
|
4252
4243
|
|
|
4253
4244
|
case 'move_node':
|
|
4254
4245
|
{
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
})) {
|
|
4258
|
-
var _key2 = ReactEditor.findKey(e, _node2);
|
|
4259
|
-
|
|
4260
|
-
matches.push([_path2, _key2]);
|
|
4261
|
-
}
|
|
4262
|
-
|
|
4246
|
+
var commonPath = Path.common(Path.parent(op.path), Path.parent(op.newPath));
|
|
4247
|
+
matches.push(...getMatches(e, commonPath));
|
|
4263
4248
|
break;
|
|
4264
4249
|
}
|
|
4265
4250
|
}
|
|
4266
4251
|
|
|
4267
4252
|
apply(op);
|
|
4268
4253
|
|
|
4269
|
-
for (var [
|
|
4270
|
-
var [
|
|
4271
|
-
NODE_TO_KEY.set(
|
|
4254
|
+
for (var [path, key] of matches) {
|
|
4255
|
+
var [node] = Editor.node(e, path);
|
|
4256
|
+
NODE_TO_KEY.set(node, key);
|
|
4272
4257
|
}
|
|
4273
4258
|
};
|
|
4274
4259
|
|
|
@@ -4423,6 +4408,19 @@ var withReact = editor => {
|
|
|
4423
4408
|
return e;
|
|
4424
4409
|
};
|
|
4425
4410
|
|
|
4411
|
+
var getMatches = (e, path) => {
|
|
4412
|
+
var matches = [];
|
|
4413
|
+
|
|
4414
|
+
for (var [n, p] of Editor.levels(e, {
|
|
4415
|
+
at: path
|
|
4416
|
+
})) {
|
|
4417
|
+
var key = ReactEditor.findKey(e, n);
|
|
4418
|
+
matches.push([p, key]);
|
|
4419
|
+
}
|
|
4420
|
+
|
|
4421
|
+
return matches;
|
|
4422
|
+
};
|
|
4423
|
+
|
|
4426
4424
|
// Components
|
|
4427
4425
|
var Editable = IS_ANDROID ? AndroidEditable : Editable$1;
|
|
4428
4426
|
|