@bigbinary/neeto-editor 1.41.1 → 1.42.0-beta1
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/Editor.js +10968 -6179
- package/dist/Editor.js.map +1 -1
- package/dist/FormikEditor.js +3 -2
- package/dist/FormikEditor.js.map +1 -1
- package/dist/Menu.js +2 -2
- package/dist/{chunk-5a82ef66.js → chunk-53f86c77.js} +1154 -205
- package/dist/chunk-53f86c77.js.map +1 -0
- package/dist/{chunk-66821a1e.js → chunk-bdd72077.js} +3 -4
- package/dist/{chunk-66821a1e.js.map → chunk-bdd72077.js.map} +1 -1
- package/dist/cjs/Editor.cjs.js +10966 -6177
- package/dist/cjs/Editor.cjs.js.map +1 -1
- package/dist/cjs/FormikEditor.cjs.js +3 -2
- package/dist/cjs/FormikEditor.cjs.js.map +1 -1
- package/dist/cjs/Menu.cjs.js +2 -2
- package/dist/cjs/{chunk-42becde2.cjs.js → chunk-b18ba907.cjs.js} +2 -4
- package/dist/cjs/{chunk-42becde2.cjs.js.map → chunk-b18ba907.cjs.js.map} +1 -1
- package/dist/cjs/{chunk-c2f54026.cjs.js → chunk-eee94a18.cjs.js} +1141 -192
- package/dist/cjs/chunk-eee94a18.cjs.js.map +1 -0
- package/dist/cjs/index.cjs.js +4 -3
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/utils.cjs.js +1 -1
- package/dist/editor-stats.html +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/utils.js +1 -1
- package/package.json +8 -2
- package/dist/chunk-5a82ef66.js.map +0 -1
- package/dist/cjs/chunk-c2f54026.cjs.js.map +0 -1
|
@@ -5,7 +5,7 @@ import React__default, { forwardRef, createContext, useState, useEffect, useDebu
|
|
|
5
5
|
import { isEmpty, fromPairs, prop, not, assoc, last } from 'ramda';
|
|
6
6
|
import { n } from './chunk-15c449f1.js';
|
|
7
7
|
import i18n, { t as t$1 } from 'i18next';
|
|
8
|
-
import { T as TextSelection, N as NodeSelection,
|
|
8
|
+
import { T as TextSelection, N as NodeSelection, c as Selection, S as Slice, d as dropPoint, k as DOMSerializer, F as Fragment, l as DOMParser, A as AllSelection, e as Mark$1, P as Plugin, R as ReplaceError, f as MarkType, m as liftTarget$2, r as replaceStep$1, n as ReplaceStep$2, o as canJoin$2, p as joinPoint$1, q as canSplit$2, u as ReplaceAroundStep$2, w as findWrapping$2, x as NodeRange, b as PluginKey, y as Schema, E as EditorState, v as validateAndFormatUrl, D as DEFAULT_EDITOR_OPTIONS } from './chunk-bdd72077.js';
|
|
9
9
|
import tippy, { roundArrow } from 'tippy.js';
|
|
10
10
|
import ReactDOM, { flushSync, createPortal } from 'react-dom';
|
|
11
11
|
import classnames from 'classnames';
|
|
@@ -5999,17 +5999,17 @@ function keydownHandler(bindings) {
|
|
|
5999
5999
|
// decode these, since those clip to 32 bits, which we might in rare
|
|
6000
6000
|
// cases want to overflow. A 64-bit float can represent 48-bit
|
|
6001
6001
|
// integers precisely.
|
|
6002
|
-
const lower16 = 0xffff;
|
|
6003
|
-
const factor16 = Math.pow(2, 16);
|
|
6004
|
-
function makeRecover(index, offset) { return index + offset * factor16; }
|
|
6005
|
-
function recoverIndex(value) { return value & lower16; }
|
|
6006
|
-
function recoverOffset(value) { return (value - (value & lower16)) / factor16; }
|
|
6007
|
-
const DEL_BEFORE = 1, DEL_AFTER = 2, DEL_ACROSS = 4, DEL_SIDE = 8;
|
|
6002
|
+
const lower16$1 = 0xffff;
|
|
6003
|
+
const factor16$1 = Math.pow(2, 16);
|
|
6004
|
+
function makeRecover$1(index, offset) { return index + offset * factor16$1; }
|
|
6005
|
+
function recoverIndex$1(value) { return value & lower16$1; }
|
|
6006
|
+
function recoverOffset$1(value) { return (value - (value & lower16$1)) / factor16$1; }
|
|
6007
|
+
const DEL_BEFORE$1 = 1, DEL_AFTER$1 = 2, DEL_ACROSS$1 = 4, DEL_SIDE$1 = 8;
|
|
6008
6008
|
/**
|
|
6009
6009
|
An object representing a mapped position with extra
|
|
6010
6010
|
information.
|
|
6011
6011
|
*/
|
|
6012
|
-
class MapResult {
|
|
6012
|
+
class MapResult$1 {
|
|
6013
6013
|
/**
|
|
6014
6014
|
@internal
|
|
6015
6015
|
*/
|
|
@@ -6035,21 +6035,21 @@ class MapResult {
|
|
|
6035
6035
|
step removed the token on the side queried (via the `assoc`)
|
|
6036
6036
|
argument from the document.
|
|
6037
6037
|
*/
|
|
6038
|
-
get deleted() { return (this.delInfo & DEL_SIDE) > 0; }
|
|
6038
|
+
get deleted() { return (this.delInfo & DEL_SIDE$1) > 0; }
|
|
6039
6039
|
/**
|
|
6040
6040
|
Tells you whether the token before the mapped position was deleted.
|
|
6041
6041
|
*/
|
|
6042
|
-
get deletedBefore() { return (this.delInfo & (DEL_BEFORE | DEL_ACROSS)) > 0; }
|
|
6042
|
+
get deletedBefore() { return (this.delInfo & (DEL_BEFORE$1 | DEL_ACROSS$1)) > 0; }
|
|
6043
6043
|
/**
|
|
6044
6044
|
True when the token after the mapped position was deleted.
|
|
6045
6045
|
*/
|
|
6046
|
-
get deletedAfter() { return (this.delInfo & (DEL_AFTER | DEL_ACROSS)) > 0; }
|
|
6046
|
+
get deletedAfter() { return (this.delInfo & (DEL_AFTER$1 | DEL_ACROSS$1)) > 0; }
|
|
6047
6047
|
/**
|
|
6048
6048
|
Tells whether any of the steps mapped through deletes across the
|
|
6049
6049
|
position (including both the token before and after the
|
|
6050
6050
|
position).
|
|
6051
6051
|
*/
|
|
6052
|
-
get deletedAcross() { return (this.delInfo & DEL_ACROSS) > 0; }
|
|
6052
|
+
get deletedAcross() { return (this.delInfo & DEL_ACROSS$1) > 0; }
|
|
6053
6053
|
}
|
|
6054
6054
|
/**
|
|
6055
6055
|
A map describing the deletions and insertions made by a step, which
|
|
@@ -6057,7 +6057,7 @@ can be used to find the correspondence between positions in the
|
|
|
6057
6057
|
pre-step version of a document and the same position in the
|
|
6058
6058
|
post-step version.
|
|
6059
6059
|
*/
|
|
6060
|
-
class StepMap {
|
|
6060
|
+
class StepMap$1 {
|
|
6061
6061
|
/**
|
|
6062
6062
|
Create a position map. The modifications to the document are
|
|
6063
6063
|
represented as an array of numbers, in which each group of three
|
|
@@ -6074,18 +6074,18 @@ class StepMap {
|
|
|
6074
6074
|
inverted = false) {
|
|
6075
6075
|
this.ranges = ranges;
|
|
6076
6076
|
this.inverted = inverted;
|
|
6077
|
-
if (!ranges.length && StepMap.empty)
|
|
6078
|
-
return StepMap.empty;
|
|
6077
|
+
if (!ranges.length && StepMap$1.empty)
|
|
6078
|
+
return StepMap$1.empty;
|
|
6079
6079
|
}
|
|
6080
6080
|
/**
|
|
6081
6081
|
@internal
|
|
6082
6082
|
*/
|
|
6083
6083
|
recover(value) {
|
|
6084
|
-
let diff = 0, index = recoverIndex(value);
|
|
6084
|
+
let diff = 0, index = recoverIndex$1(value);
|
|
6085
6085
|
if (!this.inverted)
|
|
6086
6086
|
for (let i = 0; i < index; i++)
|
|
6087
6087
|
diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
|
|
6088
|
-
return this.ranges[index * 3] + diff + recoverOffset(value);
|
|
6088
|
+
return this.ranges[index * 3] + diff + recoverOffset$1(value);
|
|
6089
6089
|
}
|
|
6090
6090
|
mapResult(pos, assoc = 1) { return this._map(pos, assoc, false); }
|
|
6091
6091
|
map(pos, assoc = 1) { return this._map(pos, assoc, true); }
|
|
@@ -6104,21 +6104,21 @@ class StepMap {
|
|
|
6104
6104
|
let result = start + diff + (side < 0 ? 0 : newSize);
|
|
6105
6105
|
if (simple)
|
|
6106
6106
|
return result;
|
|
6107
|
-
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
6108
|
-
let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
6107
|
+
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover$1(i / 3, pos - start);
|
|
6108
|
+
let del = pos == start ? DEL_AFTER$1 : pos == end ? DEL_BEFORE$1 : DEL_ACROSS$1;
|
|
6109
6109
|
if (assoc < 0 ? pos != start : pos != end)
|
|
6110
|
-
del |= DEL_SIDE;
|
|
6111
|
-
return new MapResult(result, del, recover);
|
|
6110
|
+
del |= DEL_SIDE$1;
|
|
6111
|
+
return new MapResult$1(result, del, recover);
|
|
6112
6112
|
}
|
|
6113
6113
|
diff += newSize - oldSize;
|
|
6114
6114
|
}
|
|
6115
|
-
return simple ? pos + diff : new MapResult(pos + diff, 0, null);
|
|
6115
|
+
return simple ? pos + diff : new MapResult$1(pos + diff, 0, null);
|
|
6116
6116
|
}
|
|
6117
6117
|
/**
|
|
6118
6118
|
@internal
|
|
6119
6119
|
*/
|
|
6120
6120
|
touches(pos, recover) {
|
|
6121
|
-
let diff = 0, index = recoverIndex(recover);
|
|
6121
|
+
let diff = 0, index = recoverIndex$1(recover);
|
|
6122
6122
|
let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
|
|
6123
6123
|
for (let i = 0; i < this.ranges.length; i += 3) {
|
|
6124
6124
|
let start = this.ranges[i] - (this.inverted ? diff : 0);
|
|
@@ -6149,7 +6149,7 @@ class StepMap {
|
|
|
6149
6149
|
map positions in the post-step document to the pre-step document.
|
|
6150
6150
|
*/
|
|
6151
6151
|
invert() {
|
|
6152
|
-
return new StepMap(this.ranges, !this.inverted);
|
|
6152
|
+
return new StepMap$1(this.ranges, !this.inverted);
|
|
6153
6153
|
}
|
|
6154
6154
|
/**
|
|
6155
6155
|
@internal
|
|
@@ -6163,13 +6163,13 @@ class StepMap {
|
|
|
6163
6163
|
sub-document to a larger document, or vice-versa.
|
|
6164
6164
|
*/
|
|
6165
6165
|
static offset(n) {
|
|
6166
|
-
return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);
|
|
6166
|
+
return n == 0 ? StepMap$1.empty : new StepMap$1(n < 0 ? [0, -n, 0] : [0, 0, n]);
|
|
6167
6167
|
}
|
|
6168
6168
|
}
|
|
6169
6169
|
/**
|
|
6170
6170
|
A StepMap that contains no changed ranges.
|
|
6171
6171
|
*/
|
|
6172
|
-
StepMap.empty = new StepMap([]);
|
|
6172
|
+
StepMap$1.empty = new StepMap$1([]);
|
|
6173
6173
|
/**
|
|
6174
6174
|
A mapping represents a pipeline of zero or more [step
|
|
6175
6175
|
maps](https://prosemirror.net/docs/ref/#transform.StepMap). It has special provisions for losslessly
|
|
@@ -6306,11 +6306,11 @@ class Mapping {
|
|
|
6306
6306
|
delInfo |= result.delInfo;
|
|
6307
6307
|
pos = result.pos;
|
|
6308
6308
|
}
|
|
6309
|
-
return simple ? pos : new MapResult(pos, delInfo, null);
|
|
6309
|
+
return simple ? pos : new MapResult$1(pos, delInfo, null);
|
|
6310
6310
|
}
|
|
6311
6311
|
}
|
|
6312
6312
|
|
|
6313
|
-
const stepsByID = Object.create(null);
|
|
6313
|
+
const stepsByID$1 = Object.create(null);
|
|
6314
6314
|
/**
|
|
6315
6315
|
A step object represents an atomic change. It generally applies
|
|
6316
6316
|
only to the document it was created for, since the positions
|
|
@@ -6322,13 +6322,13 @@ methods, and registering your class with a unique
|
|
|
6322
6322
|
JSON-serialization identifier using
|
|
6323
6323
|
[`Step.jsonID`](https://prosemirror.net/docs/ref/#transform.Step^jsonID).
|
|
6324
6324
|
*/
|
|
6325
|
-
class Step {
|
|
6325
|
+
class Step$1 {
|
|
6326
6326
|
/**
|
|
6327
6327
|
Get the step map that represents the changes made by this step,
|
|
6328
6328
|
and which can be used to transform between positions in the old
|
|
6329
6329
|
and the new document.
|
|
6330
6330
|
*/
|
|
6331
|
-
getMap() { return StepMap.empty; }
|
|
6331
|
+
getMap() { return StepMap$1.empty; }
|
|
6332
6332
|
/**
|
|
6333
6333
|
Try to merge this step with another one, to be applied directly
|
|
6334
6334
|
after it. Returns the merged step when possible, null if the
|
|
@@ -6342,7 +6342,7 @@ class Step {
|
|
|
6342
6342
|
static fromJSON(schema, json) {
|
|
6343
6343
|
if (!json || !json.stepType)
|
|
6344
6344
|
throw new RangeError("Invalid input for Step.fromJSON");
|
|
6345
|
-
let type = stepsByID[json.stepType];
|
|
6345
|
+
let type = stepsByID$1[json.stepType];
|
|
6346
6346
|
if (!type)
|
|
6347
6347
|
throw new RangeError(`No step type ${json.stepType} defined`);
|
|
6348
6348
|
return type.fromJSON(schema, json);
|
|
@@ -6354,9 +6354,9 @@ class Step {
|
|
|
6354
6354
|
that's unlikely to clash with steps from other modules.
|
|
6355
6355
|
*/
|
|
6356
6356
|
static jsonID(id, stepClass) {
|
|
6357
|
-
if (id in stepsByID)
|
|
6357
|
+
if (id in stepsByID$1)
|
|
6358
6358
|
throw new RangeError("Duplicate use of step JSON ID " + id);
|
|
6359
|
-
stepsByID[id] = stepClass;
|
|
6359
|
+
stepsByID$1[id] = stepClass;
|
|
6360
6360
|
stepClass.prototype.jsonID = id;
|
|
6361
6361
|
return stepClass;
|
|
6362
6362
|
}
|
|
@@ -6365,7 +6365,7 @@ class Step {
|
|
|
6365
6365
|
The result of [applying](https://prosemirror.net/docs/ref/#transform.Step.apply) a step. Contains either a
|
|
6366
6366
|
new document or a failure value.
|
|
6367
6367
|
*/
|
|
6368
|
-
class StepResult {
|
|
6368
|
+
class StepResult$1 {
|
|
6369
6369
|
/**
|
|
6370
6370
|
@internal
|
|
6371
6371
|
*/
|
|
@@ -6384,11 +6384,11 @@ class StepResult {
|
|
|
6384
6384
|
/**
|
|
6385
6385
|
Create a successful step result.
|
|
6386
6386
|
*/
|
|
6387
|
-
static ok(doc) { return new StepResult(doc, null); }
|
|
6387
|
+
static ok(doc) { return new StepResult$1(doc, null); }
|
|
6388
6388
|
/**
|
|
6389
6389
|
Create a failed step result.
|
|
6390
6390
|
*/
|
|
6391
|
-
static fail(message) { return new StepResult(null, message); }
|
|
6391
|
+
static fail(message) { return new StepResult$1(null, message); }
|
|
6392
6392
|
/**
|
|
6393
6393
|
Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
|
|
6394
6394
|
arguments. Create a successful result if it succeeds, and a
|
|
@@ -6396,22 +6396,22 @@ class StepResult {
|
|
|
6396
6396
|
*/
|
|
6397
6397
|
static fromReplace(doc, from, to, slice) {
|
|
6398
6398
|
try {
|
|
6399
|
-
return StepResult.ok(doc.replace(from, to, slice));
|
|
6399
|
+
return StepResult$1.ok(doc.replace(from, to, slice));
|
|
6400
6400
|
}
|
|
6401
6401
|
catch (e) {
|
|
6402
6402
|
if (e instanceof ReplaceError)
|
|
6403
|
-
return StepResult.fail(e.message);
|
|
6403
|
+
return StepResult$1.fail(e.message);
|
|
6404
6404
|
throw e;
|
|
6405
6405
|
}
|
|
6406
6406
|
}
|
|
6407
6407
|
}
|
|
6408
6408
|
|
|
6409
|
-
function mapFragment(fragment, f, parent) {
|
|
6409
|
+
function mapFragment$1(fragment, f, parent) {
|
|
6410
6410
|
let mapped = [];
|
|
6411
6411
|
for (let i = 0; i < fragment.childCount; i++) {
|
|
6412
6412
|
let child = fragment.child(i);
|
|
6413
6413
|
if (child.content.size)
|
|
6414
|
-
child = child.copy(mapFragment(child.content, f, child));
|
|
6414
|
+
child = child.copy(mapFragment$1(child.content, f, child));
|
|
6415
6415
|
if (child.isInline)
|
|
6416
6416
|
child = f(child, parent, i);
|
|
6417
6417
|
mapped.push(child);
|
|
@@ -6421,7 +6421,7 @@ function mapFragment(fragment, f, parent) {
|
|
|
6421
6421
|
/**
|
|
6422
6422
|
Add a mark to all inline content between two positions.
|
|
6423
6423
|
*/
|
|
6424
|
-
class AddMarkStep extends Step {
|
|
6424
|
+
class AddMarkStep$1 extends Step$1 {
|
|
6425
6425
|
/**
|
|
6426
6426
|
Create a mark step.
|
|
6427
6427
|
*/
|
|
@@ -6446,27 +6446,27 @@ class AddMarkStep extends Step {
|
|
|
6446
6446
|
apply(doc) {
|
|
6447
6447
|
let oldSlice = doc.slice(this.from, this.to), $from = doc.resolve(this.from);
|
|
6448
6448
|
let parent = $from.node($from.sharedDepth(this.to));
|
|
6449
|
-
let slice = new Slice(mapFragment(oldSlice.content, (node, parent) => {
|
|
6449
|
+
let slice = new Slice(mapFragment$1(oldSlice.content, (node, parent) => {
|
|
6450
6450
|
if (!node.isAtom || !parent.type.allowsMarkType(this.mark.type))
|
|
6451
6451
|
return node;
|
|
6452
6452
|
return node.mark(this.mark.addToSet(node.marks));
|
|
6453
6453
|
}, parent), oldSlice.openStart, oldSlice.openEnd);
|
|
6454
|
-
return StepResult.fromReplace(doc, this.from, this.to, slice);
|
|
6454
|
+
return StepResult$1.fromReplace(doc, this.from, this.to, slice);
|
|
6455
6455
|
}
|
|
6456
6456
|
invert() {
|
|
6457
|
-
return new RemoveMarkStep(this.from, this.to, this.mark);
|
|
6457
|
+
return new RemoveMarkStep$1(this.from, this.to, this.mark);
|
|
6458
6458
|
}
|
|
6459
6459
|
map(mapping) {
|
|
6460
6460
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
6461
6461
|
if (from.deleted && to.deleted || from.pos >= to.pos)
|
|
6462
6462
|
return null;
|
|
6463
|
-
return new AddMarkStep(from.pos, to.pos, this.mark);
|
|
6463
|
+
return new AddMarkStep$1(from.pos, to.pos, this.mark);
|
|
6464
6464
|
}
|
|
6465
6465
|
merge(other) {
|
|
6466
|
-
if (other instanceof AddMarkStep &&
|
|
6466
|
+
if (other instanceof AddMarkStep$1 &&
|
|
6467
6467
|
other.mark.eq(this.mark) &&
|
|
6468
6468
|
this.from <= other.to && this.to >= other.from)
|
|
6469
|
-
return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
6469
|
+
return new AddMarkStep$1(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
6470
6470
|
return null;
|
|
6471
6471
|
}
|
|
6472
6472
|
toJSON() {
|
|
@@ -6479,14 +6479,14 @@ class AddMarkStep extends Step {
|
|
|
6479
6479
|
static fromJSON(schema, json) {
|
|
6480
6480
|
if (typeof json.from != "number" || typeof json.to != "number")
|
|
6481
6481
|
throw new RangeError("Invalid input for AddMarkStep.fromJSON");
|
|
6482
|
-
return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
|
|
6482
|
+
return new AddMarkStep$1(json.from, json.to, schema.markFromJSON(json.mark));
|
|
6483
6483
|
}
|
|
6484
6484
|
}
|
|
6485
|
-
Step.jsonID("addMark", AddMarkStep);
|
|
6485
|
+
Step$1.jsonID("addMark", AddMarkStep$1);
|
|
6486
6486
|
/**
|
|
6487
6487
|
Remove a mark from all inline content between two positions.
|
|
6488
6488
|
*/
|
|
6489
|
-
class RemoveMarkStep extends Step {
|
|
6489
|
+
class RemoveMarkStep$1 extends Step$1 {
|
|
6490
6490
|
/**
|
|
6491
6491
|
Create a mark-removing step.
|
|
6492
6492
|
*/
|
|
@@ -6510,25 +6510,25 @@ class RemoveMarkStep extends Step {
|
|
|
6510
6510
|
}
|
|
6511
6511
|
apply(doc) {
|
|
6512
6512
|
let oldSlice = doc.slice(this.from, this.to);
|
|
6513
|
-
let slice = new Slice(mapFragment(oldSlice.content, node => {
|
|
6513
|
+
let slice = new Slice(mapFragment$1(oldSlice.content, node => {
|
|
6514
6514
|
return node.mark(this.mark.removeFromSet(node.marks));
|
|
6515
6515
|
}, doc), oldSlice.openStart, oldSlice.openEnd);
|
|
6516
|
-
return StepResult.fromReplace(doc, this.from, this.to, slice);
|
|
6516
|
+
return StepResult$1.fromReplace(doc, this.from, this.to, slice);
|
|
6517
6517
|
}
|
|
6518
6518
|
invert() {
|
|
6519
|
-
return new AddMarkStep(this.from, this.to, this.mark);
|
|
6519
|
+
return new AddMarkStep$1(this.from, this.to, this.mark);
|
|
6520
6520
|
}
|
|
6521
6521
|
map(mapping) {
|
|
6522
6522
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
6523
6523
|
if (from.deleted && to.deleted || from.pos >= to.pos)
|
|
6524
6524
|
return null;
|
|
6525
|
-
return new RemoveMarkStep(from.pos, to.pos, this.mark);
|
|
6525
|
+
return new RemoveMarkStep$1(from.pos, to.pos, this.mark);
|
|
6526
6526
|
}
|
|
6527
6527
|
merge(other) {
|
|
6528
|
-
if (other instanceof RemoveMarkStep &&
|
|
6528
|
+
if (other instanceof RemoveMarkStep$1 &&
|
|
6529
6529
|
other.mark.eq(this.mark) &&
|
|
6530
6530
|
this.from <= other.to && this.to >= other.from)
|
|
6531
|
-
return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
6531
|
+
return new RemoveMarkStep$1(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
6532
6532
|
return null;
|
|
6533
6533
|
}
|
|
6534
6534
|
toJSON() {
|
|
@@ -6541,14 +6541,14 @@ class RemoveMarkStep extends Step {
|
|
|
6541
6541
|
static fromJSON(schema, json) {
|
|
6542
6542
|
if (typeof json.from != "number" || typeof json.to != "number")
|
|
6543
6543
|
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
|
|
6544
|
-
return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
|
|
6544
|
+
return new RemoveMarkStep$1(json.from, json.to, schema.markFromJSON(json.mark));
|
|
6545
6545
|
}
|
|
6546
6546
|
}
|
|
6547
|
-
Step.jsonID("removeMark", RemoveMarkStep);
|
|
6547
|
+
Step$1.jsonID("removeMark", RemoveMarkStep$1);
|
|
6548
6548
|
/**
|
|
6549
6549
|
Add a mark to a specific node.
|
|
6550
6550
|
*/
|
|
6551
|
-
class AddNodeMarkStep extends Step {
|
|
6551
|
+
class AddNodeMarkStep$1 extends Step$1 {
|
|
6552
6552
|
/**
|
|
6553
6553
|
Create a node mark step.
|
|
6554
6554
|
*/
|
|
@@ -6568,9 +6568,9 @@ class AddNodeMarkStep extends Step {
|
|
|
6568
6568
|
apply(doc) {
|
|
6569
6569
|
let node = doc.nodeAt(this.pos);
|
|
6570
6570
|
if (!node)
|
|
6571
|
-
return StepResult.fail("No node at mark step's position");
|
|
6571
|
+
return StepResult$1.fail("No node at mark step's position");
|
|
6572
6572
|
let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
|
|
6573
|
-
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
6573
|
+
return StepResult$1.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
6574
6574
|
}
|
|
6575
6575
|
invert(doc) {
|
|
6576
6576
|
let node = doc.nodeAt(this.pos);
|
|
@@ -6579,15 +6579,15 @@ class AddNodeMarkStep extends Step {
|
|
|
6579
6579
|
if (newSet.length == node.marks.length) {
|
|
6580
6580
|
for (let i = 0; i < node.marks.length; i++)
|
|
6581
6581
|
if (!node.marks[i].isInSet(newSet))
|
|
6582
|
-
return new AddNodeMarkStep(this.pos, node.marks[i]);
|
|
6583
|
-
return new AddNodeMarkStep(this.pos, this.mark);
|
|
6582
|
+
return new AddNodeMarkStep$1(this.pos, node.marks[i]);
|
|
6583
|
+
return new AddNodeMarkStep$1(this.pos, this.mark);
|
|
6584
6584
|
}
|
|
6585
6585
|
}
|
|
6586
|
-
return new RemoveNodeMarkStep(this.pos, this.mark);
|
|
6586
|
+
return new RemoveNodeMarkStep$1(this.pos, this.mark);
|
|
6587
6587
|
}
|
|
6588
6588
|
map(mapping) {
|
|
6589
6589
|
let pos = mapping.mapResult(this.pos, 1);
|
|
6590
|
-
return pos.deletedAfter ? null : new AddNodeMarkStep(pos.pos, this.mark);
|
|
6590
|
+
return pos.deletedAfter ? null : new AddNodeMarkStep$1(pos.pos, this.mark);
|
|
6591
6591
|
}
|
|
6592
6592
|
toJSON() {
|
|
6593
6593
|
return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
@@ -6598,14 +6598,14 @@ class AddNodeMarkStep extends Step {
|
|
|
6598
6598
|
static fromJSON(schema, json) {
|
|
6599
6599
|
if (typeof json.pos != "number")
|
|
6600
6600
|
throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
|
|
6601
|
-
return new AddNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
|
|
6601
|
+
return new AddNodeMarkStep$1(json.pos, schema.markFromJSON(json.mark));
|
|
6602
6602
|
}
|
|
6603
6603
|
}
|
|
6604
|
-
Step.jsonID("addNodeMark", AddNodeMarkStep);
|
|
6604
|
+
Step$1.jsonID("addNodeMark", AddNodeMarkStep$1);
|
|
6605
6605
|
/**
|
|
6606
6606
|
Remove a mark from a specific node.
|
|
6607
6607
|
*/
|
|
6608
|
-
class RemoveNodeMarkStep extends Step {
|
|
6608
|
+
class RemoveNodeMarkStep$1 extends Step$1 {
|
|
6609
6609
|
/**
|
|
6610
6610
|
Create a mark-removing step.
|
|
6611
6611
|
*/
|
|
@@ -6625,19 +6625,19 @@ class RemoveNodeMarkStep extends Step {
|
|
|
6625
6625
|
apply(doc) {
|
|
6626
6626
|
let node = doc.nodeAt(this.pos);
|
|
6627
6627
|
if (!node)
|
|
6628
|
-
return StepResult.fail("No node at mark step's position");
|
|
6628
|
+
return StepResult$1.fail("No node at mark step's position");
|
|
6629
6629
|
let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
|
|
6630
|
-
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
6630
|
+
return StepResult$1.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
6631
6631
|
}
|
|
6632
6632
|
invert(doc) {
|
|
6633
6633
|
let node = doc.nodeAt(this.pos);
|
|
6634
6634
|
if (!node || !this.mark.isInSet(node.marks))
|
|
6635
6635
|
return this;
|
|
6636
|
-
return new AddNodeMarkStep(this.pos, this.mark);
|
|
6636
|
+
return new AddNodeMarkStep$1(this.pos, this.mark);
|
|
6637
6637
|
}
|
|
6638
6638
|
map(mapping) {
|
|
6639
6639
|
let pos = mapping.mapResult(this.pos, 1);
|
|
6640
|
-
return pos.deletedAfter ? null : new RemoveNodeMarkStep(pos.pos, this.mark);
|
|
6640
|
+
return pos.deletedAfter ? null : new RemoveNodeMarkStep$1(pos.pos, this.mark);
|
|
6641
6641
|
}
|
|
6642
6642
|
toJSON() {
|
|
6643
6643
|
return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
@@ -6648,15 +6648,15 @@ class RemoveNodeMarkStep extends Step {
|
|
|
6648
6648
|
static fromJSON(schema, json) {
|
|
6649
6649
|
if (typeof json.pos != "number")
|
|
6650
6650
|
throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
|
|
6651
|
-
return new RemoveNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
|
|
6651
|
+
return new RemoveNodeMarkStep$1(json.pos, schema.markFromJSON(json.mark));
|
|
6652
6652
|
}
|
|
6653
6653
|
}
|
|
6654
|
-
Step.jsonID("removeNodeMark", RemoveNodeMarkStep);
|
|
6654
|
+
Step$1.jsonID("removeNodeMark", RemoveNodeMarkStep$1);
|
|
6655
6655
|
|
|
6656
6656
|
/**
|
|
6657
6657
|
Replace a part of the document with a slice of new content.
|
|
6658
6658
|
*/
|
|
6659
|
-
class ReplaceStep extends Step {
|
|
6659
|
+
class ReplaceStep$1 extends Step$1 {
|
|
6660
6660
|
/**
|
|
6661
6661
|
The given `slice` should fit the 'gap' between `from` and
|
|
6662
6662
|
`to`—the depths must line up, and the surrounding nodes must be
|
|
@@ -6690,34 +6690,34 @@ class ReplaceStep extends Step {
|
|
|
6690
6690
|
this.structure = structure;
|
|
6691
6691
|
}
|
|
6692
6692
|
apply(doc) {
|
|
6693
|
-
if (this.structure && contentBetween(doc, this.from, this.to))
|
|
6694
|
-
return StepResult.fail("Structure replace would overwrite content");
|
|
6695
|
-
return StepResult.fromReplace(doc, this.from, this.to, this.slice);
|
|
6693
|
+
if (this.structure && contentBetween$1(doc, this.from, this.to))
|
|
6694
|
+
return StepResult$1.fail("Structure replace would overwrite content");
|
|
6695
|
+
return StepResult$1.fromReplace(doc, this.from, this.to, this.slice);
|
|
6696
6696
|
}
|
|
6697
6697
|
getMap() {
|
|
6698
|
-
return new StepMap([this.from, this.to - this.from, this.slice.size]);
|
|
6698
|
+
return new StepMap$1([this.from, this.to - this.from, this.slice.size]);
|
|
6699
6699
|
}
|
|
6700
6700
|
invert(doc) {
|
|
6701
|
-
return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
|
|
6701
|
+
return new ReplaceStep$1(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
|
|
6702
6702
|
}
|
|
6703
6703
|
map(mapping) {
|
|
6704
6704
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
6705
6705
|
if (from.deletedAcross && to.deletedAcross)
|
|
6706
6706
|
return null;
|
|
6707
|
-
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
|
|
6707
|
+
return new ReplaceStep$1(from.pos, Math.max(from.pos, to.pos), this.slice);
|
|
6708
6708
|
}
|
|
6709
6709
|
merge(other) {
|
|
6710
|
-
if (!(other instanceof ReplaceStep) || other.structure || this.structure)
|
|
6710
|
+
if (!(other instanceof ReplaceStep$1) || other.structure || this.structure)
|
|
6711
6711
|
return null;
|
|
6712
6712
|
if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {
|
|
6713
6713
|
let slice = this.slice.size + other.slice.size == 0 ? Slice.empty
|
|
6714
6714
|
: new Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);
|
|
6715
|
-
return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);
|
|
6715
|
+
return new ReplaceStep$1(this.from, this.to + (other.to - other.from), slice, this.structure);
|
|
6716
6716
|
}
|
|
6717
6717
|
else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {
|
|
6718
6718
|
let slice = this.slice.size + other.slice.size == 0 ? Slice.empty
|
|
6719
6719
|
: new Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);
|
|
6720
|
-
return new ReplaceStep(other.from, this.to, slice, this.structure);
|
|
6720
|
+
return new ReplaceStep$1(other.from, this.to, slice, this.structure);
|
|
6721
6721
|
}
|
|
6722
6722
|
else {
|
|
6723
6723
|
return null;
|
|
@@ -6737,16 +6737,16 @@ class ReplaceStep extends Step {
|
|
|
6737
6737
|
static fromJSON(schema, json) {
|
|
6738
6738
|
if (typeof json.from != "number" || typeof json.to != "number")
|
|
6739
6739
|
throw new RangeError("Invalid input for ReplaceStep.fromJSON");
|
|
6740
|
-
return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
|
|
6740
|
+
return new ReplaceStep$1(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
|
|
6741
6741
|
}
|
|
6742
6742
|
}
|
|
6743
|
-
Step.jsonID("replace", ReplaceStep);
|
|
6743
|
+
Step$1.jsonID("replace", ReplaceStep$1);
|
|
6744
6744
|
/**
|
|
6745
6745
|
Replace a part of the document with a slice of content, but
|
|
6746
6746
|
preserve a range of the replaced content by moving it into the
|
|
6747
6747
|
slice.
|
|
6748
6748
|
*/
|
|
6749
|
-
class ReplaceAroundStep extends Step {
|
|
6749
|
+
class ReplaceAroundStep$1 extends Step$1 {
|
|
6750
6750
|
/**
|
|
6751
6751
|
Create a replace-around step with the given range and gap.
|
|
6752
6752
|
`insert` should be the point in the slice into which the content
|
|
@@ -6793,24 +6793,24 @@ class ReplaceAroundStep extends Step {
|
|
|
6793
6793
|
this.structure = structure;
|
|
6794
6794
|
}
|
|
6795
6795
|
apply(doc) {
|
|
6796
|
-
if (this.structure && (contentBetween(doc, this.from, this.gapFrom) ||
|
|
6797
|
-
contentBetween(doc, this.gapTo, this.to)))
|
|
6798
|
-
return StepResult.fail("Structure gap-replace would overwrite content");
|
|
6796
|
+
if (this.structure && (contentBetween$1(doc, this.from, this.gapFrom) ||
|
|
6797
|
+
contentBetween$1(doc, this.gapTo, this.to)))
|
|
6798
|
+
return StepResult$1.fail("Structure gap-replace would overwrite content");
|
|
6799
6799
|
let gap = doc.slice(this.gapFrom, this.gapTo);
|
|
6800
6800
|
if (gap.openStart || gap.openEnd)
|
|
6801
|
-
return StepResult.fail("Gap is not a flat range");
|
|
6801
|
+
return StepResult$1.fail("Gap is not a flat range");
|
|
6802
6802
|
let inserted = this.slice.insertAt(this.insert, gap.content);
|
|
6803
6803
|
if (!inserted)
|
|
6804
|
-
return StepResult.fail("Content does not fit in gap");
|
|
6805
|
-
return StepResult.fromReplace(doc, this.from, this.to, inserted);
|
|
6804
|
+
return StepResult$1.fail("Content does not fit in gap");
|
|
6805
|
+
return StepResult$1.fromReplace(doc, this.from, this.to, inserted);
|
|
6806
6806
|
}
|
|
6807
6807
|
getMap() {
|
|
6808
|
-
return new StepMap([this.from, this.gapFrom - this.from, this.insert,
|
|
6808
|
+
return new StepMap$1([this.from, this.gapFrom - this.from, this.insert,
|
|
6809
6809
|
this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);
|
|
6810
6810
|
}
|
|
6811
6811
|
invert(doc) {
|
|
6812
6812
|
let gap = this.gapTo - this.gapFrom;
|
|
6813
|
-
return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
6813
|
+
return new ReplaceAroundStep$1(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
6814
6814
|
}
|
|
6815
6815
|
map(mapping) {
|
|
6816
6816
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
@@ -6818,7 +6818,7 @@ class ReplaceAroundStep extends Step {
|
|
|
6818
6818
|
let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
|
|
6819
6819
|
if ((from.deletedAcross && to.deletedAcross) || gapFrom < from.pos || gapTo > to.pos)
|
|
6820
6820
|
return null;
|
|
6821
|
-
return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
6821
|
+
return new ReplaceAroundStep$1(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
6822
6822
|
}
|
|
6823
6823
|
toJSON() {
|
|
6824
6824
|
let json = { stepType: "replaceAround", from: this.from, to: this.to,
|
|
@@ -6836,11 +6836,11 @@ class ReplaceAroundStep extends Step {
|
|
|
6836
6836
|
if (typeof json.from != "number" || typeof json.to != "number" ||
|
|
6837
6837
|
typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
|
|
6838
6838
|
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
6839
|
-
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
6839
|
+
return new ReplaceAroundStep$1(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
6840
6840
|
}
|
|
6841
6841
|
}
|
|
6842
|
-
Step.jsonID("replaceAround", ReplaceAroundStep);
|
|
6843
|
-
function contentBetween(doc, from, to) {
|
|
6842
|
+
Step$1.jsonID("replaceAround", ReplaceAroundStep$1);
|
|
6843
|
+
function contentBetween$1(doc, from, to) {
|
|
6844
6844
|
let $from = doc.resolve(from), dist = to - from, depth = $from.depth;
|
|
6845
6845
|
while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
|
|
6846
6846
|
depth--;
|
|
@@ -6873,13 +6873,13 @@ function addMark(tr, from, to, mark) {
|
|
|
6873
6873
|
if (removing && removing.to == start && removing.mark.eq(marks[i]))
|
|
6874
6874
|
removing.to = end;
|
|
6875
6875
|
else
|
|
6876
|
-
removed.push(removing = new RemoveMarkStep(start, end, marks[i]));
|
|
6876
|
+
removed.push(removing = new RemoveMarkStep$1(start, end, marks[i]));
|
|
6877
6877
|
}
|
|
6878
6878
|
}
|
|
6879
6879
|
if (adding && adding.to == start)
|
|
6880
6880
|
adding.to = end;
|
|
6881
6881
|
else
|
|
6882
|
-
added.push(adding = new AddMarkStep(start, end, mark));
|
|
6882
|
+
added.push(adding = new AddMarkStep$1(start, end, mark));
|
|
6883
6883
|
}
|
|
6884
6884
|
});
|
|
6885
6885
|
removed.forEach(s => tr.step(s));
|
|
@@ -6925,7 +6925,7 @@ function removeMark(tr, from, to, mark) {
|
|
|
6925
6925
|
}
|
|
6926
6926
|
}
|
|
6927
6927
|
});
|
|
6928
|
-
matched.forEach(m => tr.step(new RemoveMarkStep(m.from, m.to, m.style)));
|
|
6928
|
+
matched.forEach(m => tr.step(new RemoveMarkStep$1(m.from, m.to, m.style)));
|
|
6929
6929
|
}
|
|
6930
6930
|
function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch, clearNewlines = true) {
|
|
6931
6931
|
let node = tr.doc.nodeAt(pos);
|
|
@@ -6934,19 +6934,19 @@ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch,
|
|
|
6934
6934
|
let child = node.child(i), end = cur + child.nodeSize;
|
|
6935
6935
|
let allowed = match.matchType(child.type);
|
|
6936
6936
|
if (!allowed) {
|
|
6937
|
-
replSteps.push(new ReplaceStep(cur, end, Slice.empty));
|
|
6937
|
+
replSteps.push(new ReplaceStep$1(cur, end, Slice.empty));
|
|
6938
6938
|
}
|
|
6939
6939
|
else {
|
|
6940
6940
|
match = allowed;
|
|
6941
6941
|
for (let j = 0; j < child.marks.length; j++)
|
|
6942
6942
|
if (!parentType.allowsMarkType(child.marks[j].type))
|
|
6943
|
-
tr.step(new RemoveMarkStep(cur, end, child.marks[j]));
|
|
6943
|
+
tr.step(new RemoveMarkStep$1(cur, end, child.marks[j]));
|
|
6944
6944
|
if (clearNewlines && child.isText && parentType.whitespace != "pre") {
|
|
6945
6945
|
let m, newline = /\r?\n|\r/g, slice;
|
|
6946
6946
|
while (m = newline.exec(child.text)) {
|
|
6947
6947
|
if (!slice)
|
|
6948
6948
|
slice = new Slice(Fragment.from(parentType.schema.text(" ", parentType.allowedMarks(child.marks))), 0, 0);
|
|
6949
|
-
replSteps.push(new ReplaceStep(cur + m.index, cur + m.index + m[0].length, slice));
|
|
6949
|
+
replSteps.push(new ReplaceStep$1(cur + m.index, cur + m.index + m[0].length, slice));
|
|
6950
6950
|
}
|
|
6951
6951
|
}
|
|
6952
6952
|
}
|
|
@@ -6960,7 +6960,7 @@ function clearIncompatible(tr, pos, parentType, match = parentType.contentMatch,
|
|
|
6960
6960
|
tr.step(replSteps[i]);
|
|
6961
6961
|
}
|
|
6962
6962
|
|
|
6963
|
-
function canCut(node, start, end) {
|
|
6963
|
+
function canCut$1(node, start, end) {
|
|
6964
6964
|
return (start == 0 || node.canReplace(start, node.childCount)) &&
|
|
6965
6965
|
(end == node.childCount || node.canReplace(0, end));
|
|
6966
6966
|
}
|
|
@@ -6969,7 +6969,7 @@ Try to find a target depth to which the content in the given range
|
|
|
6969
6969
|
can be lifted. Will not go across
|
|
6970
6970
|
[isolating](https://prosemirror.net/docs/ref/#model.NodeSpec.isolating) parent nodes.
|
|
6971
6971
|
*/
|
|
6972
|
-
function liftTarget(range) {
|
|
6972
|
+
function liftTarget$1(range) {
|
|
6973
6973
|
let parent = range.parent;
|
|
6974
6974
|
let content = parent.content.cutByIndex(range.startIndex, range.endIndex);
|
|
6975
6975
|
for (let depth = range.depth;; --depth) {
|
|
@@ -6977,7 +6977,7 @@ function liftTarget(range) {
|
|
|
6977
6977
|
let index = range.$from.index(depth), endIndex = range.$to.indexAfter(depth);
|
|
6978
6978
|
if (depth < range.depth && node.canReplace(index, endIndex, content))
|
|
6979
6979
|
return depth;
|
|
6980
|
-
if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex))
|
|
6980
|
+
if (depth == 0 || node.type.spec.isolating || !canCut$1(node, index, endIndex))
|
|
6981
6981
|
break;
|
|
6982
6982
|
}
|
|
6983
6983
|
return null;
|
|
@@ -7006,7 +7006,7 @@ function lift$2(tr, range, target) {
|
|
|
7006
7006
|
else {
|
|
7007
7007
|
end++;
|
|
7008
7008
|
}
|
|
7009
|
-
tr.step(new ReplaceAroundStep(start, end, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
7009
|
+
tr.step(new ReplaceAroundStep$1(start, end, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));
|
|
7010
7010
|
}
|
|
7011
7011
|
/**
|
|
7012
7012
|
Try to find a valid way to wrap the content in the given range in a
|
|
@@ -7016,16 +7016,16 @@ could be found. When `innerRange` is given, that range's content is
|
|
|
7016
7016
|
used as the content to fit into the wrapping, instead of the
|
|
7017
7017
|
content of `range`.
|
|
7018
7018
|
*/
|
|
7019
|
-
function findWrapping(range, nodeType, attrs = null, innerRange = range) {
|
|
7020
|
-
let around = findWrappingOutside(range, nodeType);
|
|
7021
|
-
let inner = around && findWrappingInside(innerRange, nodeType);
|
|
7019
|
+
function findWrapping$1(range, nodeType, attrs = null, innerRange = range) {
|
|
7020
|
+
let around = findWrappingOutside$1(range, nodeType);
|
|
7021
|
+
let inner = around && findWrappingInside$1(innerRange, nodeType);
|
|
7022
7022
|
if (!inner)
|
|
7023
7023
|
return null;
|
|
7024
|
-
return around.map(withAttrs)
|
|
7025
|
-
.concat({ type: nodeType, attrs }).concat(inner.map(withAttrs));
|
|
7024
|
+
return around.map(withAttrs$1)
|
|
7025
|
+
.concat({ type: nodeType, attrs }).concat(inner.map(withAttrs$1));
|
|
7026
7026
|
}
|
|
7027
|
-
function withAttrs(type) { return { type, attrs: null }; }
|
|
7028
|
-
function findWrappingOutside(range, type) {
|
|
7027
|
+
function withAttrs$1(type) { return { type, attrs: null }; }
|
|
7028
|
+
function findWrappingOutside$1(range, type) {
|
|
7029
7029
|
let { parent, startIndex, endIndex } = range;
|
|
7030
7030
|
let around = parent.contentMatchAt(startIndex).findWrapping(type);
|
|
7031
7031
|
if (!around)
|
|
@@ -7033,7 +7033,7 @@ function findWrappingOutside(range, type) {
|
|
|
7033
7033
|
let outer = around.length ? around[0] : type;
|
|
7034
7034
|
return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;
|
|
7035
7035
|
}
|
|
7036
|
-
function findWrappingInside(range, type) {
|
|
7036
|
+
function findWrappingInside$1(range, type) {
|
|
7037
7037
|
let { parent, startIndex, endIndex } = range;
|
|
7038
7038
|
let inner = parent.child(startIndex);
|
|
7039
7039
|
let inside = type.contentMatch.findWrapping(inner.type);
|
|
@@ -7058,14 +7058,16 @@ function wrap(tr, range, wrappers) {
|
|
|
7058
7058
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
7059
7059
|
}
|
|
7060
7060
|
let start = range.start, end = range.end;
|
|
7061
|
-
tr.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));
|
|
7061
|
+
tr.step(new ReplaceAroundStep$1(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));
|
|
7062
7062
|
}
|
|
7063
7063
|
function setBlockType$1(tr, from, to, type, attrs) {
|
|
7064
7064
|
if (!type.isTextblock)
|
|
7065
7065
|
throw new RangeError("Type given to setBlockType should be a textblock");
|
|
7066
7066
|
let mapFrom = tr.steps.length;
|
|
7067
7067
|
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
7068
|
-
|
|
7068
|
+
let attrsHere = typeof attrs == "function" ? attrs(node) : attrs;
|
|
7069
|
+
if (node.isTextblock && !node.hasMarkup(type, attrsHere) &&
|
|
7070
|
+
canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) {
|
|
7069
7071
|
let convertNewlines = null;
|
|
7070
7072
|
if (type.schema.linebreakReplacement) {
|
|
7071
7073
|
let pre = type.whitespace == "pre", supportLinebreak = !!type.contentMatch.matchType(type.schema.linebreakReplacement);
|
|
@@ -7080,7 +7082,7 @@ function setBlockType$1(tr, from, to, type, attrs) {
|
|
|
7080
7082
|
clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type, undefined, convertNewlines === null);
|
|
7081
7083
|
let mapping = tr.mapping.slice(mapFrom);
|
|
7082
7084
|
let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
|
|
7083
|
-
tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(
|
|
7085
|
+
tr.step(new ReplaceAroundStep$1(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));
|
|
7084
7086
|
if (convertNewlines === true)
|
|
7085
7087
|
replaceNewlines(tr, node, pos, mapFrom);
|
|
7086
7088
|
return false;
|
|
@@ -7125,12 +7127,12 @@ function setNodeMarkup(tr, pos, type, attrs, marks) {
|
|
|
7125
7127
|
return tr.replaceWith(pos, pos + node.nodeSize, newNode);
|
|
7126
7128
|
if (!type.validContent(node.content))
|
|
7127
7129
|
throw new RangeError("Invalid content for node type " + type.name);
|
|
7128
|
-
tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
7130
|
+
tr.step(new ReplaceAroundStep$1(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
|
|
7129
7131
|
}
|
|
7130
7132
|
/**
|
|
7131
7133
|
Check whether splitting at the given position is allowed.
|
|
7132
7134
|
*/
|
|
7133
|
-
function canSplit(doc, pos, depth = 1, typesAfter) {
|
|
7135
|
+
function canSplit$1(doc, pos, depth = 1, typesAfter) {
|
|
7134
7136
|
let $pos = doc.resolve(pos), base = $pos.depth - depth;
|
|
7135
7137
|
let innerType = (typesAfter && typesAfter[typesAfter.length - 1]) || $pos.parent;
|
|
7136
7138
|
if (base < 0 || $pos.parent.type.spec.isolating ||
|
|
@@ -7160,18 +7162,18 @@ function split(tr, pos, depth = 1, typesAfter) {
|
|
|
7160
7162
|
let typeAfter = typesAfter && typesAfter[i];
|
|
7161
7163
|
after = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
|
|
7162
7164
|
}
|
|
7163
|
-
tr.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true));
|
|
7165
|
+
tr.step(new ReplaceStep$1(pos, pos, new Slice(before.append(after), depth, depth), true));
|
|
7164
7166
|
}
|
|
7165
7167
|
/**
|
|
7166
7168
|
Test whether the blocks before and after a given position can be
|
|
7167
7169
|
joined.
|
|
7168
7170
|
*/
|
|
7169
|
-
function canJoin(doc, pos) {
|
|
7171
|
+
function canJoin$1(doc, pos) {
|
|
7170
7172
|
let $pos = doc.resolve(pos), index = $pos.index();
|
|
7171
|
-
return joinable($pos.nodeBefore, $pos.nodeAfter) &&
|
|
7173
|
+
return joinable$1($pos.nodeBefore, $pos.nodeAfter) &&
|
|
7172
7174
|
$pos.parent.canReplace(index, index + 1);
|
|
7173
7175
|
}
|
|
7174
|
-
function joinable(a, b) {
|
|
7176
|
+
function joinable$1(a, b) {
|
|
7175
7177
|
return !!(a && b && !a.isLeaf && a.canAppend(b));
|
|
7176
7178
|
}
|
|
7177
7179
|
/**
|
|
@@ -7196,7 +7198,7 @@ function joinPoint(doc, pos, dir = -1) {
|
|
|
7196
7198
|
before = $pos.node(d).maybeChild(index - 1);
|
|
7197
7199
|
after = $pos.node(d + 1);
|
|
7198
7200
|
}
|
|
7199
|
-
if (before && !before.isTextblock && joinable(before, after) &&
|
|
7201
|
+
if (before && !before.isTextblock && joinable$1(before, after) &&
|
|
7200
7202
|
$pos.node(d).canReplace(index, index + 1))
|
|
7201
7203
|
return pos;
|
|
7202
7204
|
if (d == 0)
|
|
@@ -7205,7 +7207,7 @@ function joinPoint(doc, pos, dir = -1) {
|
|
|
7205
7207
|
}
|
|
7206
7208
|
}
|
|
7207
7209
|
function join(tr, pos, depth) {
|
|
7208
|
-
let step = new ReplaceStep(pos - depth, pos + depth, Slice.empty, true);
|
|
7210
|
+
let step = new ReplaceStep$1(pos - depth, pos + depth, Slice.empty, true);
|
|
7209
7211
|
tr.step(step);
|
|
7210
7212
|
}
|
|
7211
7213
|
/**
|
|
@@ -7249,7 +7251,7 @@ function replaceStep(doc, from, to = from, slice = Slice.empty) {
|
|
|
7249
7251
|
let $from = doc.resolve(from), $to = doc.resolve(to);
|
|
7250
7252
|
// Optimization -- avoid work if it's obvious that it's not needed.
|
|
7251
7253
|
if (fitsTrivially($from, $to, slice))
|
|
7252
|
-
return new ReplaceStep(from, to, slice);
|
|
7254
|
+
return new ReplaceStep$1(from, to, slice);
|
|
7253
7255
|
return new Fitter($from, $to, slice).fit();
|
|
7254
7256
|
}
|
|
7255
7257
|
function fitsTrivially($from, $to, slice) {
|
|
@@ -7323,9 +7325,9 @@ class Fitter {
|
|
|
7323
7325
|
}
|
|
7324
7326
|
let slice = new Slice(content, openStart, openEnd);
|
|
7325
7327
|
if (moveInline > -1)
|
|
7326
|
-
return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize);
|
|
7328
|
+
return new ReplaceAroundStep$1($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize);
|
|
7327
7329
|
if (slice.size || $from.pos != this.$to.pos) // Don't generate no-op steps
|
|
7328
|
-
return new ReplaceStep($from.pos, $to.pos, slice);
|
|
7330
|
+
return new ReplaceStep$1($from.pos, $to.pos, slice);
|
|
7329
7331
|
return null;
|
|
7330
7332
|
}
|
|
7331
7333
|
// Find a position on the start spine of `this.unplaced` that has
|
|
@@ -7556,7 +7558,7 @@ function replaceRange(tr, from, to, slice) {
|
|
|
7556
7558
|
return tr.deleteRange(from, to);
|
|
7557
7559
|
let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
|
|
7558
7560
|
if (fitsTrivially($from, $to, slice))
|
|
7559
|
-
return tr.step(new ReplaceStep(from, to, slice));
|
|
7561
|
+
return tr.step(new ReplaceStep$1(from, to, slice));
|
|
7560
7562
|
let targetDepths = coveredDepths($from, tr.doc.resolve(to));
|
|
7561
7563
|
// Can't replace the whole document, so remove 0 if it's present
|
|
7562
7564
|
if (targetDepths[targetDepths.length - 1] == 0)
|
|
@@ -7686,7 +7688,7 @@ function coveredDepths($from, $to) {
|
|
|
7686
7688
|
/**
|
|
7687
7689
|
Update an attribute in a specific node.
|
|
7688
7690
|
*/
|
|
7689
|
-
class AttrStep extends Step {
|
|
7691
|
+
class AttrStep$1 extends Step$1 {
|
|
7690
7692
|
/**
|
|
7691
7693
|
Construct an attribute step.
|
|
7692
7694
|
*/
|
|
@@ -7709,23 +7711,23 @@ class AttrStep extends Step {
|
|
|
7709
7711
|
apply(doc) {
|
|
7710
7712
|
let node = doc.nodeAt(this.pos);
|
|
7711
7713
|
if (!node)
|
|
7712
|
-
return StepResult.fail("No node at attribute step's position");
|
|
7714
|
+
return StepResult$1.fail("No node at attribute step's position");
|
|
7713
7715
|
let attrs = Object.create(null);
|
|
7714
7716
|
for (let name in node.attrs)
|
|
7715
7717
|
attrs[name] = node.attrs[name];
|
|
7716
7718
|
attrs[this.attr] = this.value;
|
|
7717
7719
|
let updated = node.type.create(attrs, null, node.marks);
|
|
7718
|
-
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
7720
|
+
return StepResult$1.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
7719
7721
|
}
|
|
7720
7722
|
getMap() {
|
|
7721
|
-
return StepMap.empty;
|
|
7723
|
+
return StepMap$1.empty;
|
|
7722
7724
|
}
|
|
7723
7725
|
invert(doc) {
|
|
7724
|
-
return new AttrStep(this.pos, this.attr, doc.nodeAt(this.pos).attrs[this.attr]);
|
|
7726
|
+
return new AttrStep$1(this.pos, this.attr, doc.nodeAt(this.pos).attrs[this.attr]);
|
|
7725
7727
|
}
|
|
7726
7728
|
map(mapping) {
|
|
7727
7729
|
let pos = mapping.mapResult(this.pos, 1);
|
|
7728
|
-
return pos.deletedAfter ? null : new AttrStep(pos.pos, this.attr, this.value);
|
|
7730
|
+
return pos.deletedAfter ? null : new AttrStep$1(pos.pos, this.attr, this.value);
|
|
7729
7731
|
}
|
|
7730
7732
|
toJSON() {
|
|
7731
7733
|
return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
|
|
@@ -7733,14 +7735,14 @@ class AttrStep extends Step {
|
|
|
7733
7735
|
static fromJSON(schema, json) {
|
|
7734
7736
|
if (typeof json.pos != "number" || typeof json.attr != "string")
|
|
7735
7737
|
throw new RangeError("Invalid input for AttrStep.fromJSON");
|
|
7736
|
-
return new AttrStep(json.pos, json.attr, json.value);
|
|
7738
|
+
return new AttrStep$1(json.pos, json.attr, json.value);
|
|
7737
7739
|
}
|
|
7738
7740
|
}
|
|
7739
|
-
Step.jsonID("attr", AttrStep);
|
|
7741
|
+
Step$1.jsonID("attr", AttrStep$1);
|
|
7740
7742
|
/**
|
|
7741
7743
|
Update an attribute in the doc node.
|
|
7742
7744
|
*/
|
|
7743
|
-
class DocAttrStep extends Step {
|
|
7745
|
+
class DocAttrStep$1 extends Step$1 {
|
|
7744
7746
|
/**
|
|
7745
7747
|
Construct an attribute step.
|
|
7746
7748
|
*/
|
|
@@ -7761,13 +7763,13 @@ class DocAttrStep extends Step {
|
|
|
7761
7763
|
attrs[name] = doc.attrs[name];
|
|
7762
7764
|
attrs[this.attr] = this.value;
|
|
7763
7765
|
let updated = doc.type.create(attrs, doc.content, doc.marks);
|
|
7764
|
-
return StepResult.ok(updated);
|
|
7766
|
+
return StepResult$1.ok(updated);
|
|
7765
7767
|
}
|
|
7766
7768
|
getMap() {
|
|
7767
|
-
return StepMap.empty;
|
|
7769
|
+
return StepMap$1.empty;
|
|
7768
7770
|
}
|
|
7769
7771
|
invert(doc) {
|
|
7770
|
-
return new DocAttrStep(this.attr, doc.attrs[this.attr]);
|
|
7772
|
+
return new DocAttrStep$1(this.attr, doc.attrs[this.attr]);
|
|
7771
7773
|
}
|
|
7772
7774
|
map(mapping) {
|
|
7773
7775
|
return this;
|
|
@@ -7778,24 +7780,24 @@ class DocAttrStep extends Step {
|
|
|
7778
7780
|
static fromJSON(schema, json) {
|
|
7779
7781
|
if (typeof json.attr != "string")
|
|
7780
7782
|
throw new RangeError("Invalid input for DocAttrStep.fromJSON");
|
|
7781
|
-
return new DocAttrStep(json.attr, json.value);
|
|
7783
|
+
return new DocAttrStep$1(json.attr, json.value);
|
|
7782
7784
|
}
|
|
7783
7785
|
}
|
|
7784
|
-
Step.jsonID("docAttr", DocAttrStep);
|
|
7786
|
+
Step$1.jsonID("docAttr", DocAttrStep$1);
|
|
7785
7787
|
|
|
7786
7788
|
/**
|
|
7787
7789
|
@internal
|
|
7788
7790
|
*/
|
|
7789
|
-
let TransformError = class extends Error {
|
|
7791
|
+
let TransformError$1 = class extends Error {
|
|
7790
7792
|
};
|
|
7791
|
-
TransformError = function TransformError(message) {
|
|
7793
|
+
TransformError$1 = function TransformError(message) {
|
|
7792
7794
|
let err = Error.call(this, message);
|
|
7793
7795
|
err.__proto__ = TransformError.prototype;
|
|
7794
7796
|
return err;
|
|
7795
7797
|
};
|
|
7796
|
-
TransformError.prototype = Object.create(Error.prototype);
|
|
7797
|
-
TransformError.prototype.constructor = TransformError;
|
|
7798
|
-
TransformError.prototype.name = "TransformError";
|
|
7798
|
+
TransformError$1.prototype = Object.create(Error.prototype);
|
|
7799
|
+
TransformError$1.prototype.constructor = TransformError$1;
|
|
7800
|
+
TransformError$1.prototype.name = "TransformError";
|
|
7799
7801
|
/**
|
|
7800
7802
|
Abstraction to build up and track an array of
|
|
7801
7803
|
[steps](https://prosemirror.net/docs/ref/#transform.Step) representing a document transformation.
|
|
@@ -7838,7 +7840,7 @@ class Transform {
|
|
|
7838
7840
|
step(step) {
|
|
7839
7841
|
let result = this.maybeStep(step);
|
|
7840
7842
|
if (result.failed)
|
|
7841
|
-
throw new TransformError(result.failed);
|
|
7843
|
+
throw new TransformError$1(result.failed);
|
|
7842
7844
|
return this;
|
|
7843
7845
|
}
|
|
7844
7846
|
/**
|
|
@@ -7990,21 +7992,21 @@ class Transform {
|
|
|
7990
7992
|
to set attributes on the document itself.
|
|
7991
7993
|
*/
|
|
7992
7994
|
setNodeAttribute(pos, attr, value) {
|
|
7993
|
-
this.step(new AttrStep(pos, attr, value));
|
|
7995
|
+
this.step(new AttrStep$1(pos, attr, value));
|
|
7994
7996
|
return this;
|
|
7995
7997
|
}
|
|
7996
7998
|
/**
|
|
7997
7999
|
Set a single attribute on the document to a new value.
|
|
7998
8000
|
*/
|
|
7999
8001
|
setDocAttribute(attr, value) {
|
|
8000
|
-
this.step(new DocAttrStep(attr, value));
|
|
8002
|
+
this.step(new DocAttrStep$1(attr, value));
|
|
8001
8003
|
return this;
|
|
8002
8004
|
}
|
|
8003
8005
|
/**
|
|
8004
8006
|
Add a mark to the node at position `pos`.
|
|
8005
8007
|
*/
|
|
8006
8008
|
addNodeMark(pos, mark) {
|
|
8007
|
-
this.step(new AddNodeMarkStep(pos, mark));
|
|
8009
|
+
this.step(new AddNodeMarkStep$1(pos, mark));
|
|
8008
8010
|
return this;
|
|
8009
8011
|
}
|
|
8010
8012
|
/**
|
|
@@ -8020,7 +8022,7 @@ class Transform {
|
|
|
8020
8022
|
if (!mark)
|
|
8021
8023
|
return this;
|
|
8022
8024
|
}
|
|
8023
|
-
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
8025
|
+
this.step(new RemoveNodeMarkStep$1(pos, mark));
|
|
8024
8026
|
return this;
|
|
8025
8027
|
}
|
|
8026
8028
|
/**
|
|
@@ -8096,7 +8098,7 @@ const joinBackward$1 = (state, dispatch, view) => {
|
|
|
8096
8098
|
let $cut = findCutBefore($cursor);
|
|
8097
8099
|
// If there is no node before this, try to lift
|
|
8098
8100
|
if (!$cut) {
|
|
8099
|
-
let range = $cursor.blockRange(), target = range && liftTarget$
|
|
8101
|
+
let range = $cursor.blockRange(), target = range && liftTarget$2(range);
|
|
8100
8102
|
if (target == null)
|
|
8101
8103
|
return false;
|
|
8102
8104
|
if (dispatch)
|
|
@@ -8105,21 +8107,26 @@ const joinBackward$1 = (state, dispatch, view) => {
|
|
|
8105
8107
|
}
|
|
8106
8108
|
let before = $cut.nodeBefore;
|
|
8107
8109
|
// Apply the joining algorithm
|
|
8108
|
-
if (
|
|
8110
|
+
if (deleteBarrier(state, $cut, dispatch, -1))
|
|
8109
8111
|
return true;
|
|
8110
8112
|
// If the node below has no content and the node above is
|
|
8111
8113
|
// selectable, delete the node below and select the one above.
|
|
8112
8114
|
if ($cursor.parent.content.size == 0 &&
|
|
8113
8115
|
(textblockAt(before, "end") || NodeSelection.isSelectable(before))) {
|
|
8114
|
-
let
|
|
8115
|
-
|
|
8116
|
-
if (
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8116
|
+
for (let depth = $cursor.depth;; depth--) {
|
|
8117
|
+
let delStep = replaceStep$1(state.doc, $cursor.before(depth), $cursor.after(depth), Slice.empty);
|
|
8118
|
+
if (delStep && delStep.slice.size < delStep.to - delStep.from) {
|
|
8119
|
+
if (dispatch) {
|
|
8120
|
+
let tr = state.tr.step(delStep);
|
|
8121
|
+
tr.setSelection(textblockAt(before, "end")
|
|
8122
|
+
? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1)
|
|
8123
|
+
: NodeSelection.create(tr.doc, $cut.pos - before.nodeSize));
|
|
8124
|
+
dispatch(tr.scrollIntoView());
|
|
8125
|
+
}
|
|
8126
|
+
return true;
|
|
8121
8127
|
}
|
|
8122
|
-
|
|
8128
|
+
if (depth == 1 || $cursor.node(depth - 1).childCount > 1)
|
|
8129
|
+
break;
|
|
8123
8130
|
}
|
|
8124
8131
|
}
|
|
8125
8132
|
// If the node before is an atom, delete it
|
|
@@ -8175,7 +8182,7 @@ function joinTextblocksAround(state, $cut, dispatch) {
|
|
|
8175
8182
|
}
|
|
8176
8183
|
let step = replaceStep$1(state.doc, beforePos, afterPos, Slice.empty);
|
|
8177
8184
|
if (!step || step.from != beforePos ||
|
|
8178
|
-
step instanceof ReplaceStep$
|
|
8185
|
+
step instanceof ReplaceStep$2 && step.slice.size >= afterPos - beforePos)
|
|
8179
8186
|
return false;
|
|
8180
8187
|
if (dispatch) {
|
|
8181
8188
|
let tr = state.tr.step(step);
|
|
@@ -8251,7 +8258,7 @@ const joinForward$1 = (state, dispatch, view) => {
|
|
|
8251
8258
|
return false;
|
|
8252
8259
|
let after = $cut.nodeAfter;
|
|
8253
8260
|
// Try the joining algorithm
|
|
8254
|
-
if (deleteBarrier(state, $cut, dispatch))
|
|
8261
|
+
if (deleteBarrier(state, $cut, dispatch, 1))
|
|
8255
8262
|
return true;
|
|
8256
8263
|
// If the node above has no content and the node below is
|
|
8257
8264
|
// selectable, delete the node above and select the one below.
|
|
@@ -8319,7 +8326,7 @@ the sibling above it.
|
|
|
8319
8326
|
const joinUp$1 = (state, dispatch) => {
|
|
8320
8327
|
let sel = state.selection, nodeSel = sel instanceof NodeSelection, point;
|
|
8321
8328
|
if (nodeSel) {
|
|
8322
|
-
if (sel.node.isTextblock || !canJoin$
|
|
8329
|
+
if (sel.node.isTextblock || !canJoin$2(state.doc, sel.from))
|
|
8323
8330
|
return false;
|
|
8324
8331
|
point = sel.from;
|
|
8325
8332
|
}
|
|
@@ -8343,7 +8350,7 @@ that can be joined, with the sibling after it.
|
|
|
8343
8350
|
const joinDown$1 = (state, dispatch) => {
|
|
8344
8351
|
let sel = state.selection, point;
|
|
8345
8352
|
if (sel instanceof NodeSelection) {
|
|
8346
|
-
if (sel.node.isTextblock || !canJoin$
|
|
8353
|
+
if (sel.node.isTextblock || !canJoin$2(state.doc, sel.to))
|
|
8347
8354
|
return false;
|
|
8348
8355
|
point = sel.to;
|
|
8349
8356
|
}
|
|
@@ -8362,7 +8369,7 @@ selection that can be lifted, out of its parent node.
|
|
|
8362
8369
|
*/
|
|
8363
8370
|
const lift$1 = (state, dispatch) => {
|
|
8364
8371
|
let { $from, $to } = state.selection;
|
|
8365
|
-
let range = $from.blockRange($to), target = range && liftTarget$
|
|
8372
|
+
let range = $from.blockRange($to), target = range && liftTarget$2(range);
|
|
8366
8373
|
if (target == null)
|
|
8367
8374
|
return false;
|
|
8368
8375
|
if (dispatch)
|
|
@@ -8438,13 +8445,13 @@ const liftEmptyBlock$1 = (state, dispatch) => {
|
|
|
8438
8445
|
return false;
|
|
8439
8446
|
if ($cursor.depth > 1 && $cursor.after() != $cursor.end(-1)) {
|
|
8440
8447
|
let before = $cursor.before();
|
|
8441
|
-
if (canSplit$
|
|
8448
|
+
if (canSplit$2(state.doc, before)) {
|
|
8442
8449
|
if (dispatch)
|
|
8443
8450
|
dispatch(state.tr.split(before).scrollIntoView());
|
|
8444
8451
|
return true;
|
|
8445
8452
|
}
|
|
8446
8453
|
}
|
|
8447
|
-
let range = $cursor.blockRange(), target = range && liftTarget$
|
|
8454
|
+
let range = $cursor.blockRange(), target = range && liftTarget$2(range);
|
|
8448
8455
|
if (target == null)
|
|
8449
8456
|
return false;
|
|
8450
8457
|
if (dispatch)
|
|
@@ -8474,7 +8481,7 @@ function joinMaybeClear(state, $pos, dispatch) {
|
|
|
8474
8481
|
dispatch(state.tr.delete($pos.pos - before.nodeSize, $pos.pos).scrollIntoView());
|
|
8475
8482
|
return true;
|
|
8476
8483
|
}
|
|
8477
|
-
if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin$
|
|
8484
|
+
if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin$2(state.doc, $pos.pos)))
|
|
8478
8485
|
return false;
|
|
8479
8486
|
if (dispatch)
|
|
8480
8487
|
dispatch(state.tr
|
|
@@ -8483,13 +8490,12 @@ function joinMaybeClear(state, $pos, dispatch) {
|
|
|
8483
8490
|
.scrollIntoView());
|
|
8484
8491
|
return true;
|
|
8485
8492
|
}
|
|
8486
|
-
function deleteBarrier(state, $cut, dispatch) {
|
|
8493
|
+
function deleteBarrier(state, $cut, dispatch, dir) {
|
|
8487
8494
|
let before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match;
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
if (joinMaybeClear(state, $cut, dispatch))
|
|
8495
|
+
let isolated = before.type.spec.isolating || after.type.spec.isolating;
|
|
8496
|
+
if (!isolated && joinMaybeClear(state, $cut, dispatch))
|
|
8491
8497
|
return true;
|
|
8492
|
-
let canDelAfter = $cut.parent.canReplace($cut.index(), $cut.index() + 1);
|
|
8498
|
+
let canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);
|
|
8493
8499
|
if (canDelAfter &&
|
|
8494
8500
|
(conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) &&
|
|
8495
8501
|
match.matchType(conn[0] || after.type).validEnd) {
|
|
@@ -8498,16 +8504,16 @@ function deleteBarrier(state, $cut, dispatch) {
|
|
|
8498
8504
|
for (let i = conn.length - 1; i >= 0; i--)
|
|
8499
8505
|
wrap = Fragment.from(conn[i].create(null, wrap));
|
|
8500
8506
|
wrap = Fragment.from(before.copy(wrap));
|
|
8501
|
-
let tr = state.tr.step(new ReplaceAroundStep$
|
|
8507
|
+
let tr = state.tr.step(new ReplaceAroundStep$2($cut.pos - 1, end, $cut.pos, end, new Slice(wrap, 1, 0), conn.length, true));
|
|
8502
8508
|
let joinAt = end + 2 * conn.length;
|
|
8503
|
-
if (canJoin$
|
|
8509
|
+
if (canJoin$2(tr.doc, joinAt))
|
|
8504
8510
|
tr.join(joinAt);
|
|
8505
8511
|
dispatch(tr.scrollIntoView());
|
|
8506
8512
|
}
|
|
8507
8513
|
return true;
|
|
8508
8514
|
}
|
|
8509
|
-
let selAfter = Selection.findFrom($cut, 1);
|
|
8510
|
-
let range = selAfter && selAfter.$from.blockRange(selAfter.$to), target = range && liftTarget$
|
|
8515
|
+
let selAfter = after.type.spec.isolating || (dir > 0 && isolated) ? null : Selection.findFrom($cut, 1);
|
|
8516
|
+
let range = selAfter && selAfter.$from.blockRange(selAfter.$to), target = range && liftTarget$2(range);
|
|
8511
8517
|
if (target != null && target >= $cut.depth) {
|
|
8512
8518
|
if (dispatch)
|
|
8513
8519
|
dispatch(state.tr.lift(range, target).scrollIntoView());
|
|
@@ -8529,7 +8535,7 @@ function deleteBarrier(state, $cut, dispatch) {
|
|
|
8529
8535
|
let end = Fragment.empty;
|
|
8530
8536
|
for (let i = wrap.length - 1; i >= 0; i--)
|
|
8531
8537
|
end = Fragment.from(wrap[i].copy(end));
|
|
8532
|
-
let tr = state.tr.step(new ReplaceAroundStep$
|
|
8538
|
+
let tr = state.tr.step(new ReplaceAroundStep$2($cut.pos - wrap.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new Slice(end, wrap.length, 0), 0, true));
|
|
8533
8539
|
dispatch(tr.scrollIntoView());
|
|
8534
8540
|
}
|
|
8535
8541
|
return true;
|
|
@@ -8569,7 +8575,7 @@ attributes.
|
|
|
8569
8575
|
function wrapIn$1(nodeType, attrs = null) {
|
|
8570
8576
|
return function (state, dispatch) {
|
|
8571
8577
|
let { $from, $to } = state.selection;
|
|
8572
|
-
let range = $from.blockRange($to), wrapping = range && findWrapping$
|
|
8578
|
+
let range = $from.blockRange($to), wrapping = range && findWrapping$2(range, nodeType, attrs);
|
|
8573
8579
|
if (!wrapping)
|
|
8574
8580
|
return false;
|
|
8575
8581
|
if (dispatch)
|
|
@@ -8617,6 +8623,949 @@ typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform)
|
|
|
8617
8623
|
// @ts-ignore
|
|
8618
8624
|
: typeof os != "undefined" && os.platform ? os.platform() == "darwin" : false;
|
|
8619
8625
|
|
|
8626
|
+
// Recovery values encode a range index and an offset. They are
|
|
8627
|
+
// represented as numbers, because tons of them will be created when
|
|
8628
|
+
// mapping, for example, a large number of decorations. The number's
|
|
8629
|
+
// lower 16 bits provide the index, the remaining bits the offset.
|
|
8630
|
+
//
|
|
8631
|
+
// Note: We intentionally don't use bit shift operators to en- and
|
|
8632
|
+
// decode these, since those clip to 32 bits, which we might in rare
|
|
8633
|
+
// cases want to overflow. A 64-bit float can represent 48-bit
|
|
8634
|
+
// integers precisely.
|
|
8635
|
+
const lower16 = 0xffff;
|
|
8636
|
+
const factor16 = Math.pow(2, 16);
|
|
8637
|
+
function makeRecover(index, offset) { return index + offset * factor16; }
|
|
8638
|
+
function recoverIndex(value) { return value & lower16; }
|
|
8639
|
+
function recoverOffset(value) { return (value - (value & lower16)) / factor16; }
|
|
8640
|
+
const DEL_BEFORE = 1, DEL_AFTER = 2, DEL_ACROSS = 4, DEL_SIDE = 8;
|
|
8641
|
+
/**
|
|
8642
|
+
An object representing a mapped position with extra
|
|
8643
|
+
information.
|
|
8644
|
+
*/
|
|
8645
|
+
class MapResult {
|
|
8646
|
+
/**
|
|
8647
|
+
@internal
|
|
8648
|
+
*/
|
|
8649
|
+
constructor(
|
|
8650
|
+
/**
|
|
8651
|
+
The mapped version of the position.
|
|
8652
|
+
*/
|
|
8653
|
+
pos,
|
|
8654
|
+
/**
|
|
8655
|
+
@internal
|
|
8656
|
+
*/
|
|
8657
|
+
delInfo,
|
|
8658
|
+
/**
|
|
8659
|
+
@internal
|
|
8660
|
+
*/
|
|
8661
|
+
recover) {
|
|
8662
|
+
this.pos = pos;
|
|
8663
|
+
this.delInfo = delInfo;
|
|
8664
|
+
this.recover = recover;
|
|
8665
|
+
}
|
|
8666
|
+
/**
|
|
8667
|
+
Tells you whether the position was deleted, that is, whether the
|
|
8668
|
+
step removed the token on the side queried (via the `assoc`)
|
|
8669
|
+
argument from the document.
|
|
8670
|
+
*/
|
|
8671
|
+
get deleted() { return (this.delInfo & DEL_SIDE) > 0; }
|
|
8672
|
+
/**
|
|
8673
|
+
Tells you whether the token before the mapped position was deleted.
|
|
8674
|
+
*/
|
|
8675
|
+
get deletedBefore() { return (this.delInfo & (DEL_BEFORE | DEL_ACROSS)) > 0; }
|
|
8676
|
+
/**
|
|
8677
|
+
True when the token after the mapped position was deleted.
|
|
8678
|
+
*/
|
|
8679
|
+
get deletedAfter() { return (this.delInfo & (DEL_AFTER | DEL_ACROSS)) > 0; }
|
|
8680
|
+
/**
|
|
8681
|
+
Tells whether any of the steps mapped through deletes across the
|
|
8682
|
+
position (including both the token before and after the
|
|
8683
|
+
position).
|
|
8684
|
+
*/
|
|
8685
|
+
get deletedAcross() { return (this.delInfo & DEL_ACROSS) > 0; }
|
|
8686
|
+
}
|
|
8687
|
+
/**
|
|
8688
|
+
A map describing the deletions and insertions made by a step, which
|
|
8689
|
+
can be used to find the correspondence between positions in the
|
|
8690
|
+
pre-step version of a document and the same position in the
|
|
8691
|
+
post-step version.
|
|
8692
|
+
*/
|
|
8693
|
+
class StepMap {
|
|
8694
|
+
/**
|
|
8695
|
+
Create a position map. The modifications to the document are
|
|
8696
|
+
represented as an array of numbers, in which each group of three
|
|
8697
|
+
represents a modified chunk as `[start, oldSize, newSize]`.
|
|
8698
|
+
*/
|
|
8699
|
+
constructor(
|
|
8700
|
+
/**
|
|
8701
|
+
@internal
|
|
8702
|
+
*/
|
|
8703
|
+
ranges,
|
|
8704
|
+
/**
|
|
8705
|
+
@internal
|
|
8706
|
+
*/
|
|
8707
|
+
inverted = false) {
|
|
8708
|
+
this.ranges = ranges;
|
|
8709
|
+
this.inverted = inverted;
|
|
8710
|
+
if (!ranges.length && StepMap.empty)
|
|
8711
|
+
return StepMap.empty;
|
|
8712
|
+
}
|
|
8713
|
+
/**
|
|
8714
|
+
@internal
|
|
8715
|
+
*/
|
|
8716
|
+
recover(value) {
|
|
8717
|
+
let diff = 0, index = recoverIndex(value);
|
|
8718
|
+
if (!this.inverted)
|
|
8719
|
+
for (let i = 0; i < index; i++)
|
|
8720
|
+
diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
|
|
8721
|
+
return this.ranges[index * 3] + diff + recoverOffset(value);
|
|
8722
|
+
}
|
|
8723
|
+
mapResult(pos, assoc = 1) { return this._map(pos, assoc, false); }
|
|
8724
|
+
map(pos, assoc = 1) { return this._map(pos, assoc, true); }
|
|
8725
|
+
/**
|
|
8726
|
+
@internal
|
|
8727
|
+
*/
|
|
8728
|
+
_map(pos, assoc, simple) {
|
|
8729
|
+
let diff = 0, oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
|
|
8730
|
+
for (let i = 0; i < this.ranges.length; i += 3) {
|
|
8731
|
+
let start = this.ranges[i] - (this.inverted ? diff : 0);
|
|
8732
|
+
if (start > pos)
|
|
8733
|
+
break;
|
|
8734
|
+
let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex], end = start + oldSize;
|
|
8735
|
+
if (pos <= end) {
|
|
8736
|
+
let side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;
|
|
8737
|
+
let result = start + diff + (side < 0 ? 0 : newSize);
|
|
8738
|
+
if (simple)
|
|
8739
|
+
return result;
|
|
8740
|
+
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
8741
|
+
let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
8742
|
+
if (assoc < 0 ? pos != start : pos != end)
|
|
8743
|
+
del |= DEL_SIDE;
|
|
8744
|
+
return new MapResult(result, del, recover);
|
|
8745
|
+
}
|
|
8746
|
+
diff += newSize - oldSize;
|
|
8747
|
+
}
|
|
8748
|
+
return simple ? pos + diff : new MapResult(pos + diff, 0, null);
|
|
8749
|
+
}
|
|
8750
|
+
/**
|
|
8751
|
+
@internal
|
|
8752
|
+
*/
|
|
8753
|
+
touches(pos, recover) {
|
|
8754
|
+
let diff = 0, index = recoverIndex(recover);
|
|
8755
|
+
let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
|
|
8756
|
+
for (let i = 0; i < this.ranges.length; i += 3) {
|
|
8757
|
+
let start = this.ranges[i] - (this.inverted ? diff : 0);
|
|
8758
|
+
if (start > pos)
|
|
8759
|
+
break;
|
|
8760
|
+
let oldSize = this.ranges[i + oldIndex], end = start + oldSize;
|
|
8761
|
+
if (pos <= end && i == index * 3)
|
|
8762
|
+
return true;
|
|
8763
|
+
diff += this.ranges[i + newIndex] - oldSize;
|
|
8764
|
+
}
|
|
8765
|
+
return false;
|
|
8766
|
+
}
|
|
8767
|
+
/**
|
|
8768
|
+
Calls the given function on each of the changed ranges included in
|
|
8769
|
+
this map.
|
|
8770
|
+
*/
|
|
8771
|
+
forEach(f) {
|
|
8772
|
+
let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
|
|
8773
|
+
for (let i = 0, diff = 0; i < this.ranges.length; i += 3) {
|
|
8774
|
+
let start = this.ranges[i], oldStart = start - (this.inverted ? diff : 0), newStart = start + (this.inverted ? 0 : diff);
|
|
8775
|
+
let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex];
|
|
8776
|
+
f(oldStart, oldStart + oldSize, newStart, newStart + newSize);
|
|
8777
|
+
diff += newSize - oldSize;
|
|
8778
|
+
}
|
|
8779
|
+
}
|
|
8780
|
+
/**
|
|
8781
|
+
Create an inverted version of this map. The result can be used to
|
|
8782
|
+
map positions in the post-step document to the pre-step document.
|
|
8783
|
+
*/
|
|
8784
|
+
invert() {
|
|
8785
|
+
return new StepMap(this.ranges, !this.inverted);
|
|
8786
|
+
}
|
|
8787
|
+
/**
|
|
8788
|
+
@internal
|
|
8789
|
+
*/
|
|
8790
|
+
toString() {
|
|
8791
|
+
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
|
|
8792
|
+
}
|
|
8793
|
+
/**
|
|
8794
|
+
Create a map that moves all positions by offset `n` (which may be
|
|
8795
|
+
negative). This can be useful when applying steps meant for a
|
|
8796
|
+
sub-document to a larger document, or vice-versa.
|
|
8797
|
+
*/
|
|
8798
|
+
static offset(n) {
|
|
8799
|
+
return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);
|
|
8800
|
+
}
|
|
8801
|
+
}
|
|
8802
|
+
/**
|
|
8803
|
+
A StepMap that contains no changed ranges.
|
|
8804
|
+
*/
|
|
8805
|
+
StepMap.empty = new StepMap([]);
|
|
8806
|
+
|
|
8807
|
+
const stepsByID = Object.create(null);
|
|
8808
|
+
/**
|
|
8809
|
+
A step object represents an atomic change. It generally applies
|
|
8810
|
+
only to the document it was created for, since the positions
|
|
8811
|
+
stored in it will only make sense for that document.
|
|
8812
|
+
|
|
8813
|
+
New steps are defined by creating classes that extend `Step`,
|
|
8814
|
+
overriding the `apply`, `invert`, `map`, `getMap` and `fromJSON`
|
|
8815
|
+
methods, and registering your class with a unique
|
|
8816
|
+
JSON-serialization identifier using
|
|
8817
|
+
[`Step.jsonID`](https://prosemirror.net/docs/ref/#transform.Step^jsonID).
|
|
8818
|
+
*/
|
|
8819
|
+
class Step {
|
|
8820
|
+
/**
|
|
8821
|
+
Get the step map that represents the changes made by this step,
|
|
8822
|
+
and which can be used to transform between positions in the old
|
|
8823
|
+
and the new document.
|
|
8824
|
+
*/
|
|
8825
|
+
getMap() { return StepMap.empty; }
|
|
8826
|
+
/**
|
|
8827
|
+
Try to merge this step with another one, to be applied directly
|
|
8828
|
+
after it. Returns the merged step when possible, null if the
|
|
8829
|
+
steps can't be merged.
|
|
8830
|
+
*/
|
|
8831
|
+
merge(other) { return null; }
|
|
8832
|
+
/**
|
|
8833
|
+
Deserialize a step from its JSON representation. Will call
|
|
8834
|
+
through to the step class' own implementation of this method.
|
|
8835
|
+
*/
|
|
8836
|
+
static fromJSON(schema, json) {
|
|
8837
|
+
if (!json || !json.stepType)
|
|
8838
|
+
throw new RangeError("Invalid input for Step.fromJSON");
|
|
8839
|
+
let type = stepsByID[json.stepType];
|
|
8840
|
+
if (!type)
|
|
8841
|
+
throw new RangeError(`No step type ${json.stepType} defined`);
|
|
8842
|
+
return type.fromJSON(schema, json);
|
|
8843
|
+
}
|
|
8844
|
+
/**
|
|
8845
|
+
To be able to serialize steps to JSON, each step needs a string
|
|
8846
|
+
ID to attach to its JSON representation. Use this method to
|
|
8847
|
+
register an ID for your step classes. Try to pick something
|
|
8848
|
+
that's unlikely to clash with steps from other modules.
|
|
8849
|
+
*/
|
|
8850
|
+
static jsonID(id, stepClass) {
|
|
8851
|
+
if (id in stepsByID)
|
|
8852
|
+
throw new RangeError("Duplicate use of step JSON ID " + id);
|
|
8853
|
+
stepsByID[id] = stepClass;
|
|
8854
|
+
stepClass.prototype.jsonID = id;
|
|
8855
|
+
return stepClass;
|
|
8856
|
+
}
|
|
8857
|
+
}
|
|
8858
|
+
/**
|
|
8859
|
+
The result of [applying](https://prosemirror.net/docs/ref/#transform.Step.apply) a step. Contains either a
|
|
8860
|
+
new document or a failure value.
|
|
8861
|
+
*/
|
|
8862
|
+
class StepResult {
|
|
8863
|
+
/**
|
|
8864
|
+
@internal
|
|
8865
|
+
*/
|
|
8866
|
+
constructor(
|
|
8867
|
+
/**
|
|
8868
|
+
The transformed document, if successful.
|
|
8869
|
+
*/
|
|
8870
|
+
doc,
|
|
8871
|
+
/**
|
|
8872
|
+
The failure message, if unsuccessful.
|
|
8873
|
+
*/
|
|
8874
|
+
failed) {
|
|
8875
|
+
this.doc = doc;
|
|
8876
|
+
this.failed = failed;
|
|
8877
|
+
}
|
|
8878
|
+
/**
|
|
8879
|
+
Create a successful step result.
|
|
8880
|
+
*/
|
|
8881
|
+
static ok(doc) { return new StepResult(doc, null); }
|
|
8882
|
+
/**
|
|
8883
|
+
Create a failed step result.
|
|
8884
|
+
*/
|
|
8885
|
+
static fail(message) { return new StepResult(null, message); }
|
|
8886
|
+
/**
|
|
8887
|
+
Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
|
|
8888
|
+
arguments. Create a successful result if it succeeds, and a
|
|
8889
|
+
failed one if it throws a `ReplaceError`.
|
|
8890
|
+
*/
|
|
8891
|
+
static fromReplace(doc, from, to, slice) {
|
|
8892
|
+
try {
|
|
8893
|
+
return StepResult.ok(doc.replace(from, to, slice));
|
|
8894
|
+
}
|
|
8895
|
+
catch (e) {
|
|
8896
|
+
if (e instanceof ReplaceError)
|
|
8897
|
+
return StepResult.fail(e.message);
|
|
8898
|
+
throw e;
|
|
8899
|
+
}
|
|
8900
|
+
}
|
|
8901
|
+
}
|
|
8902
|
+
|
|
8903
|
+
function mapFragment(fragment, f, parent) {
|
|
8904
|
+
let mapped = [];
|
|
8905
|
+
for (let i = 0; i < fragment.childCount; i++) {
|
|
8906
|
+
let child = fragment.child(i);
|
|
8907
|
+
if (child.content.size)
|
|
8908
|
+
child = child.copy(mapFragment(child.content, f, child));
|
|
8909
|
+
if (child.isInline)
|
|
8910
|
+
child = f(child, parent, i);
|
|
8911
|
+
mapped.push(child);
|
|
8912
|
+
}
|
|
8913
|
+
return Fragment.fromArray(mapped);
|
|
8914
|
+
}
|
|
8915
|
+
/**
|
|
8916
|
+
Add a mark to all inline content between two positions.
|
|
8917
|
+
*/
|
|
8918
|
+
class AddMarkStep extends Step {
|
|
8919
|
+
/**
|
|
8920
|
+
Create a mark step.
|
|
8921
|
+
*/
|
|
8922
|
+
constructor(
|
|
8923
|
+
/**
|
|
8924
|
+
The start of the marked range.
|
|
8925
|
+
*/
|
|
8926
|
+
from,
|
|
8927
|
+
/**
|
|
8928
|
+
The end of the marked range.
|
|
8929
|
+
*/
|
|
8930
|
+
to,
|
|
8931
|
+
/**
|
|
8932
|
+
The mark to add.
|
|
8933
|
+
*/
|
|
8934
|
+
mark) {
|
|
8935
|
+
super();
|
|
8936
|
+
this.from = from;
|
|
8937
|
+
this.to = to;
|
|
8938
|
+
this.mark = mark;
|
|
8939
|
+
}
|
|
8940
|
+
apply(doc) {
|
|
8941
|
+
let oldSlice = doc.slice(this.from, this.to), $from = doc.resolve(this.from);
|
|
8942
|
+
let parent = $from.node($from.sharedDepth(this.to));
|
|
8943
|
+
let slice = new Slice(mapFragment(oldSlice.content, (node, parent) => {
|
|
8944
|
+
if (!node.isAtom || !parent.type.allowsMarkType(this.mark.type))
|
|
8945
|
+
return node;
|
|
8946
|
+
return node.mark(this.mark.addToSet(node.marks));
|
|
8947
|
+
}, parent), oldSlice.openStart, oldSlice.openEnd);
|
|
8948
|
+
return StepResult.fromReplace(doc, this.from, this.to, slice);
|
|
8949
|
+
}
|
|
8950
|
+
invert() {
|
|
8951
|
+
return new RemoveMarkStep(this.from, this.to, this.mark);
|
|
8952
|
+
}
|
|
8953
|
+
map(mapping) {
|
|
8954
|
+
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
8955
|
+
if (from.deleted && to.deleted || from.pos >= to.pos)
|
|
8956
|
+
return null;
|
|
8957
|
+
return new AddMarkStep(from.pos, to.pos, this.mark);
|
|
8958
|
+
}
|
|
8959
|
+
merge(other) {
|
|
8960
|
+
if (other instanceof AddMarkStep &&
|
|
8961
|
+
other.mark.eq(this.mark) &&
|
|
8962
|
+
this.from <= other.to && this.to >= other.from)
|
|
8963
|
+
return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
8964
|
+
return null;
|
|
8965
|
+
}
|
|
8966
|
+
toJSON() {
|
|
8967
|
+
return { stepType: "addMark", mark: this.mark.toJSON(),
|
|
8968
|
+
from: this.from, to: this.to };
|
|
8969
|
+
}
|
|
8970
|
+
/**
|
|
8971
|
+
@internal
|
|
8972
|
+
*/
|
|
8973
|
+
static fromJSON(schema, json) {
|
|
8974
|
+
if (typeof json.from != "number" || typeof json.to != "number")
|
|
8975
|
+
throw new RangeError("Invalid input for AddMarkStep.fromJSON");
|
|
8976
|
+
return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
Step.jsonID("addMark", AddMarkStep);
|
|
8980
|
+
/**
|
|
8981
|
+
Remove a mark from all inline content between two positions.
|
|
8982
|
+
*/
|
|
8983
|
+
class RemoveMarkStep extends Step {
|
|
8984
|
+
/**
|
|
8985
|
+
Create a mark-removing step.
|
|
8986
|
+
*/
|
|
8987
|
+
constructor(
|
|
8988
|
+
/**
|
|
8989
|
+
The start of the unmarked range.
|
|
8990
|
+
*/
|
|
8991
|
+
from,
|
|
8992
|
+
/**
|
|
8993
|
+
The end of the unmarked range.
|
|
8994
|
+
*/
|
|
8995
|
+
to,
|
|
8996
|
+
/**
|
|
8997
|
+
The mark to remove.
|
|
8998
|
+
*/
|
|
8999
|
+
mark) {
|
|
9000
|
+
super();
|
|
9001
|
+
this.from = from;
|
|
9002
|
+
this.to = to;
|
|
9003
|
+
this.mark = mark;
|
|
9004
|
+
}
|
|
9005
|
+
apply(doc) {
|
|
9006
|
+
let oldSlice = doc.slice(this.from, this.to);
|
|
9007
|
+
let slice = new Slice(mapFragment(oldSlice.content, node => {
|
|
9008
|
+
return node.mark(this.mark.removeFromSet(node.marks));
|
|
9009
|
+
}, doc), oldSlice.openStart, oldSlice.openEnd);
|
|
9010
|
+
return StepResult.fromReplace(doc, this.from, this.to, slice);
|
|
9011
|
+
}
|
|
9012
|
+
invert() {
|
|
9013
|
+
return new AddMarkStep(this.from, this.to, this.mark);
|
|
9014
|
+
}
|
|
9015
|
+
map(mapping) {
|
|
9016
|
+
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
9017
|
+
if (from.deleted && to.deleted || from.pos >= to.pos)
|
|
9018
|
+
return null;
|
|
9019
|
+
return new RemoveMarkStep(from.pos, to.pos, this.mark);
|
|
9020
|
+
}
|
|
9021
|
+
merge(other) {
|
|
9022
|
+
if (other instanceof RemoveMarkStep &&
|
|
9023
|
+
other.mark.eq(this.mark) &&
|
|
9024
|
+
this.from <= other.to && this.to >= other.from)
|
|
9025
|
+
return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
|
|
9026
|
+
return null;
|
|
9027
|
+
}
|
|
9028
|
+
toJSON() {
|
|
9029
|
+
return { stepType: "removeMark", mark: this.mark.toJSON(),
|
|
9030
|
+
from: this.from, to: this.to };
|
|
9031
|
+
}
|
|
9032
|
+
/**
|
|
9033
|
+
@internal
|
|
9034
|
+
*/
|
|
9035
|
+
static fromJSON(schema, json) {
|
|
9036
|
+
if (typeof json.from != "number" || typeof json.to != "number")
|
|
9037
|
+
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
|
|
9038
|
+
return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
|
|
9039
|
+
}
|
|
9040
|
+
}
|
|
9041
|
+
Step.jsonID("removeMark", RemoveMarkStep);
|
|
9042
|
+
/**
|
|
9043
|
+
Add a mark to a specific node.
|
|
9044
|
+
*/
|
|
9045
|
+
class AddNodeMarkStep extends Step {
|
|
9046
|
+
/**
|
|
9047
|
+
Create a node mark step.
|
|
9048
|
+
*/
|
|
9049
|
+
constructor(
|
|
9050
|
+
/**
|
|
9051
|
+
The position of the target node.
|
|
9052
|
+
*/
|
|
9053
|
+
pos,
|
|
9054
|
+
/**
|
|
9055
|
+
The mark to add.
|
|
9056
|
+
*/
|
|
9057
|
+
mark) {
|
|
9058
|
+
super();
|
|
9059
|
+
this.pos = pos;
|
|
9060
|
+
this.mark = mark;
|
|
9061
|
+
}
|
|
9062
|
+
apply(doc) {
|
|
9063
|
+
let node = doc.nodeAt(this.pos);
|
|
9064
|
+
if (!node)
|
|
9065
|
+
return StepResult.fail("No node at mark step's position");
|
|
9066
|
+
let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
|
|
9067
|
+
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
9068
|
+
}
|
|
9069
|
+
invert(doc) {
|
|
9070
|
+
let node = doc.nodeAt(this.pos);
|
|
9071
|
+
if (node) {
|
|
9072
|
+
let newSet = this.mark.addToSet(node.marks);
|
|
9073
|
+
if (newSet.length == node.marks.length) {
|
|
9074
|
+
for (let i = 0; i < node.marks.length; i++)
|
|
9075
|
+
if (!node.marks[i].isInSet(newSet))
|
|
9076
|
+
return new AddNodeMarkStep(this.pos, node.marks[i]);
|
|
9077
|
+
return new AddNodeMarkStep(this.pos, this.mark);
|
|
9078
|
+
}
|
|
9079
|
+
}
|
|
9080
|
+
return new RemoveNodeMarkStep(this.pos, this.mark);
|
|
9081
|
+
}
|
|
9082
|
+
map(mapping) {
|
|
9083
|
+
let pos = mapping.mapResult(this.pos, 1);
|
|
9084
|
+
return pos.deletedAfter ? null : new AddNodeMarkStep(pos.pos, this.mark);
|
|
9085
|
+
}
|
|
9086
|
+
toJSON() {
|
|
9087
|
+
return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
9088
|
+
}
|
|
9089
|
+
/**
|
|
9090
|
+
@internal
|
|
9091
|
+
*/
|
|
9092
|
+
static fromJSON(schema, json) {
|
|
9093
|
+
if (typeof json.pos != "number")
|
|
9094
|
+
throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
|
|
9095
|
+
return new AddNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
|
|
9096
|
+
}
|
|
9097
|
+
}
|
|
9098
|
+
Step.jsonID("addNodeMark", AddNodeMarkStep);
|
|
9099
|
+
/**
|
|
9100
|
+
Remove a mark from a specific node.
|
|
9101
|
+
*/
|
|
9102
|
+
class RemoveNodeMarkStep extends Step {
|
|
9103
|
+
/**
|
|
9104
|
+
Create a mark-removing step.
|
|
9105
|
+
*/
|
|
9106
|
+
constructor(
|
|
9107
|
+
/**
|
|
9108
|
+
The position of the target node.
|
|
9109
|
+
*/
|
|
9110
|
+
pos,
|
|
9111
|
+
/**
|
|
9112
|
+
The mark to remove.
|
|
9113
|
+
*/
|
|
9114
|
+
mark) {
|
|
9115
|
+
super();
|
|
9116
|
+
this.pos = pos;
|
|
9117
|
+
this.mark = mark;
|
|
9118
|
+
}
|
|
9119
|
+
apply(doc) {
|
|
9120
|
+
let node = doc.nodeAt(this.pos);
|
|
9121
|
+
if (!node)
|
|
9122
|
+
return StepResult.fail("No node at mark step's position");
|
|
9123
|
+
let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
|
|
9124
|
+
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
9125
|
+
}
|
|
9126
|
+
invert(doc) {
|
|
9127
|
+
let node = doc.nodeAt(this.pos);
|
|
9128
|
+
if (!node || !this.mark.isInSet(node.marks))
|
|
9129
|
+
return this;
|
|
9130
|
+
return new AddNodeMarkStep(this.pos, this.mark);
|
|
9131
|
+
}
|
|
9132
|
+
map(mapping) {
|
|
9133
|
+
let pos = mapping.mapResult(this.pos, 1);
|
|
9134
|
+
return pos.deletedAfter ? null : new RemoveNodeMarkStep(pos.pos, this.mark);
|
|
9135
|
+
}
|
|
9136
|
+
toJSON() {
|
|
9137
|
+
return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
9138
|
+
}
|
|
9139
|
+
/**
|
|
9140
|
+
@internal
|
|
9141
|
+
*/
|
|
9142
|
+
static fromJSON(schema, json) {
|
|
9143
|
+
if (typeof json.pos != "number")
|
|
9144
|
+
throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
|
|
9145
|
+
return new RemoveNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
|
|
9146
|
+
}
|
|
9147
|
+
}
|
|
9148
|
+
Step.jsonID("removeNodeMark", RemoveNodeMarkStep);
|
|
9149
|
+
|
|
9150
|
+
/**
|
|
9151
|
+
Replace a part of the document with a slice of new content.
|
|
9152
|
+
*/
|
|
9153
|
+
class ReplaceStep extends Step {
|
|
9154
|
+
/**
|
|
9155
|
+
The given `slice` should fit the 'gap' between `from` and
|
|
9156
|
+
`to`—the depths must line up, and the surrounding nodes must be
|
|
9157
|
+
able to be joined with the open sides of the slice. When
|
|
9158
|
+
`structure` is true, the step will fail if the content between
|
|
9159
|
+
from and to is not just a sequence of closing and then opening
|
|
9160
|
+
tokens (this is to guard against rebased replace steps
|
|
9161
|
+
overwriting something they weren't supposed to).
|
|
9162
|
+
*/
|
|
9163
|
+
constructor(
|
|
9164
|
+
/**
|
|
9165
|
+
The start position of the replaced range.
|
|
9166
|
+
*/
|
|
9167
|
+
from,
|
|
9168
|
+
/**
|
|
9169
|
+
The end position of the replaced range.
|
|
9170
|
+
*/
|
|
9171
|
+
to,
|
|
9172
|
+
/**
|
|
9173
|
+
The slice to insert.
|
|
9174
|
+
*/
|
|
9175
|
+
slice,
|
|
9176
|
+
/**
|
|
9177
|
+
@internal
|
|
9178
|
+
*/
|
|
9179
|
+
structure = false) {
|
|
9180
|
+
super();
|
|
9181
|
+
this.from = from;
|
|
9182
|
+
this.to = to;
|
|
9183
|
+
this.slice = slice;
|
|
9184
|
+
this.structure = structure;
|
|
9185
|
+
}
|
|
9186
|
+
apply(doc) {
|
|
9187
|
+
if (this.structure && contentBetween(doc, this.from, this.to))
|
|
9188
|
+
return StepResult.fail("Structure replace would overwrite content");
|
|
9189
|
+
return StepResult.fromReplace(doc, this.from, this.to, this.slice);
|
|
9190
|
+
}
|
|
9191
|
+
getMap() {
|
|
9192
|
+
return new StepMap([this.from, this.to - this.from, this.slice.size]);
|
|
9193
|
+
}
|
|
9194
|
+
invert(doc) {
|
|
9195
|
+
return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
|
|
9196
|
+
}
|
|
9197
|
+
map(mapping) {
|
|
9198
|
+
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
9199
|
+
if (from.deletedAcross && to.deletedAcross)
|
|
9200
|
+
return null;
|
|
9201
|
+
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
|
|
9202
|
+
}
|
|
9203
|
+
merge(other) {
|
|
9204
|
+
if (!(other instanceof ReplaceStep) || other.structure || this.structure)
|
|
9205
|
+
return null;
|
|
9206
|
+
if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {
|
|
9207
|
+
let slice = this.slice.size + other.slice.size == 0 ? Slice.empty
|
|
9208
|
+
: new Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);
|
|
9209
|
+
return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);
|
|
9210
|
+
}
|
|
9211
|
+
else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {
|
|
9212
|
+
let slice = this.slice.size + other.slice.size == 0 ? Slice.empty
|
|
9213
|
+
: new Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);
|
|
9214
|
+
return new ReplaceStep(other.from, this.to, slice, this.structure);
|
|
9215
|
+
}
|
|
9216
|
+
else {
|
|
9217
|
+
return null;
|
|
9218
|
+
}
|
|
9219
|
+
}
|
|
9220
|
+
toJSON() {
|
|
9221
|
+
let json = { stepType: "replace", from: this.from, to: this.to };
|
|
9222
|
+
if (this.slice.size)
|
|
9223
|
+
json.slice = this.slice.toJSON();
|
|
9224
|
+
if (this.structure)
|
|
9225
|
+
json.structure = true;
|
|
9226
|
+
return json;
|
|
9227
|
+
}
|
|
9228
|
+
/**
|
|
9229
|
+
@internal
|
|
9230
|
+
*/
|
|
9231
|
+
static fromJSON(schema, json) {
|
|
9232
|
+
if (typeof json.from != "number" || typeof json.to != "number")
|
|
9233
|
+
throw new RangeError("Invalid input for ReplaceStep.fromJSON");
|
|
9234
|
+
return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
|
|
9235
|
+
}
|
|
9236
|
+
}
|
|
9237
|
+
Step.jsonID("replace", ReplaceStep);
|
|
9238
|
+
/**
|
|
9239
|
+
Replace a part of the document with a slice of content, but
|
|
9240
|
+
preserve a range of the replaced content by moving it into the
|
|
9241
|
+
slice.
|
|
9242
|
+
*/
|
|
9243
|
+
class ReplaceAroundStep extends Step {
|
|
9244
|
+
/**
|
|
9245
|
+
Create a replace-around step with the given range and gap.
|
|
9246
|
+
`insert` should be the point in the slice into which the content
|
|
9247
|
+
of the gap should be moved. `structure` has the same meaning as
|
|
9248
|
+
it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
|
|
9249
|
+
*/
|
|
9250
|
+
constructor(
|
|
9251
|
+
/**
|
|
9252
|
+
The start position of the replaced range.
|
|
9253
|
+
*/
|
|
9254
|
+
from,
|
|
9255
|
+
/**
|
|
9256
|
+
The end position of the replaced range.
|
|
9257
|
+
*/
|
|
9258
|
+
to,
|
|
9259
|
+
/**
|
|
9260
|
+
The start of preserved range.
|
|
9261
|
+
*/
|
|
9262
|
+
gapFrom,
|
|
9263
|
+
/**
|
|
9264
|
+
The end of preserved range.
|
|
9265
|
+
*/
|
|
9266
|
+
gapTo,
|
|
9267
|
+
/**
|
|
9268
|
+
The slice to insert.
|
|
9269
|
+
*/
|
|
9270
|
+
slice,
|
|
9271
|
+
/**
|
|
9272
|
+
The position in the slice where the preserved range should be
|
|
9273
|
+
inserted.
|
|
9274
|
+
*/
|
|
9275
|
+
insert,
|
|
9276
|
+
/**
|
|
9277
|
+
@internal
|
|
9278
|
+
*/
|
|
9279
|
+
structure = false) {
|
|
9280
|
+
super();
|
|
9281
|
+
this.from = from;
|
|
9282
|
+
this.to = to;
|
|
9283
|
+
this.gapFrom = gapFrom;
|
|
9284
|
+
this.gapTo = gapTo;
|
|
9285
|
+
this.slice = slice;
|
|
9286
|
+
this.insert = insert;
|
|
9287
|
+
this.structure = structure;
|
|
9288
|
+
}
|
|
9289
|
+
apply(doc) {
|
|
9290
|
+
if (this.structure && (contentBetween(doc, this.from, this.gapFrom) ||
|
|
9291
|
+
contentBetween(doc, this.gapTo, this.to)))
|
|
9292
|
+
return StepResult.fail("Structure gap-replace would overwrite content");
|
|
9293
|
+
let gap = doc.slice(this.gapFrom, this.gapTo);
|
|
9294
|
+
if (gap.openStart || gap.openEnd)
|
|
9295
|
+
return StepResult.fail("Gap is not a flat range");
|
|
9296
|
+
let inserted = this.slice.insertAt(this.insert, gap.content);
|
|
9297
|
+
if (!inserted)
|
|
9298
|
+
return StepResult.fail("Content does not fit in gap");
|
|
9299
|
+
return StepResult.fromReplace(doc, this.from, this.to, inserted);
|
|
9300
|
+
}
|
|
9301
|
+
getMap() {
|
|
9302
|
+
return new StepMap([this.from, this.gapFrom - this.from, this.insert,
|
|
9303
|
+
this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);
|
|
9304
|
+
}
|
|
9305
|
+
invert(doc) {
|
|
9306
|
+
let gap = this.gapTo - this.gapFrom;
|
|
9307
|
+
return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
9308
|
+
}
|
|
9309
|
+
map(mapping) {
|
|
9310
|
+
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
9311
|
+
let gapFrom = this.from == this.gapFrom ? from.pos : mapping.map(this.gapFrom, -1);
|
|
9312
|
+
let gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);
|
|
9313
|
+
if ((from.deletedAcross && to.deletedAcross) || gapFrom < from.pos || gapTo > to.pos)
|
|
9314
|
+
return null;
|
|
9315
|
+
return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
|
|
9316
|
+
}
|
|
9317
|
+
toJSON() {
|
|
9318
|
+
let json = { stepType: "replaceAround", from: this.from, to: this.to,
|
|
9319
|
+
gapFrom: this.gapFrom, gapTo: this.gapTo, insert: this.insert };
|
|
9320
|
+
if (this.slice.size)
|
|
9321
|
+
json.slice = this.slice.toJSON();
|
|
9322
|
+
if (this.structure)
|
|
9323
|
+
json.structure = true;
|
|
9324
|
+
return json;
|
|
9325
|
+
}
|
|
9326
|
+
/**
|
|
9327
|
+
@internal
|
|
9328
|
+
*/
|
|
9329
|
+
static fromJSON(schema, json) {
|
|
9330
|
+
if (typeof json.from != "number" || typeof json.to != "number" ||
|
|
9331
|
+
typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number")
|
|
9332
|
+
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
9333
|
+
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
|
|
9334
|
+
}
|
|
9335
|
+
}
|
|
9336
|
+
Step.jsonID("replaceAround", ReplaceAroundStep);
|
|
9337
|
+
function contentBetween(doc, from, to) {
|
|
9338
|
+
let $from = doc.resolve(from), dist = to - from, depth = $from.depth;
|
|
9339
|
+
while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
|
|
9340
|
+
depth--;
|
|
9341
|
+
dist--;
|
|
9342
|
+
}
|
|
9343
|
+
if (dist > 0) {
|
|
9344
|
+
let next = $from.node(depth).maybeChild($from.indexAfter(depth));
|
|
9345
|
+
while (dist > 0) {
|
|
9346
|
+
if (!next || next.isLeaf)
|
|
9347
|
+
return true;
|
|
9348
|
+
next = next.firstChild;
|
|
9349
|
+
dist--;
|
|
9350
|
+
}
|
|
9351
|
+
}
|
|
9352
|
+
return false;
|
|
9353
|
+
}
|
|
9354
|
+
|
|
9355
|
+
function canCut(node, start, end) {
|
|
9356
|
+
return (start == 0 || node.canReplace(start, node.childCount)) &&
|
|
9357
|
+
(end == node.childCount || node.canReplace(0, end));
|
|
9358
|
+
}
|
|
9359
|
+
/**
|
|
9360
|
+
Try to find a target depth to which the content in the given range
|
|
9361
|
+
can be lifted. Will not go across
|
|
9362
|
+
[isolating](https://prosemirror.net/docs/ref/#model.NodeSpec.isolating) parent nodes.
|
|
9363
|
+
*/
|
|
9364
|
+
function liftTarget(range) {
|
|
9365
|
+
let parent = range.parent;
|
|
9366
|
+
let content = parent.content.cutByIndex(range.startIndex, range.endIndex);
|
|
9367
|
+
for (let depth = range.depth;; --depth) {
|
|
9368
|
+
let node = range.$from.node(depth);
|
|
9369
|
+
let index = range.$from.index(depth), endIndex = range.$to.indexAfter(depth);
|
|
9370
|
+
if (depth < range.depth && node.canReplace(index, endIndex, content))
|
|
9371
|
+
return depth;
|
|
9372
|
+
if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex))
|
|
9373
|
+
break;
|
|
9374
|
+
}
|
|
9375
|
+
return null;
|
|
9376
|
+
}
|
|
9377
|
+
/**
|
|
9378
|
+
Try to find a valid way to wrap the content in the given range in a
|
|
9379
|
+
node of the given type. May introduce extra nodes around and inside
|
|
9380
|
+
the wrapper node, if necessary. Returns null if no valid wrapping
|
|
9381
|
+
could be found. When `innerRange` is given, that range's content is
|
|
9382
|
+
used as the content to fit into the wrapping, instead of the
|
|
9383
|
+
content of `range`.
|
|
9384
|
+
*/
|
|
9385
|
+
function findWrapping(range, nodeType, attrs = null, innerRange = range) {
|
|
9386
|
+
let around = findWrappingOutside(range, nodeType);
|
|
9387
|
+
let inner = around && findWrappingInside(innerRange, nodeType);
|
|
9388
|
+
if (!inner)
|
|
9389
|
+
return null;
|
|
9390
|
+
return around.map(withAttrs)
|
|
9391
|
+
.concat({ type: nodeType, attrs }).concat(inner.map(withAttrs));
|
|
9392
|
+
}
|
|
9393
|
+
function withAttrs(type) { return { type, attrs: null }; }
|
|
9394
|
+
function findWrappingOutside(range, type) {
|
|
9395
|
+
let { parent, startIndex, endIndex } = range;
|
|
9396
|
+
let around = parent.contentMatchAt(startIndex).findWrapping(type);
|
|
9397
|
+
if (!around)
|
|
9398
|
+
return null;
|
|
9399
|
+
let outer = around.length ? around[0] : type;
|
|
9400
|
+
return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;
|
|
9401
|
+
}
|
|
9402
|
+
function findWrappingInside(range, type) {
|
|
9403
|
+
let { parent, startIndex, endIndex } = range;
|
|
9404
|
+
let inner = parent.child(startIndex);
|
|
9405
|
+
let inside = type.contentMatch.findWrapping(inner.type);
|
|
9406
|
+
if (!inside)
|
|
9407
|
+
return null;
|
|
9408
|
+
let lastType = inside.length ? inside[inside.length - 1] : type;
|
|
9409
|
+
let innerMatch = lastType.contentMatch;
|
|
9410
|
+
for (let i = startIndex; innerMatch && i < endIndex; i++)
|
|
9411
|
+
innerMatch = innerMatch.matchType(parent.child(i).type);
|
|
9412
|
+
if (!innerMatch || !innerMatch.validEnd)
|
|
9413
|
+
return null;
|
|
9414
|
+
return inside;
|
|
9415
|
+
}
|
|
9416
|
+
/**
|
|
9417
|
+
Check whether splitting at the given position is allowed.
|
|
9418
|
+
*/
|
|
9419
|
+
function canSplit(doc, pos, depth = 1, typesAfter) {
|
|
9420
|
+
let $pos = doc.resolve(pos), base = $pos.depth - depth;
|
|
9421
|
+
let innerType = (typesAfter && typesAfter[typesAfter.length - 1]) || $pos.parent;
|
|
9422
|
+
if (base < 0 || $pos.parent.type.spec.isolating ||
|
|
9423
|
+
!$pos.parent.canReplace($pos.index(), $pos.parent.childCount) ||
|
|
9424
|
+
!innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount)))
|
|
9425
|
+
return false;
|
|
9426
|
+
for (let d = $pos.depth - 1, i = depth - 2; d > base; d--, i--) {
|
|
9427
|
+
let node = $pos.node(d), index = $pos.index(d);
|
|
9428
|
+
if (node.type.spec.isolating)
|
|
9429
|
+
return false;
|
|
9430
|
+
let rest = node.content.cutByIndex(index, node.childCount);
|
|
9431
|
+
let overrideChild = typesAfter && typesAfter[i + 1];
|
|
9432
|
+
if (overrideChild)
|
|
9433
|
+
rest = rest.replaceChild(0, overrideChild.type.create(overrideChild.attrs));
|
|
9434
|
+
let after = (typesAfter && typesAfter[i]) || node;
|
|
9435
|
+
if (!node.canReplace(index + 1, node.childCount) || !after.type.validContent(rest))
|
|
9436
|
+
return false;
|
|
9437
|
+
}
|
|
9438
|
+
let index = $pos.indexAfter(base);
|
|
9439
|
+
let baseType = typesAfter && typesAfter[0];
|
|
9440
|
+
return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type);
|
|
9441
|
+
}
|
|
9442
|
+
/**
|
|
9443
|
+
Test whether the blocks before and after a given position can be
|
|
9444
|
+
joined.
|
|
9445
|
+
*/
|
|
9446
|
+
function canJoin(doc, pos) {
|
|
9447
|
+
let $pos = doc.resolve(pos), index = $pos.index();
|
|
9448
|
+
return joinable($pos.nodeBefore, $pos.nodeAfter) &&
|
|
9449
|
+
$pos.parent.canReplace(index, index + 1);
|
|
9450
|
+
}
|
|
9451
|
+
function joinable(a, b) {
|
|
9452
|
+
return !!(a && b && !a.isLeaf && a.canAppend(b));
|
|
9453
|
+
}
|
|
9454
|
+
|
|
9455
|
+
/**
|
|
9456
|
+
Update an attribute in a specific node.
|
|
9457
|
+
*/
|
|
9458
|
+
class AttrStep extends Step {
|
|
9459
|
+
/**
|
|
9460
|
+
Construct an attribute step.
|
|
9461
|
+
*/
|
|
9462
|
+
constructor(
|
|
9463
|
+
/**
|
|
9464
|
+
The position of the target node.
|
|
9465
|
+
*/
|
|
9466
|
+
pos,
|
|
9467
|
+
/**
|
|
9468
|
+
The attribute to set.
|
|
9469
|
+
*/
|
|
9470
|
+
attr,
|
|
9471
|
+
// The attribute's new value.
|
|
9472
|
+
value) {
|
|
9473
|
+
super();
|
|
9474
|
+
this.pos = pos;
|
|
9475
|
+
this.attr = attr;
|
|
9476
|
+
this.value = value;
|
|
9477
|
+
}
|
|
9478
|
+
apply(doc) {
|
|
9479
|
+
let node = doc.nodeAt(this.pos);
|
|
9480
|
+
if (!node)
|
|
9481
|
+
return StepResult.fail("No node at attribute step's position");
|
|
9482
|
+
let attrs = Object.create(null);
|
|
9483
|
+
for (let name in node.attrs)
|
|
9484
|
+
attrs[name] = node.attrs[name];
|
|
9485
|
+
attrs[this.attr] = this.value;
|
|
9486
|
+
let updated = node.type.create(attrs, null, node.marks);
|
|
9487
|
+
return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));
|
|
9488
|
+
}
|
|
9489
|
+
getMap() {
|
|
9490
|
+
return StepMap.empty;
|
|
9491
|
+
}
|
|
9492
|
+
invert(doc) {
|
|
9493
|
+
return new AttrStep(this.pos, this.attr, doc.nodeAt(this.pos).attrs[this.attr]);
|
|
9494
|
+
}
|
|
9495
|
+
map(mapping) {
|
|
9496
|
+
let pos = mapping.mapResult(this.pos, 1);
|
|
9497
|
+
return pos.deletedAfter ? null : new AttrStep(pos.pos, this.attr, this.value);
|
|
9498
|
+
}
|
|
9499
|
+
toJSON() {
|
|
9500
|
+
return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
|
|
9501
|
+
}
|
|
9502
|
+
static fromJSON(schema, json) {
|
|
9503
|
+
if (typeof json.pos != "number" || typeof json.attr != "string")
|
|
9504
|
+
throw new RangeError("Invalid input for AttrStep.fromJSON");
|
|
9505
|
+
return new AttrStep(json.pos, json.attr, json.value);
|
|
9506
|
+
}
|
|
9507
|
+
}
|
|
9508
|
+
Step.jsonID("attr", AttrStep);
|
|
9509
|
+
/**
|
|
9510
|
+
Update an attribute in the doc node.
|
|
9511
|
+
*/
|
|
9512
|
+
class DocAttrStep extends Step {
|
|
9513
|
+
/**
|
|
9514
|
+
Construct an attribute step.
|
|
9515
|
+
*/
|
|
9516
|
+
constructor(
|
|
9517
|
+
/**
|
|
9518
|
+
The attribute to set.
|
|
9519
|
+
*/
|
|
9520
|
+
attr,
|
|
9521
|
+
// The attribute's new value.
|
|
9522
|
+
value) {
|
|
9523
|
+
super();
|
|
9524
|
+
this.attr = attr;
|
|
9525
|
+
this.value = value;
|
|
9526
|
+
}
|
|
9527
|
+
apply(doc) {
|
|
9528
|
+
let attrs = Object.create(null);
|
|
9529
|
+
for (let name in doc.attrs)
|
|
9530
|
+
attrs[name] = doc.attrs[name];
|
|
9531
|
+
attrs[this.attr] = this.value;
|
|
9532
|
+
let updated = doc.type.create(attrs, doc.content, doc.marks);
|
|
9533
|
+
return StepResult.ok(updated);
|
|
9534
|
+
}
|
|
9535
|
+
getMap() {
|
|
9536
|
+
return StepMap.empty;
|
|
9537
|
+
}
|
|
9538
|
+
invert(doc) {
|
|
9539
|
+
return new DocAttrStep(this.attr, doc.attrs[this.attr]);
|
|
9540
|
+
}
|
|
9541
|
+
map(mapping) {
|
|
9542
|
+
return this;
|
|
9543
|
+
}
|
|
9544
|
+
toJSON() {
|
|
9545
|
+
return { stepType: "docAttr", attr: this.attr, value: this.value };
|
|
9546
|
+
}
|
|
9547
|
+
static fromJSON(schema, json) {
|
|
9548
|
+
if (typeof json.attr != "string")
|
|
9549
|
+
throw new RangeError("Invalid input for DocAttrStep.fromJSON");
|
|
9550
|
+
return new DocAttrStep(json.attr, json.value);
|
|
9551
|
+
}
|
|
9552
|
+
}
|
|
9553
|
+
Step.jsonID("docAttr", DocAttrStep);
|
|
9554
|
+
|
|
9555
|
+
/**
|
|
9556
|
+
@internal
|
|
9557
|
+
*/
|
|
9558
|
+
let TransformError = class extends Error {
|
|
9559
|
+
};
|
|
9560
|
+
TransformError = function TransformError(message) {
|
|
9561
|
+
let err = Error.call(this, message);
|
|
9562
|
+
err.__proto__ = TransformError.prototype;
|
|
9563
|
+
return err;
|
|
9564
|
+
};
|
|
9565
|
+
TransformError.prototype = Object.create(Error.prototype);
|
|
9566
|
+
TransformError.prototype.constructor = TransformError;
|
|
9567
|
+
TransformError.prototype.name = "TransformError";
|
|
9568
|
+
|
|
8620
9569
|
/**
|
|
8621
9570
|
Returns a command function that wraps the selection in a list with
|
|
8622
9571
|
the given type an attributes. If `dispatch` is null, only return a
|
|
@@ -8640,7 +9589,7 @@ function wrapInList$1(listType, attrs = null) {
|
|
|
8640
9589
|
range = new NodeRange($from, state.doc.resolve($to.end(range.depth)), range.depth);
|
|
8641
9590
|
doJoin = true;
|
|
8642
9591
|
}
|
|
8643
|
-
let wrap = findWrapping
|
|
9592
|
+
let wrap = findWrapping(outerRange, listType, attrs, range);
|
|
8644
9593
|
if (!wrap)
|
|
8645
9594
|
return false;
|
|
8646
9595
|
if (dispatch)
|
|
@@ -8652,7 +9601,7 @@ function doWrapInList(tr, range, wrappers, joinBefore, listType) {
|
|
|
8652
9601
|
let content = Fragment.empty;
|
|
8653
9602
|
for (let i = wrappers.length - 1; i >= 0; i--)
|
|
8654
9603
|
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
8655
|
-
tr.step(new ReplaceAroundStep
|
|
9604
|
+
tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
|
|
8656
9605
|
let found = 0;
|
|
8657
9606
|
for (let i = 0; i < wrappers.length; i++)
|
|
8658
9607
|
if (wrappers[i].type == listType)
|
|
@@ -8660,7 +9609,7 @@ function doWrapInList(tr, range, wrappers, joinBefore, listType) {
|
|
|
8660
9609
|
let splitDepth = wrappers.length - found;
|
|
8661
9610
|
let splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0), parent = range.parent;
|
|
8662
9611
|
for (let i = range.startIndex, e = range.endIndex, first = true; i < e; i++, first = false) {
|
|
8663
|
-
if (!first && canSplit
|
|
9612
|
+
if (!first && canSplit(tr.doc, splitPos, splitDepth)) {
|
|
8664
9613
|
tr.split(splitPos, splitDepth);
|
|
8665
9614
|
splitPos += 2 * splitDepth;
|
|
8666
9615
|
}
|
|
@@ -8691,15 +9640,15 @@ function liftToOuterList(state, dispatch, itemType, range) {
|
|
|
8691
9640
|
if (end < endOfList) {
|
|
8692
9641
|
// There are siblings after the lifted items, which must become
|
|
8693
9642
|
// children of the last item
|
|
8694
|
-
tr.step(new ReplaceAroundStep
|
|
9643
|
+
tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
|
|
8695
9644
|
range = new NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
8696
9645
|
}
|
|
8697
|
-
const target = liftTarget
|
|
9646
|
+
const target = liftTarget(range);
|
|
8698
9647
|
if (target == null)
|
|
8699
9648
|
return false;
|
|
8700
9649
|
tr.lift(range, target);
|
|
8701
9650
|
let after = tr.mapping.map(end, -1) - 1;
|
|
8702
|
-
if (canJoin
|
|
9651
|
+
if (canJoin(tr.doc, after))
|
|
8703
9652
|
tr.join(after);
|
|
8704
9653
|
dispatch(tr.scrollIntoView());
|
|
8705
9654
|
return true;
|
|
@@ -8722,7 +9671,7 @@ function liftOutOfList(state, dispatch, range) {
|
|
|
8722
9671
|
// Strip off the surrounding list. At the sides where we're not at
|
|
8723
9672
|
// the end of the list, the existing list is closed. At sides where
|
|
8724
9673
|
// this is the end, it is overwritten to its end.
|
|
8725
|
-
tr.step(new ReplaceAroundStep
|
|
9674
|
+
tr.step(new ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty)))
|
|
8726
9675
|
.append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
|
|
8727
9676
|
dispatch(tr.scrollIntoView());
|
|
8728
9677
|
return true;
|
|
@@ -8748,7 +9697,7 @@ function sinkListItem$1(itemType) {
|
|
|
8748
9697
|
let inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
8749
9698
|
let slice = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
8750
9699
|
let before = range.start, after = range.end;
|
|
8751
|
-
dispatch(state.tr.step(new ReplaceAroundStep
|
|
9700
|
+
dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true))
|
|
8752
9701
|
.scrollIntoView());
|
|
8753
9702
|
}
|
|
8754
9703
|
return true;
|
|
@@ -10186,7 +11135,7 @@ const clearNodes = () => ({ state, tr, dispatch }) => {
|
|
|
10186
11135
|
if (!nodeRange) {
|
|
10187
11136
|
return;
|
|
10188
11137
|
}
|
|
10189
|
-
const targetLiftDepth = liftTarget(nodeRange);
|
|
11138
|
+
const targetLiftDepth = liftTarget$1(nodeRange);
|
|
10190
11139
|
if (node.type.isTextblock) {
|
|
10191
11140
|
const { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index());
|
|
10192
11141
|
tr.setNodeMarkup(nodeRange.start, defaultType);
|
|
@@ -10581,7 +11530,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
10581
11530
|
return;
|
|
10582
11531
|
}
|
|
10583
11532
|
const step = tr.steps[last];
|
|
10584
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
11533
|
+
if (!(step instanceof ReplaceStep$1 || step instanceof ReplaceAroundStep$1)) {
|
|
10585
11534
|
return;
|
|
10586
11535
|
}
|
|
10587
11536
|
const map = tr.mapping.maps[last];
|
|
@@ -11656,7 +12605,7 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
|
|
|
11656
12605
|
const extensionAttributes = editor.extensionManager.attributes;
|
|
11657
12606
|
const newAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);
|
|
11658
12607
|
if (selection instanceof NodeSelection && selection.node.isBlock) {
|
|
11659
|
-
if (!$from.parentOffset || !canSplit(doc, $from.pos)) {
|
|
12608
|
+
if (!$from.parentOffset || !canSplit$1(doc, $from.pos)) {
|
|
11660
12609
|
return false;
|
|
11661
12610
|
}
|
|
11662
12611
|
if (dispatch) {
|
|
@@ -11682,10 +12631,10 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
|
|
|
11682
12631
|
},
|
|
11683
12632
|
]
|
|
11684
12633
|
: undefined;
|
|
11685
|
-
let can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types);
|
|
12634
|
+
let can = canSplit$1(tr.doc, tr.mapping.map($from.pos), 1, types);
|
|
11686
12635
|
if (!types
|
|
11687
12636
|
&& !can
|
|
11688
|
-
&& canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined)) {
|
|
12637
|
+
&& canSplit$1(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined)) {
|
|
11689
12638
|
can = true;
|
|
11690
12639
|
types = deflt
|
|
11691
12640
|
? [
|
|
@@ -11785,7 +12734,7 @@ const splitListItem = typeOrName => ({ tr, state, dispatch, editor, }) => {
|
|
|
11785
12734
|
{ type: nextType, attrs: newNextTypeAttributes },
|
|
11786
12735
|
]
|
|
11787
12736
|
: [{ type, attrs: newTypeAttributes }];
|
|
11788
|
-
if (!canSplit(tr.doc, $from.pos, 2)) {
|
|
12737
|
+
if (!canSplit$1(tr.doc, $from.pos, 2)) {
|
|
11789
12738
|
return false;
|
|
11790
12739
|
}
|
|
11791
12740
|
if (dispatch) {
|
|
@@ -11812,7 +12761,7 @@ const joinListBackwards = (tr, listType) => {
|
|
|
11812
12761
|
return true;
|
|
11813
12762
|
}
|
|
11814
12763
|
const nodeBefore = tr.doc.nodeAt(before);
|
|
11815
|
-
const canJoinBackwards = list.node.type === (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) && canJoin(tr.doc, list.pos);
|
|
12764
|
+
const canJoinBackwards = list.node.type === (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) && canJoin$1(tr.doc, list.pos);
|
|
11816
12765
|
if (!canJoinBackwards) {
|
|
11817
12766
|
return true;
|
|
11818
12767
|
}
|
|
@@ -11829,7 +12778,7 @@ const joinListForwards = (tr, listType) => {
|
|
|
11829
12778
|
return true;
|
|
11830
12779
|
}
|
|
11831
12780
|
const nodeAfter = tr.doc.nodeAt(after);
|
|
11832
|
-
const canJoinForwards = list.node.type === (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.type) && canJoin(tr.doc, after);
|
|
12781
|
+
const canJoinForwards = list.node.type === (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.type) && canJoin$1(tr.doc, after);
|
|
11833
12782
|
if (!canJoinForwards) {
|
|
11834
12783
|
return true;
|
|
11835
12784
|
}
|
|
@@ -13108,7 +14057,7 @@ function wrappingInputRule(config) {
|
|
|
13108
14057
|
const tr = state.tr.delete(range.from, range.to);
|
|
13109
14058
|
const $start = tr.doc.resolve(range.from);
|
|
13110
14059
|
const blockRange = $start.blockRange();
|
|
13111
|
-
const wrapping = blockRange && findWrapping(blockRange, config.type, attributes);
|
|
14060
|
+
const wrapping = blockRange && findWrapping$1(blockRange, config.type, attributes);
|
|
13112
14061
|
if (!wrapping) {
|
|
13113
14062
|
return null;
|
|
13114
14063
|
}
|
|
@@ -13130,7 +14079,7 @@ function wrappingInputRule(config) {
|
|
|
13130
14079
|
const before = tr.doc.resolve(range.from - 1).nodeBefore;
|
|
13131
14080
|
if (before
|
|
13132
14081
|
&& before.type === config.type
|
|
13133
|
-
&& canJoin(tr.doc, range.from - 1)
|
|
14082
|
+
&& canJoin$1(tr.doc, range.from - 1)
|
|
13134
14083
|
&& (!config.joinPredicate || config.joinPredicate(match, before))) {
|
|
13135
14084
|
tr.join(range.from - 1);
|
|
13136
14085
|
}
|
|
@@ -18389,5 +19338,5 @@ var Menu = function Menu(props) {
|
|
|
18389
19338
|
}));
|
|
18390
19339
|
};
|
|
18391
19340
|
|
|
18392
|
-
export { getAttributes as A, highlightFocussedNode as B, resetFocussedNode as C, DecorationSet as D, Extension as E, findParentNodeClosestToPos as F, BubbleMenu as G, getLinkPopoverPosition as H, InputRule as I, getMarkType as J, getMarkRange as K, useEditor as L, Menu as M, Node as N, useEditorState$1 as O, PasteRule as P, EditorContent as Q, ReactNodeViewRenderer as R, MediaUploader as S, EmbedOption as T, EditorView as U, Mark as a, markInputRule as b, markPasteRule as c, Decoration as d, callOrReturn as e, getExtensionField as f, getMarkAttributes as g, findChildren as h, isNodeSelection as i, NodeViewWrapper as j, keydownHandler as k, NodeViewContent as l, mergeAttributes as m, nodeInputRule as n, escapeForRegEx as o, ReactRenderer as p, EmojiPickerMenu as q, emojiPickerApi as r, liftTarget as s, textblockTypeInputRule as t, combineTransactionSteps as u, validateUrl as v, wrappingInputRule as w, getChangedRanges as x, findChildrenInRange as y, getMarksBetween as z };
|
|
18393
|
-
//# sourceMappingURL=chunk-
|
|
19341
|
+
export { getAttributes as A, highlightFocussedNode as B, resetFocussedNode as C, DecorationSet as D, Extension as E, findParentNodeClosestToPos as F, BubbleMenu as G, getLinkPopoverPosition as H, InputRule as I, getMarkType as J, getMarkRange as K, useEditor as L, Menu as M, Node as N, useEditorState$1 as O, PasteRule as P, EditorContent as Q, ReactNodeViewRenderer as R, MediaUploader as S, EmbedOption as T, EditorView as U, Mark as a, markInputRule as b, markPasteRule as c, Decoration as d, callOrReturn as e, getExtensionField as f, getMarkAttributes as g, findChildren as h, isNodeSelection as i, NodeViewWrapper as j, keydownHandler as k, NodeViewContent as l, mergeAttributes as m, nodeInputRule as n, escapeForRegEx as o, ReactRenderer as p, EmojiPickerMenu as q, emojiPickerApi as r, liftTarget$1 as s, textblockTypeInputRule as t, combineTransactionSteps as u, validateUrl as v, wrappingInputRule as w, getChangedRanges as x, findChildrenInRange as y, getMarksBetween as z };
|
|
19342
|
+
//# sourceMappingURL=chunk-53f86c77.js.map
|