slate 0.82.1 → 0.84.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/index.es.js +106 -110
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +104 -103
- package/dist/index.js.map +1 -1
- package/dist/interfaces/path.d.ts.map +1 -1
- package/dist/slate.js +104 -103
- package/dist/slate.min.js +1 -1
- package/dist/transforms/text.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -2847,6 +2847,7 @@ var Operation = {
|
|
|
2847
2847
|
|
|
2848
2848
|
};
|
|
2849
2849
|
|
|
2850
|
+
// eslint-disable-next-line no-redeclare
|
|
2850
2851
|
var Path = {
|
|
2851
2852
|
/**
|
|
2852
2853
|
* Get a list of ancestor paths for a given path.
|
|
@@ -3130,131 +3131,130 @@ var Path = {
|
|
|
3130
3131
|
*/
|
|
3131
3132
|
transform(path, operation) {
|
|
3132
3133
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
3133
|
-
|
|
3134
|
-
var {
|
|
3135
|
-
affinity = 'forward'
|
|
3136
|
-
} = options; // PERF: Exit early if the operation is guaranteed not to have an effect.
|
|
3137
|
-
|
|
3138
|
-
if (!path || (path === null || path === void 0 ? void 0 : path.length) === 0) {
|
|
3139
|
-
return;
|
|
3140
|
-
}
|
|
3134
|
+
if (!path) return null; // PERF: use destructing instead of immer
|
|
3141
3135
|
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3136
|
+
var p = [...path];
|
|
3137
|
+
var {
|
|
3138
|
+
affinity = 'forward'
|
|
3139
|
+
} = options; // PERF: Exit early if the operation is guaranteed not to have an effect.
|
|
3145
3140
|
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
var {
|
|
3150
|
-
path: op
|
|
3151
|
-
} = operation;
|
|
3141
|
+
if (path.length === 0) {
|
|
3142
|
+
return p;
|
|
3143
|
+
}
|
|
3152
3144
|
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3145
|
+
switch (operation.type) {
|
|
3146
|
+
case 'insert_node':
|
|
3147
|
+
{
|
|
3148
|
+
var {
|
|
3149
|
+
path: op
|
|
3150
|
+
} = operation;
|
|
3156
3151
|
|
|
3157
|
-
|
|
3152
|
+
if (Path.equals(op, p) || Path.endsBefore(op, p) || Path.isAncestor(op, p)) {
|
|
3153
|
+
p[op.length - 1] += 1;
|
|
3158
3154
|
}
|
|
3159
3155
|
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
var {
|
|
3163
|
-
path: _op
|
|
3164
|
-
} = operation;
|
|
3156
|
+
break;
|
|
3157
|
+
}
|
|
3165
3158
|
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3159
|
+
case 'remove_node':
|
|
3160
|
+
{
|
|
3161
|
+
var {
|
|
3162
|
+
path: _op
|
|
3163
|
+
} = operation;
|
|
3171
3164
|
|
|
3172
|
-
|
|
3165
|
+
if (Path.equals(_op, p) || Path.isAncestor(_op, p)) {
|
|
3166
|
+
return null;
|
|
3167
|
+
} else if (Path.endsBefore(_op, p)) {
|
|
3168
|
+
p[_op.length - 1] -= 1;
|
|
3173
3169
|
}
|
|
3174
3170
|
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
var {
|
|
3178
|
-
path: _op2,
|
|
3179
|
-
position
|
|
3180
|
-
} = operation;
|
|
3181
|
-
|
|
3182
|
-
if (Path.equals(_op2, p) || Path.endsBefore(_op2, p)) {
|
|
3183
|
-
p[_op2.length - 1] -= 1;
|
|
3184
|
-
} else if (Path.isAncestor(_op2, p)) {
|
|
3185
|
-
p[_op2.length - 1] -= 1;
|
|
3186
|
-
p[_op2.length] += position;
|
|
3187
|
-
}
|
|
3171
|
+
break;
|
|
3172
|
+
}
|
|
3188
3173
|
|
|
3189
|
-
|
|
3174
|
+
case 'merge_node':
|
|
3175
|
+
{
|
|
3176
|
+
var {
|
|
3177
|
+
path: _op2,
|
|
3178
|
+
position
|
|
3179
|
+
} = operation;
|
|
3180
|
+
|
|
3181
|
+
if (Path.equals(_op2, p) || Path.endsBefore(_op2, p)) {
|
|
3182
|
+
p[_op2.length - 1] -= 1;
|
|
3183
|
+
} else if (Path.isAncestor(_op2, p)) {
|
|
3184
|
+
p[_op2.length - 1] -= 1;
|
|
3185
|
+
p[_op2.length] += position;
|
|
3190
3186
|
}
|
|
3191
3187
|
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
var {
|
|
3195
|
-
path: _op3,
|
|
3196
|
-
position: _position
|
|
3197
|
-
} = operation;
|
|
3198
|
-
|
|
3199
|
-
if (Path.equals(_op3, p)) {
|
|
3200
|
-
if (affinity === 'forward') {
|
|
3201
|
-
p[p.length - 1] += 1;
|
|
3202
|
-
} else if (affinity === 'backward') ; else {
|
|
3203
|
-
return null;
|
|
3204
|
-
}
|
|
3205
|
-
} else if (Path.endsBefore(_op3, p)) {
|
|
3206
|
-
p[_op3.length - 1] += 1;
|
|
3207
|
-
} else if (Path.isAncestor(_op3, p) && path[_op3.length] >= _position) {
|
|
3208
|
-
p[_op3.length - 1] += 1;
|
|
3209
|
-
p[_op3.length] -= _position;
|
|
3210
|
-
}
|
|
3188
|
+
break;
|
|
3189
|
+
}
|
|
3211
3190
|
|
|
3212
|
-
|
|
3191
|
+
case 'split_node':
|
|
3192
|
+
{
|
|
3193
|
+
var {
|
|
3194
|
+
path: _op3,
|
|
3195
|
+
position: _position
|
|
3196
|
+
} = operation;
|
|
3197
|
+
|
|
3198
|
+
if (Path.equals(_op3, p)) {
|
|
3199
|
+
if (affinity === 'forward') {
|
|
3200
|
+
p[p.length - 1] += 1;
|
|
3201
|
+
} else if (affinity === 'backward') ; else {
|
|
3202
|
+
return null;
|
|
3203
|
+
}
|
|
3204
|
+
} else if (Path.endsBefore(_op3, p)) {
|
|
3205
|
+
p[_op3.length - 1] += 1;
|
|
3206
|
+
} else if (Path.isAncestor(_op3, p) && path[_op3.length] >= _position) {
|
|
3207
|
+
p[_op3.length - 1] += 1;
|
|
3208
|
+
p[_op3.length] -= _position;
|
|
3213
3209
|
}
|
|
3214
3210
|
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
var {
|
|
3218
|
-
path: _op4,
|
|
3219
|
-
newPath: onp
|
|
3220
|
-
} = operation; // If the old and new path are the same, it's a no-op.
|
|
3221
|
-
|
|
3222
|
-
if (Path.equals(_op4, onp)) {
|
|
3223
|
-
return;
|
|
3224
|
-
}
|
|
3211
|
+
break;
|
|
3212
|
+
}
|
|
3225
3213
|
|
|
3226
|
-
|
|
3227
|
-
|
|
3214
|
+
case 'move_node':
|
|
3215
|
+
{
|
|
3216
|
+
var {
|
|
3217
|
+
path: _op4,
|
|
3218
|
+
newPath: onp
|
|
3219
|
+
} = operation; // If the old and new path are the same, it's a no-op.
|
|
3228
3220
|
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3221
|
+
if (Path.equals(_op4, onp)) {
|
|
3222
|
+
return p;
|
|
3223
|
+
}
|
|
3232
3224
|
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
if (Path.endsBefore(_op4, p)) {
|
|
3236
|
-
p[_op4.length - 1] -= 1;
|
|
3237
|
-
} else {
|
|
3238
|
-
p[_op4.length - 1] += 1;
|
|
3239
|
-
}
|
|
3240
|
-
} else if (Path.endsBefore(onp, p) || Path.equals(onp, p) || Path.isAncestor(onp, p)) {
|
|
3241
|
-
if (Path.endsBefore(_op4, p)) {
|
|
3242
|
-
p[_op4.length - 1] -= 1;
|
|
3243
|
-
}
|
|
3225
|
+
if (Path.isAncestor(_op4, p) || Path.equals(_op4, p)) {
|
|
3226
|
+
var copy = onp.slice();
|
|
3244
3227
|
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
p[onp.length - 1] += 1;
|
|
3249
|
-
}
|
|
3228
|
+
if (Path.endsBefore(_op4, onp) && _op4.length < onp.length) {
|
|
3229
|
+
copy[_op4.length - 1] -= 1;
|
|
3230
|
+
}
|
|
3250
3231
|
|
|
3232
|
+
return copy.concat(p.slice(_op4.length));
|
|
3233
|
+
} else if (Path.isSibling(_op4, onp) && (Path.isAncestor(onp, p) || Path.equals(onp, p))) {
|
|
3234
|
+
if (Path.endsBefore(_op4, p)) {
|
|
3235
|
+
p[_op4.length - 1] -= 1;
|
|
3236
|
+
} else {
|
|
3237
|
+
p[_op4.length - 1] += 1;
|
|
3238
|
+
}
|
|
3239
|
+
} else if (Path.endsBefore(onp, p) || Path.equals(onp, p) || Path.isAncestor(onp, p)) {
|
|
3240
|
+
if (Path.endsBefore(_op4, p)) {
|
|
3251
3241
|
p[_op4.length - 1] -= 1;
|
|
3252
3242
|
}
|
|
3253
3243
|
|
|
3254
|
-
|
|
3244
|
+
p[onp.length - 1] += 1;
|
|
3245
|
+
} else if (Path.endsBefore(_op4, p)) {
|
|
3246
|
+
if (Path.equals(onp, p)) {
|
|
3247
|
+
p[onp.length - 1] += 1;
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
p[_op4.length - 1] -= 1;
|
|
3255
3251
|
}
|
|
3256
|
-
|
|
3257
|
-
|
|
3252
|
+
|
|
3253
|
+
break;
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3257
|
+
return p;
|
|
3258
3258
|
}
|
|
3259
3259
|
|
|
3260
3260
|
};
|
|
@@ -5641,20 +5641,16 @@ var TextTransforms = {
|
|
|
5641
5641
|
}
|
|
5642
5642
|
}
|
|
5643
5643
|
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
at: _path2,
|
|
5649
|
-
voids
|
|
5650
|
-
});
|
|
5651
|
-
}
|
|
5644
|
+
pathRefs.reverse().map(r => r.unref()).filter(r => r !== null).forEach(p => Transforms.removeNodes(editor, {
|
|
5645
|
+
at: p,
|
|
5646
|
+
voids
|
|
5647
|
+
}));
|
|
5652
5648
|
|
|
5653
5649
|
if (!endVoid) {
|
|
5654
5650
|
var _point2 = endRef.current;
|
|
5655
5651
|
var [_node2] = Editor.leaf(editor, _point2);
|
|
5656
5652
|
var {
|
|
5657
|
-
path:
|
|
5653
|
+
path: _path2
|
|
5658
5654
|
} = _point2;
|
|
5659
5655
|
|
|
5660
5656
|
var _offset = isSingleText ? start.offset : 0;
|
|
@@ -5664,7 +5660,7 @@ var TextTransforms = {
|
|
|
5664
5660
|
if (_text.length > 0) {
|
|
5665
5661
|
editor.apply({
|
|
5666
5662
|
type: 'remove_text',
|
|
5667
|
-
path:
|
|
5663
|
+
path: _path2,
|
|
5668
5664
|
offset: _offset,
|
|
5669
5665
|
text: _text
|
|
5670
5666
|
});
|