slate
Version:
A completely customizable framework for building rich text editors.
7,502 lines • 352 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Slate = {}));
})(this, (function (exports) { 'use strict';
// eslint-disable-next-line no-redeclare
var PathRef = {
transform: function transform(ref, op) {
var current = ref.current,
affinity = ref.affinity;
if (current == null) {
return;
}
var path = Path.transform(current, op, {
affinity: affinity
});
ref.current = path;
if (path == null) {
ref.unref();
}
}
};
// eslint-disable-next-line no-redeclare
var PointRef = {
transform: function transform(ref, op) {
var current = ref.current,
affinity = ref.affinity;
if (current == null) {
return;
}
var point = Point.transform(current, op, {
affinity: affinity
});
ref.current = point;
if (point == null) {
ref.unref();
}
}
};
// eslint-disable-next-line no-redeclare
var RangeRef = {
transform: function transform(ref, op) {
var current = ref.current,
affinity = ref.affinity;
if (current == null) {
return;
}
var path = Range.transform(current, op, {
affinity: affinity
});
ref.current = path;
if (path == null) {
ref.unref();
}
}
};
var DIRTY_PATHS = new WeakMap();
var DIRTY_PATH_KEYS = new WeakMap();
var FLUSHING = new WeakMap();
var NORMALIZING = new WeakMap();
var PATH_REFS = new WeakMap();
var POINT_REFS = new WeakMap();
var RANGE_REFS = new WeakMap();
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var arrayLikeToArray = createCommonjsModule(function (module) {
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(arrayLikeToArray);
var arrayWithoutHoles = createCommonjsModule(function (module) {
function _arrayWithoutHoles(r) {
if (Array.isArray(r)) return arrayLikeToArray(r);
}
module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(arrayWithoutHoles);
var iterableToArray = createCommonjsModule(function (module) {
function _iterableToArray(r) {
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(iterableToArray);
var unsupportedIterableToArray = createCommonjsModule(function (module) {
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0;
}
}
module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(unsupportedIterableToArray);
var nonIterableSpread = createCommonjsModule(function (module) {
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(nonIterableSpread);
var toConsumableArray = createCommonjsModule(function (module) {
function _toConsumableArray(r) {
return arrayWithoutHoles(r) || iterableToArray(r) || unsupportedIterableToArray(r) || nonIterableSpread();
}
module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
var _toConsumableArray = unwrapExports(toConsumableArray);
// eslint-disable-next-line no-redeclare
var Path = {
ancestors: function ancestors(path) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$reverse = options.reverse,
reverse = _options$reverse === void 0 ? false : _options$reverse;
var paths = Path.levels(path, options);
if (reverse) {
paths = paths.slice(1);
} else {
paths = paths.slice(0, -1);
}
return paths;
},
common: function common(path, another) {
var common = [];
for (var i = 0; i < path.length && i < another.length; i++) {
var av = path[i];
var bv = another[i];
if (typeof av !== 'number' || typeof bv !== 'number') {
throw new Error('Got non-numeric path index');
}
if (av !== bv) {
break;
}
common.push(av);
}
return common;
},
compare: function compare(path, another) {
var min = Math.min(path.length, another.length);
for (var i = 0; i < min; i++) {
if (path[i] < another[i]) return -1;
if (path[i] > another[i]) return 1;
}
return 0;
},
endsAfter: function endsAfter(path, another) {
var i = path.length - 1;
var as = path.slice(0, i);
var bs = another.slice(0, i);
var av = path[i];
var bv = another[i];
return Path.equals(as, bs) && av > bv;
},
endsAt: function endsAt(path, another) {
var i = path.length;
var as = path.slice(0, i);
var bs = another.slice(0, i);
return Path.equals(as, bs);
},
endsBefore: function endsBefore(path, another) {
var i = path.length - 1;
var as = path.slice(0, i);
var bs = another.slice(0, i);
var av = path[i];
var bv = another[i];
return Path.equals(as, bs) && av < bv;
},
equals: function equals(path, another) {
return path.length === another.length && path.every(function (n, i) {
return n === another[i];
});
},
hasPrevious: function hasPrevious(path) {
return path[path.length - 1] > 0;
},
isAfter: function isAfter(path, another) {
return Path.compare(path, another) === 1;
},
isAncestor: function isAncestor(path, another) {
return path.length < another.length && Path.compare(path, another) === 0;
},
isBefore: function isBefore(path, another) {
return Path.compare(path, another) === -1;
},
isChild: function isChild(path, another) {
return path.length === another.length + 1 && Path.compare(path, another) === 0;
},
isCommon: function isCommon(path, another) {
return path.length <= another.length && Path.compare(path, another) === 0;
},
isDescendant: function isDescendant(path, another) {
return path.length > another.length && Path.compare(path, another) === 0;
},
isParent: function isParent(path, another) {
return path.length + 1 === another.length && Path.compare(path, another) === 0;
},
isPath: function isPath(value) {
return Array.isArray(value) && value.every(function (n) {
return typeof n === 'number';
});
},
isSibling: function isSibling(path, another) {
if (path.length !== another.length) {
return false;
}
var as = path.slice(0, -1);
var bs = another.slice(0, -1);
var al = path[path.length - 1];
var bl = another[another.length - 1];
return al !== bl && Path.equals(as, bs);
},
levels: function levels(path) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$reverse2 = options.reverse,
reverse = _options$reverse2 === void 0 ? false : _options$reverse2;
var list = [];
for (var i = 0; i <= path.length; i++) {
list.push(path.slice(0, i));
}
if (reverse) {
list.reverse();
}
return list;
},
next: function next(path) {
if (path.length === 0) {
throw new Error("Cannot get the next path of a root path [".concat(path, "], because it has no next index."));
}
var last = path[path.length - 1];
return path.slice(0, -1).concat(last + 1);
},
operationCanTransformPath: function operationCanTransformPath(operation) {
switch (operation.type) {
case 'insert_node':
case 'remove_node':
case 'merge_node':
case 'split_node':
case 'move_node':
return true;
default:
return false;
}
},
parent: function parent(path) {
if (path.length === 0) {
throw new Error("Cannot get the parent path of the root path [".concat(path, "]."));
}
return path.slice(0, -1);
},
previous: function previous(path) {
if (path.length === 0) {
throw new Error("Cannot get the previous path of a root path [".concat(path, "], because it has no previous index."));
}
var last = path[path.length - 1];
if (last <= 0) {
throw new Error("Cannot get the previous path of a first child path [".concat(path, "] because it would result in a negative index."));
}
return path.slice(0, -1).concat(last - 1);
},
relative: function relative(path, ancestor) {
if (!Path.isAncestor(ancestor, path) && !Path.equals(path, ancestor)) {
throw new Error("Cannot get the relative path of [".concat(path, "] inside ancestor [").concat(ancestor, "], because it is not above or equal to the path."));
}
return path.slice(ancestor.length);
},
transform: function transform(path, operation) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!path) return null;
// PERF: use destructing instead of immer
var p = _toConsumableArray(path);
var _options$affinity = options.affinity,
affinity = _options$affinity === void 0 ? 'forward' : _options$affinity;
// PERF: Exit early if the operation is guaranteed not to have an effect.
if (path.length === 0) {
return p;
}
switch (operation.type) {
case 'insert_node':
{
var op = operation.path;
if (Path.equals(op, p) || Path.endsBefore(op, p) || Path.isAncestor(op, p)) {
p[op.length - 1] += 1;
}
break;
}
case 'remove_node':
{
var _op = operation.path;
if (Path.equals(_op, p) || Path.isAncestor(_op, p)) {
return null;
} else if (Path.endsBefore(_op, p)) {
p[_op.length - 1] -= 1;
}
break;
}
case 'merge_node':
{
var _op2 = operation.path,
position = operation.position;
if (Path.equals(_op2, p) || Path.endsBefore(_op2, p)) {
p[_op2.length - 1] -= 1;
} else if (Path.isAncestor(_op2, p)) {
p[_op2.length - 1] -= 1;
p[_op2.length] += position;
}
break;
}
case 'split_node':
{
var _op3 = operation.path,
_position = operation.position;
if (Path.equals(_op3, p)) {
if (affinity === 'forward') {
p[p.length - 1] += 1;
} else if (affinity === 'backward') ; else {
return null;
}
} else if (Path.endsBefore(_op3, p)) {
p[_op3.length - 1] += 1;
} else if (Path.isAncestor(_op3, p) && path[_op3.length] >= _position) {
p[_op3.length - 1] += 1;
p[_op3.length] -= _position;
}
break;
}
case 'move_node':
{
var _op4 = operation.path,
onp = operation.newPath;
// If the old and new path are the same, it's a no-op.
if (Path.equals(_op4, onp)) {
return p;
}
if (Path.isAncestor(_op4, p) || Path.equals(_op4, p)) {
var copy = onp.slice();
if (Path.endsBefore(_op4, onp) && _op4.length < onp.length) {
copy[_op4.length - 1] -= 1;
}
return copy.concat(p.slice(_op4.length));
} else if (Path.isSibling(_op4, onp) && (Path.isAncestor(onp, p) || Path.equals(onp, p))) {
if (Path.endsBefore(_op4, p)) {
p[_op4.length - 1] -= 1;
} else {
p[_op4.length - 1] += 1;
}
} else if (Path.endsBefore(onp, p) || Path.equals(onp, p) || Path.isAncestor(onp, p)) {
if (Path.endsBefore(_op4, p)) {
p[_op4.length - 1] -= 1;
}
p[onp.length - 1] += 1;
} else if (Path.endsBefore(_op4, p)) {
if (Path.equals(onp, p)) {
p[onp.length - 1] += 1;
}
p[_op4.length - 1] -= 1;
}
break;
}
}
return p;
}
};
var _typeof_1 = createCommonjsModule(function (module) {
function _typeof(o) {
"@babel/helpers - typeof";
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
}
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
var _typeof = unwrapExports(_typeof_1);
var toPrimitive_1 = createCommonjsModule(function (module) {
var _typeof = _typeof_1["default"];
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(toPrimitive_1);
var toPropertyKey_1 = createCommonjsModule(function (module) {
var _typeof = _typeof_1["default"];
function toPropertyKey(t) {
var i = toPrimitive_1(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(toPropertyKey_1);
var defineProperty = createCommonjsModule(function (module) {
function _defineProperty(e, r, t) {
return (r = toPropertyKey_1(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: true,
configurable: true,
writable: true
}) : e[r] = t, e;
}
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
var _defineProperty = unwrapExports(defineProperty);
var arrayWithHoles = createCommonjsModule(function (module) {
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(arrayWithHoles);
var iterableToArrayLimit = createCommonjsModule(function (module) {
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = true,
o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = true, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(iterableToArrayLimit);
var nonIterableRest = createCommonjsModule(function (module) {
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(nonIterableRest);
var slicedToArray = createCommonjsModule(function (module) {
function _slicedToArray(r, e) {
return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
}
module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
var _slicedToArray = unwrapExports(slicedToArray);
var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
function _objectWithoutPropertiesLoose(r, e) {
if (null == r) return {};
var t = {};
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
if (-1 !== e.indexOf(n)) continue;
t[n] = r[n];
}
return t;
}
module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(objectWithoutPropertiesLoose);
var objectWithoutProperties = createCommonjsModule(function (module) {
function _objectWithoutProperties(e, t) {
if (null == e) return {};
var o,
r,
i = objectWithoutPropertiesLoose(e, t);
if (Object.getOwnPropertySymbols) {
var n = Object.getOwnPropertySymbols(e);
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
}
return i;
}
module.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
var _objectWithoutProperties = unwrapExports(objectWithoutProperties);
var readOnlyError = createCommonjsModule(function (module) {
function _readOnlyError(r) {
throw new TypeError('"' + r + '" is read-only');
}
module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(readOnlyError);
var OverloadYield = createCommonjsModule(function (module) {
function _OverloadYield(e, d) {
this.v = e, this.k = d;
}
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(OverloadYield);
var regeneratorDefine = createCommonjsModule(function (module) {
function _regeneratorDefine(e, r, n, t) {
var i = Object.defineProperty;
try {
i({}, "", {});
} catch (e) {
i = 0;
}
module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
function o(r, n) {
_regeneratorDefine(e, r, function (e) {
return this._invoke(r, n, e);
});
}
r ? i ? i(e, r, {
value: n,
enumerable: !t,
configurable: !t,
writable: !t
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
}
module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regeneratorDefine);
var regenerator$1 = createCommonjsModule(function (module) {
function _regenerator() {
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
var e,
t,
r = "function" == typeof Symbol ? Symbol : {},
n = r.iterator || "@@iterator",
o = r.toStringTag || "@@toStringTag";
function i(r, n, o, i) {
var c = n && n.prototype instanceof Generator ? n : Generator,
u = Object.create(c.prototype);
return regeneratorDefine(u, "_invoke", function (r, n, o) {
var i,
c,
u,
f = 0,
p = o || [],
y = false,
G = {
p: 0,
n: 0,
v: e,
a: d,
f: d.bind(e, 4),
d: function d(t, r) {
return i = t, c = 0, u = e, G.n = r, a;
}
};
function d(r, n) {
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
var o,
i = p[t],
d = G.p,
l = i[2];
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
}
if (o || r > 1) return a;
throw y = true, n;
}
return function (o, p, l) {
if (f > 1) throw TypeError("Generator is already running");
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
try {
if (f = 2, i) {
if (c || (o = "next"), t = i[o]) {
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
if (!t.done) return t;
u = t.value, c < 2 && (c = 0);
} else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
i = e;
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
} catch (t) {
i = e, c = 1, u = t;
} finally {
f = 1;
}
}
return {
value: t,
done: y
};
};
}(r, o, i), true), u;
}
var a = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
t = Object.getPrototypeOf;
var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
return this;
}), t),
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
function f(e) {
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function () {
return this;
}), regeneratorDefine(u, "toString", function () {
return "[object Generator]";
}), (module.exports = _regenerator = function _regenerator() {
return {
w: i,
m: f
};
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
}
module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regenerator$1);
var regeneratorAsyncIterator = createCommonjsModule(function (module) {
function AsyncIterator(t, e) {
function n(r, o, i, f) {
try {
var c = t[r](o),
u = c.value;
return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
n("next", t, i, f);
}, function (t) {
n("throw", t, i, f);
}) : e.resolve(u).then(function (t) {
c.value = t, i(c);
}, function (t) {
return n("throw", t, i, f);
});
} catch (t) {
f(t);
}
}
var r;
this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
return this;
})), regeneratorDefine(this, "_invoke", function (t, o, i) {
function f() {
return new e(function (e, r) {
n(t, i, e, r);
});
}
return r = r ? r.then(f, f) : f();
}, true);
}
module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regeneratorAsyncIterator);
var regeneratorAsyncGen = createCommonjsModule(function (module) {
function _regeneratorAsyncGen(r, e, t, o, n) {
return new regeneratorAsyncIterator(regenerator$1().w(r, e, t, o), n || Promise);
}
module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regeneratorAsyncGen);
var regeneratorAsync = createCommonjsModule(function (module) {
function _regeneratorAsync(n, e, r, t, o) {
var a = regeneratorAsyncGen(n, e, r, t, o);
return a.next().then(function (n) {
return n.done ? n.value : a.next();
});
}
module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regeneratorAsync);
var regeneratorKeys = createCommonjsModule(function (module) {
function _regeneratorKeys(e) {
var n = Object(e),
r = [];
for (var t in n) r.unshift(t);
return function e() {
for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = false, e;
return e.done = true, e;
};
}
module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regeneratorKeys);
var regeneratorValues = createCommonjsModule(function (module) {
var _typeof = _typeof_1["default"];
function _regeneratorValues(e) {
if (null != e) {
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
r = 0;
if (t) return t.call(e);
if ("function" == typeof e.next) return e;
if (!isNaN(e.length)) return {
next: function next() {
return e && r >= e.length && (e = void 0), {
value: e && e[r++],
done: !e
};
}
};
}
throw new TypeError(_typeof(e) + " is not iterable");
}
module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regeneratorValues);
var regeneratorRuntime$1 = createCommonjsModule(function (module) {
function _regeneratorRuntime() {
var r = regenerator$1(),
e = r.m(_regeneratorRuntime),
t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
function n(r) {
var e = "function" == typeof r && r.constructor;
return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
}
var o = {
"throw": 1,
"return": 2,
"break": 3,
"continue": 3
};
function a(r) {
var e, t;
return function (n) {
e || (e = {
stop: function stop() {
return t(n.a, 2);
},
"catch": function _catch() {
return n.v;
},
abrupt: function abrupt(r, e) {
return t(n.a, o[r], e);
},
delegateYield: function delegateYield(r, o, a) {
return e.resultName = o, t(n.d, regeneratorValues(r), a);
},
finish: function finish(r) {
return t(n.f, r);
}
}, t = function t(r, _t, o) {
n.p = e.prev, n.n = e.next;
try {
return r(_t, o);
} finally {
e.next = n.n;
}
}), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
try {
return r.call(this, e);
} finally {
n.p = e.prev, n.n = e.next;
}
};
}
return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
return {
wrap: function wrap(e, t, n, o) {
return r.w(a(e), t, n, o && o.reverse());
},
isGeneratorFunction: n,
mark: r.m,
awrap: function awrap(r, e) {
return new OverloadYield(r, e);
},
AsyncIterator: regeneratorAsyncIterator,
async: function async(r, e, t, o, u) {
return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
},
keys: regeneratorKeys,
values: regeneratorValues
};
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
}
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
});
unwrapExports(regeneratorRuntime$1);
// TODO(Babel 8): Remove this file.
var runtime = regeneratorRuntime$1();
var regenerator = runtime;
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
if (typeof globalThis === "object") {
globalThis.regeneratorRuntime = runtime;
} else {
Function("r", "regeneratorRuntime = r")(runtime);
}
}
var _excluded$4 = ["anchor", "focus"];
function ownKeys$g(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$g(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$g(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$g(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
// eslint-disable-next-line no-redeclare
var Range = {
direction: function direction(range) {
var order = Point.compare(range.focus, range.anchor);
return order > 0 ? 'forward' : order < 0 ? 'backward' : 'collapsed';
},
edges: function edges(range) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$reverse = options.reverse,
reverse = _options$reverse === void 0 ? false : _options$reverse;
var anchor = range.anchor,
focus = range.focus;
return Range.isBackward(range) === reverse ? [anchor, focus] : [focus, anchor];
},
end: function end(range) {
var _Range$edges = Range.edges(range),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
end = _Range$edges2[1];
return end;
},
equals: function equals(range, another) {
return Point.equals(range.anchor, another.anchor) && Point.equals(range.focus, another.focus);
},
surrounds: function surrounds(range, target) {
var intersectionRange = Range.intersection(range, target);
if (!intersectionRange) {
return false;
}
return Range.equals(intersectionRange, target);
},
includes: function includes(range, target) {
if (Location.isRange(target)) {
if (Range.includes(range, target.anchor) || Range.includes(range, target.focus)) {
return true;
}
var _Range$edges3 = Range.edges(range),
_Range$edges4 = _slicedToArray(_Range$edges3, 2),
rs = _Range$edges4[0],
re = _Range$edges4[1];
var _Range$edges5 = Range.edges(target),
_Range$edges6 = _slicedToArray(_Range$edges5, 2),
ts = _Range$edges6[0],
te = _Range$edges6[1];
return Point.isBefore(rs, ts) && Point.isAfter(re, te);
}
var _Range$edges7 = Range.edges(range),
_Range$edges8 = _slicedToArray(_Range$edges7, 2),
start = _Range$edges8[0],
end = _Range$edges8[1];
var isAfterStart = false;
var isBeforeEnd = false;
if (Location.isPoint(target)) {
isAfterStart = Point.compare(target, start) >= 0;
isBeforeEnd = Point.compare(target, end) <= 0;
} else {
isAfterStart = Path.compare(target, start.path) >= 0;
isBeforeEnd = Path.compare(target, end.path) <= 0;
}
return isAfterStart && isBeforeEnd;
},
intersection: function intersection(range, another) {
range.anchor;
range.focus;
var rest = _objectWithoutProperties(range, _excluded$4);
var _Range$edges9 = Range.edges(range),
_Range$edges0 = _slicedToArray(_Range$edges9, 2),
s1 = _Range$edges0[0],
e1 = _Range$edges0[1];
var _Range$edges1 = Range.edges(another),
_Range$edges10 = _slicedToArray(_Range$edges1, 2),
s2 = _Range$edges10[0],
e2 = _Range$edges10[1];
var start = Point.isBefore(s1, s2) ? s2 : s1;
var end = Point.isBefore(e1, e2) ? e1 : e2;
if (Point.isBefore(end, start)) {
return null;
} else {
return _objectSpread$g({
anchor: start,
focus: end
}, rest);
}
},
isBackward: function isBackward(range) {
var anchor = range.anchor,
focus = range.focus;
return Point.isAfter(anchor, focus);
},
isCollapsed: function isCollapsed(range) {
var anchor = range.anchor,
focus = range.focus;
return Point.equals(anchor, focus);
},
isExpanded: function isExpanded(range) {
return !Range.isCollapsed(range);
},
isForward: function isForward(range) {
return !Range.isBackward(range);
},
isRange: function isRange(value) {
return isObject(value) && Point.isPoint(value.anchor) && Point.isPoint(value.focus);
},
points: /*#__PURE__*/regenerator.mark(function points(range) {
return regenerator.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_context.next = 1;
return [range.anchor, 'anchor'];
case 1:
_context.next = 2;
return [range.focus, 'focus'];
case 2:
case "end":
return _context.stop();
}
}, points);
}),
start: function start(range) {
var _Range$edges11 = Range.edges(range),
_Range$edges12 = _slicedToArray(_Range$edges11, 1),
start = _Range$edges12[0];
return start;
},
transform: function transform(range, op) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (range === null) {
return null;
}
var _options$affinity = options.affinity,
affinity = _options$affinity === void 0 ? 'inward' : _options$affinity;
var affinityAnchor;
var affinityFocus;
if (affinity === 'inward') {
// If the range is collapsed, make sure to use the same affinity to
// avoid the two points passing each other and expanding in the opposite
// direction
var isCollapsed = Range.isCollapsed(range);
if (Range.isForward(range)) {
affinityAnchor = 'forward';
affinityFocus = isCollapsed ? affinityAnchor : 'backward';
} else {
affinityAnchor = 'backward';
affinityFocus = isCollapsed ? affinityAnchor : 'forward';
}
} else if (affinity === 'outward') {
if (Range.isForward(range)) {
affinityAnchor = 'backward';
affinityFocus = 'forward';
} else {
affinityAnchor = 'forward';
affinityFocus = 'backward';
}
} else {
affinityAnchor = affinity;
affinityFocus = affinity;
}
var anchor = Point.transform(range.anchor, op, {
affinity: affinityAnchor
});
var focus = Point.transform(range.focus, op, {
affinity: affinityFocus
});
if (!anchor || !focus) {
return null;
}
return {
anchor: anchor,
focus: focus
};
}
};
/**
* Shared the function with isElementType utility
*/
var isElement = function isElement(value) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$deep = _ref.deep,
deep = _ref$deep === void 0 ? false : _ref$deep;
if (!isObject(value)) return false;
// PERF: No need to use the full Editor.isEditor here
var isEditor = typeof value.apply === 'function';
if (isEditor) return false;
var isChildrenValid = deep ? Node.isNodeList(value.children) : Array.isArray(value.children);
return isChildrenValid;
};
// eslint-disable-next-line no-redeclare
var Element = {
isAncestor: function isAncestor(value) {
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref2$deep = _ref2.deep,
deep = _ref2$deep === void 0 ? false : _ref2$deep;
return isObject(value) && Node.isNodeList(value.children, {
deep: deep
});
},
isElement: isElement,
isElementList: function isElementList(value) {
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref3$deep = _ref3.deep,
deep = _ref3$deep === void 0 ? false : _ref3$deep;
return Array.isArray(value) && value.every(function (val) {
return Element.isElement(val, {
deep: deep
});
});
},
isElementProps: function isElementProps(props) {
return props.children !== undefined;
},
isElementType: function isElementType(value, elementVal) {
var elementKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'type';
return isElement(value) && value[elementKey] === elementVal;
},
matches: function matches(element, props) {
for (var key in props) {
if (key === 'children') {
continue;
}
if (element[key] !== props[key]) {
return false;
}
}
return true;
}
};
var _excluded$3 = ["text"],
_excluded2$3 = ["children"];
function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _createForOfIteratorHelper$l(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$l(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$l(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$l(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$l(r, a) : void 0; } }
function _arrayLikeToArray$l(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
// eslint-disable-next-line no-redeclare
var Node = {
ancestor: function ancestor(root, path) {
var node = Node.get(root, path);
if (Node.isText(node)) {
throw new Error("Cannot get the ancestor node at path [".concat(path, "] because it refers to a text node instead: ").concat(Scrubber.stringify(node)));
}
return node;
},
ancestors: function ancestors(root, path) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return /*#__PURE__*/regenerator.mark(function _callee() {
var _iterator, _step, p, n, entry, _t;
return regenerator.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_iterator = _createForOfIteratorHelper$l(Path.ancestors(path, options));
_context.prev = 1;
_iterator.s();
case 2:
if ((_step = _iterator.n()).done) {
_context.next = 4;
break;
}
p = _step.value;
n = Node.ancestor(root, p);
entry = [n, p];
_context.next = 3;
return entry;
case 3:
_context.next = 2;
break;
case 4:
_context.next = 6;
break;
case 5:
_context.prev = 5;
_t = _context["catch"](1);
_iterator.e(_t);
case 6:
_context.prev = 6;
_iterator.f();
return _context.finish(6);
case 7:
case "end":
return _context.stop();
}
}, _callee, null, [[1, 5, 6, 7]]);
})();
},
child: function child(root, index) {
if (Node.isText(root)) {
throw new Error("Cannot get the child of a text node: ".concat(Scrubber.stringify(root)));
}
if (typeof index !== 'number') {
throw new Error('Expected index to be a number');
}
var c = root.children[index];
if (c == null) {
throw new Error("Cannot get child at index `".concat(index, "` in node: ").concat(Scrubber.stringify(root)));
}
return c;
},
children: function children(root, path) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return /*#__PURE__*/regenerator.mark(function _callee2() {
var _options$reverse, reverse, ancestor, children, index, child, childPath;
return regenerator.wrap(function (_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_options$reverse = options.reverse, reverse = _options$reverse === void 0 ? false : _options$reverse;
ancestor = Node.ancestor(root, path);
children = ancestor.children;
index = reverse ? children.length - 1 : 0;
case 1:
if (!(reverse ? index >= 0 : index < children.length)) {
_context2.next = 3;
break;
}
child = Node.child(ancestor, index);
childPath = path.concat(index);
_context2.next = 2;
return [child, childPath];
case 2:
index = reverse ? index - 1 : index + 1;
_context2.next = 1;
break;
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
})();
},
common: function common(root, path, another) {
var p = Path.common(path, another);
var n = Node.get(root, p);
return [n, p];
},
descendant: function descendant(root, path) {
var node = Node.get(root, path);
if (Node.isEditor(node)) {
throw new Error("Cannot get the descendant node at path [".concat(path, "] because it refers to the root editor node instead: ").concat(Scrubber.stringify(node)));
}
return node;
},
descendants: function descendants(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return /*#__PURE__*/regenerator.mark(function _callee3() {
var _iterator2, _step2, _step2$value, node, path, _t2;
return regenerator.wrap(function (_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_iterator2 = _createForOfIteratorHelper$l(Node.nodes(root, options));
_context3.prev = 1;
_iterator2.s();
case 2:
if ((_step2 = _iterator2.n()).done) {
_context3.next = 4;
break;
}
_step2$value = _slicedToArray(_step2.value, 2), node = _step2$value[0], path = _step2$value[1];
if (!(path.length !== 0)) {
_context3.next = 3;
break;
}
_context3.next = 3;
return [node, path];
case 3:
_context3.next = 2;
break;
case 4:
_context3.next = 6;
break;
case 5:
_context3.prev = 5;
_t2 = _context3["catch"](1);
_iterator2.e(_t2);
case 6:
_context3.prev = 6;
_iterator2.f();
return _context3.finish(6);
case 7:
case "end":
return _context3.stop();
}
}, _callee3, null, [[1, 5, 6, 7]]);
})();
},
elements: function elements(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return /*#__PURE__*/regenerator.mark(function _callee4() {
var _iterator3, _step3, _step3$value, node, path, _t3;
return regenerator.wrap(function (_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
_iterator3 = _createForOfIteratorHelper$l(Node.nodes(root, options));
_context4.prev = 1;
_iterator3.s();
case 2:
if ((_step3 = _iterator3.n()).done) {
_context4.next = 4;
break;
}
_step3$value = _slicedToArray(_step3.value, 2), node = _step3$value[0], path = _step3$value[1];
if (!Node.isElement(node)) {
_context4.next = 3;
break;
}
_context4.next = 3;
return [node, path];
case 3:
_context4.next = 2;
break;
case 4:
_context4.next = 6;
break;
case 5:
_context4.prev = 5;
_t3 = _context4["catch"](1);
_iterator3.e(_t3);
case 6:
_context4.prev = 6;
_iterator3.f();
return _context4.finish(6);
case 7:
case "end":
return _context4.stop();
}
}, _callee4, null, [[1, 5, 6, 7]]);
})();
},
extractProps: function extractProps(node) {
if (Node.isText(node)) {
node.text;
var properties = _objectWithoutProperties(node, _excluded$3);
return properties;
} else {
node.children;
var _properties = _objectWithoutProperties(node, _excluded2$3);
return _properties;
}
},
first: function first(root, path) {
var p = path.slice();
var n = Node.get(root, p);
while (n) {
if (Node.isText(n) || n.children.length === 0) {
break;
} else {
n = n.children[0];
p.push(0);
}
}
return [n, p];
},
fragment: function fragment(root, range) {
var _Range$edges = Range.edges(range),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
rootStart = _Range$edges2[0],
rootEnd = _Range$edges2[1];
var firstIndex = rootStart.path[0];
var newRoot = {
children: root.children.slice(firstIndex, rootEnd.path[0] + 1)
};
var toSlicedPoint = function toSlicedPoint(point) {
return _objectSpread$f(_objectSpread$f({}, point), {}, {
path: [point.path[0] - firstIndex].concat(_toConsumableArray(point.path.slice(1)))
});
};
var start = toSlicedPoint(rootStart);
var end = toSlicedPoint(rootEnd);
var slicedRange = {
anchor: start,
focus: end
};
var nodeEntries = Node.nodes(newRoot, {
reverse: true,
pass: function pass(_ref) {
var _ref2 = _slicedToArray(_ref, 2),
path = _ref2[1];
return !Range.includes(slicedRange, path);
}
});
var _iterator4 = _createForOfIteratorHelper$l(nodeEntries),
_step4;
try {
var _loop = function _loop() {
var _step4$value = _slicedToArray(_step4.value, 2),
path = _step4$value[1];
if (!Range.includes(slicedRange, path)) {
var index = path[path.length - 1];
modifyChildren(newRoot, Path.parent(path), function (children) {
return removeChildren(children, index, 1);
});
}
if (Path.equals(path, end.path)) {
modifyLeaf(newRoot, path, function (node) {
var before = node.text.slice(0, end.offset);
return _objectSpread$f(_objectSpread$f({}, node), {}, {
text: before
});
});
}
if (Path.equals(path, start.path)) {
modifyLeaf(newRoot, path, function (node) {
var before = node.text.slice(start.offset);
return _objectSpread$f(_objectSpread$f({}, node), {}, {
text: before
});
});
}
};
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
_loop();
}
} catch (err) {
_iterator4.e(err);
} finally {
_iterator4.f();
}
return newRoot.children;
},
get: function get(root, path) {
var node = Node.getIf(root, path);
if (node === undefined) {
throw new Error("Cannot find a descendant at path [".concat(path, "] in node: ").concat(Scrubber.stringify(root)));
}
return node;
},
getIf: function getIf(root, path) {
var node = root;
for (var i = 0; i < path.length; i++) {
var p = path[i];
if (typeof p !== 'number') {
throw new Error('Got non-numeric path index');
}
if (Node.isText(node) || !node.children[p]) {
return;
}
node = node.children[p];
}
return node;
},
has: function has(root, path) {
var node = root;
for (var i = 0; i < path.length; i++) {
var p = path[i];
if (typeof p !== 'number') {
throw new Error('Got non-numeric path index');
}
if (Node.isText(node) || !node.children[p]) {
return false;
}
node = node.children[p];
}
return true;
},
isAncestor: function isAncestor(node) {
return !Node.isText(node);
},
isEditor: function isEditor(node) {
return typeof node.apply === 'function';
},
isElement: function isElement(node) {
return Array.isArray(node.children) && typeof node.apply !== 'function';
},
isNode: function isNode(value) {
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref3$deep = _ref3.deep,
deep = _ref3$deep === void 0 ? false : _ref3$deep;
return Text.isText(value) || Element.isElement(value, {
deep: deep
}) || Editor.isEditor(value, {
deep: deep
});
},
isNodeList: function isNodeList(value) {
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref4$deep = _ref4.deep,
deep = _ref4$deep === void 0 ? false : _ref4$deep;
return Array.isArray(value) && value.every(function (val) {
return Node.isNode(val, {
deep: deep
});
});
},
isText: function isText(node) {
return typeof node.text === 'string';
},
last: function last(root, path) {
var p = path.slice();
var n = Node.get(root, p);
while (n) {
if (Node.isText(n) || n.children.length === 0) {
break;
} else {
var i = n.children.length - 1;
n = n.children[i];
p.push(i);
}
}
return [n, p];
},
leaf: function leaf(root, path) {
var node = Node.get(root, path);
if (!Node.isText(node)) {
throw new Error("Cannot get the leaf node at path [".concat(path, "] because it refers to a non-leaf node: ").concat(Scrubber.stringify(node)));
}
return node;
},
levels: function levels(root, path) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return /*#__PURE__*/regenerator.mark(function _callee5() {
var _iterator5, _step5, p, n, _t4;
return regenerator.wrap(function (_context5) {
while (1) switch (_context5.prev = _context5.next) {
case 0:
_iterator5 = _createForOfIteratorHelper$l(Path.levels(path, options));
_context5.prev = 1;
_iterator5.s();
case 2:
if ((_step5 = _iterator5.n()).done) {
_context5.next = 4;
break;
}
p = _step5.value;
n = Node.get(root, p);
_context5.next = 3;
return [n, p];
case 3:
_context5.next = 2;
break;
case 4:
_context5.next = 6;
break;
case 5:
_context5.prev = 5;
_t4 = _context5["catch"](1);
_iterator5.e(_t4);
case 6:
_context5.prev = 6;
_iterator5.f();
return _context5.finish(6);
case 7:
case "end":
return _context5.stop();
}
}, _callee5, null, [[1, 5, 6, 7]]);
})();
},
matches: function matches(node, props) {
return Node.isElement(node) && Element.isElementProps(props) && Element.matches(node, props) || Node.isText(node) && Text.isTextProps(props) && Text.matches(node, props);
},
nodes: function nodes(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return /*#__PURE__*/regenerator.mark(function _callee6() {
var pass, _options$reverse2, reverse, _options$from, from, to, visited, p, n, nextIndex, newPath, _newPath;
return regenerator.wrap(function (_context6) {
while (1) switch (_context6.prev = _context6.next) {
case 0:
pass = options.pass, _options$reverse2 = options.reverse, reverse = _options$reverse2 === void 0 ? false : _options$reverse2;
_options$from = options.from, from = _options$from === void 0 ? [] : _options$from, to = options.to;
visited = new Set();
p = [];
n = root;
case 1:
if (!(to && (reverse ? Path.isBefore(p, to) : Path.isAfter(p, to)))) {
_context6.next = 2;
break;
}
return _context6.abrupt("continue", 8);
case 2:
if (visited.has(n)) {
_context6.next = 3;
break;
}
_context6.next = 3;
return [n, p];
case 3:
if (!(!visited.has(n) && !Node.isText(n) && n.children.length !== 0 && (pass == null || pass([n, p]) === false))) {
_context6.next = 4;
break;
}
visited.add(n);
nextIndex = reverse ? n.children.length - 1 : 0;
if (Path.isAncestor(p, from)) {
nextIndex = from[p.length];
}
p = p.concat(nextIndex);
n = Node.get(root, p);
return _context6.abrupt("continue", 1);
case 4:
if (!(p.length === 0)) {
_context6.next = 5;
break;
}
return _context6.abrupt("continue", 8);
case 5:
if (reverse) {
_context6.next = 6;
break;
}
newPath = Path.next(p);
if (!Node.has(root, newPath)) {
_context6.next = 6;
break;
}
p = newPath;
n = Node.get(root, p);
return _context6.abrupt("continue", 1);
case 6:
if (!(reverse && p[p.length - 1] !== 0)) {
_context6.next = 7;
break;
}
_newPath = Path.previous(p);
p = _newPath;
n = Node.get(root, p);
return _context6.abrupt("continue", 1);
case 7:
// Otherwise we're going upward...
p = Path.parent(p);
n = Node.get(root, p);
visited.add(n);
_context6.next = 1;
break;
case 8:
case "end":
return _context6.stop();
}
}, _callee6);
})();
},
parent: function parent(root, path) {
var parentPath = Path.parent(path);
var node = Node.get(root, parentPath);
if (Node.isText(node)) {
// this can happen if `path` points somewhere that doesnt exist and it's where a child of a text node would be
throw new Error("Cannot get the parent of path [".concat(path, "] because it does not exist in the root."));
}
return node;
},
string: function string(node) {
if (Node.isText(node)) {
return node.text;
} else {
return node.children.map(Node.string).join('');
}
},
texts: function texts(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return /*#__PURE__*/regenerator.mark(function _callee7() {
var _iterator6, _step6, _step6$value, node, path, _t5;
return regenerator.wrap(function (_context7) {
while (1) switch (_context7.prev = _context7.next) {
case 0:
_iterator6 = _createForOfIteratorHelper$l(Node.nodes(root, options));
_context7.prev = 1;
_iterator6.s();
case 2:
if ((_step6 = _iterator6.n()).done) {
_context7.next = 4;
break;
}
_step6$value = _slicedToArray(_step6.value, 2), node = _step6$value[0], path = _step6$value[1];
if (!Node.isText(node)) {
_context7.next = 3;
break;
}
_context7.next = 3;
return [node, path];
case 3:
_context7.next = 2;
break;
case 4:
_context7.next = 6;
break;
case 5:
_context7.prev = 5;
_t5 = _context7["catch"](1);
_iterator6.e(_t5);
case 6:
_context7.prev = 6;
_iterator6.f();
return _context7.finish(6);
case 7:
case "end":
return _context7.stop();
}
}, _callee7, null, [[1, 5, 6, 7]]);
})();
}
};
function ownKeys$e(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
// eslint-disable-next-line no-redeclare
var Operation = {
isNodeOperation: function isNodeOperation(value) {
return Operation.isOperation(value) && value.type.endsWith('_node');
},
isOperation: function isOperation(value) {
if (!isObject(value)) {
return false;
}
switch (value.type) {
case 'insert_node':
return Path.isPath(value.path) && Node.isNode(value.node);
case 'insert_text':
return typeof value.offset === 'number' && typeof value.text === 'string' && Path.isPath(value.path);
case 'merge_node':
return typeof value.position === 'number' && Path.isPath(value.path) && isObject(value.properties);
case 'move_node':
return Path.isPath(value.path) && Path.isPath(value.newPath);
case 'remove_node':
return Path.isPath(value.path) && Node.isNode(value.node);
case 'remove_text':
return typeof value.offset === 'number' && typeof value.text === 'string' && Path.isPath(value.path);
case 'set_node':
return Path.isPath(value.path) && isObject(value.properties) && isObject(value.newProperties);
case 'set_selection':
return value.properties === null && Range.isRange(value.newProperties) || value.newProperties === null && Range.isRange(value.properties) || isObject(value.properties) && isObject(value.newProperties);
case 'split_node':
return Path.isPath(value.path) && typeof value.position === 'number' && isObject(value.properties);
default:
return false;
}
},
isOperationList: function isOperationList(value) {
return Array.isArray(value) && value.every(function (val) {
return Operation.isOperation(val);
});
},
isSelectionOperation: function isSelectionOperation(value) {
return Operation.isOperation(value) && value.type.endsWith('_selection');
},
isTextOperation: function isTextOperation(value) {
return Operation.isOperation(value) && value.type.endsWith('_text');
},
inverse: function inverse(op) {
switch (op.type) {
case 'insert_node':
{
return _objectSpread$e(_objectSpread$e({}, op), {}, {
type: 'remove_node'
});
}
case 'insert_text':
{
return _objectSpread$e(_objectSpread$e({}, op), {}, {
type: 'remove_text'
});
}
case 'merge_node':
{
return _objectSpread$e(_objectSpread$e({}, op), {}, {
type: 'split_node',
path: Path.previous(op.path)
});
}
case 'move_node':
{
var newPath = op.newPath,
path = op.path;
// PERF: in this case the move operation is a no-op anyways.
if (Path.equals(newPath, path)) {
return op;
}
// If the move happens completely within a single parent the path and
// newPath are stable with respect to each other.
if (Path.isSibling(path, newPath)) {
return _objectSpread$e(_objectSpread$e({}, op), {}, {
path: newPath,
newPath: path
});
}
// If the move does not happen within a single parent it is possible
// for the move to impact the true path to the location where the node
// was removed from and where it was inserted. We have to adjust for this
// and find the original path. We can accomplish this (only in non-sibling)
// moves by looking at the impact of the move operation on the node
// after the original move path.
var inversePath = Path.transform(path, op);
var inverseNewPath = Path.transform(Path.next(path), op);
return _objectSpread$e(_objectSpread$e({}, op), {}, {
path: inversePath,
newPath: inverseNewPath
});
}
case 'remove_node':
{
return _objectSpread$e(_objectSpread$e({}, op), {}, {
type: 'insert_node'
});
}
case 'remove_text':
{
return _objectSpread$e(_objectSpread$e({}, op), {}, {
type: 'insert_text'
});
}
case 'set_node':
{
var properties = op.properties,
newProperties = op.newProperties;
return _objectSpread$e(_objectSpread$e({}, op), {}, {
properties: newProperties,
newProperties: properties
});
}
case 'set_selection':
{
var _properties = op.properties,
_newProperties = op.newProperties;
if (_properties == null) {
return _objectSpread$e(_objectSpread$e({}, op), {}, {
properties: _newProperties,
newProperties: null
});
} else if (_newProperties == null) {
return _objectSpread$e(_objectSpread$e({}, op), {}, {
properties: null,
newProperties: _properties
});
} else {
return _objectSpread$e(_objectSpread$e({}, op), {}, {
properties: _newProperties,
newProperties: _properties
});
}
}
case 'split_node':
{
return _objectSpread$e(_objectSpread$e({}, op), {}, {
type: 'merge_node',
path: Path.next(op.path)
});
}
}
}
};
var isObject = function isObject(value) {
return _typeof(value) === 'object' && value !== null;
};
/**
* Custom deep equal comparison for Slate nodes. Since Slate only supports plain
* values, arrays and nested objects, we don't need a general purpose deep
* equality check.
*
* Slate objects are designed to be serialised, so missing keys are deliberately
* normalised to undefined.
*/
var _isDeepEqual = function isDeepEqual(a, b) {
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false;
for (var i = 0; i < a.length; i++) {
if (!_isDeepEqual(a[i], b[i])) return false;
}
return true;
}
if (isObject(a) && isObject(b)) {
for (var key in a) {
var valueA = Object.hasOwn(a, key) ? a[key] : undefined;
var valueB = Object.hasOwn(b, key) ? b[key] : undefined;
if (!_isDeepEqual(valueA, valueB)) return false;
}
// Deep object equality is only necessary in one direction; in the reverse
// direction we are only looking for keys that are missing. As above,
// undefined keys treated the same as missing keys.
for (var _key in b) {
if (a[_key] === undefined && b[_key] !== undefined) return false;
}
return true;
}
return a === b;
};
/**
* Get the default location to insert content into the editor.
* By default, use the selection as the target location. But if there is
* no selection, insert at the end of the document since that is such a
* common use case when inserting from a non-selected state.
*/
var getDefaultInsertLocation = function getDefaultInsertLocation(editor) {
if (editor.selection) {
return editor.selection;
} else if (editor.children.length > 0) {
return Editor.end(editor, []);
} else {
return [0];
}
};
var matchPath = function matchPath(editor, path) {
var _Editor$node = Editor.node(editor, path),
_Editor$node2 = _slicedToArray(_Editor$node, 1),
node = _Editor$node2[0];
return function (n) {
return n === node;
};
};
function _createForOfIteratorHelper$k(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$k(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$k(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$k(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$k(r, a) : void 0; } }
function _arrayLikeToArray$k(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
// Character (grapheme cluster) boundaries are determined according to
// the default grapheme cluster boundary specification, extended grapheme clusters variant[1].
//
// References:
//
// [1] https://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table
// [2] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
// [3] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.html
// [4] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
/**
* Get the distance to the end of the first character in a string of text.
*/
var getCharacterDistance = function getCharacterDistance(str) {
var isRTL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var isLTR = !isRTL;
var codepoints = isRTL ? codepointsIteratorRTL(str) : str;
var left = CodepointType.None;
var right = CodepointType.None;
var distance = 0;
// Evaluation of these conditions are deferred.
var gb11 = null; // Is GB11 applicable?
var gb12Or13 = null; // Is GB12 or GB13 applicable?
var gb9c = null; // Is GB9c applicable?
var _iterator = _createForOfIteratorHelper$k(codepoints),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _char = _step.value;
var code = _char.codePointAt(0);
if (!code) break;
var type = getCodepointType(_char, code);
var _ref = isLTR ? [right, type] : [type, left];
var _ref2 = _slicedToArray(_ref, 2);
left = _ref2[0];
right = _ref2[1];
if (intersects(left, CodepointType.ZWJ) && intersects(right, CodepointType.ExtPict)) {
if (isLTR) {
gb11 = endsWithEmojiZWJ(str.substring(0, distance));
} else {
gb11 = endsWithEmojiZWJ(str.substring(0, str.length - distance));
}
if (!gb11) break;
}
if (intersects(left, CodepointType.RI) && intersects(right, CodepointType.RI)) {
if (gb12Or13 !== null) {
gb12Or13 = !gb12Or13;
} else {
if (isLTR) {
gb12Or13 = true;
} else {
gb12Or13 = endsWithOddNumberOfRIs(str.substring(0, str.length - distance));
}
}
if (!gb12Or13) break;
}
if (intersects(left, CodepointType.InCBLinker | CodepointType.InCBExtend) && intersects(right, CodepointType.InCBConsonant)) {
if (isLTR) {
gb9c = endsWithConjunctLinker(str.substring(0, distance));
} else {
gb9c = endsWithConjunctLinker(str.substring(0, str.length - distance));
}
if (!gb9c) break;
}
if (left !== CodepointType.None && right !== CodepointType.None && isBoundaryPair(left, right)) {
break;
}
distance += _char.length;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return distance || 1;
};
var SPACE = /\s/;
var PUNCTUATION = /[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;
var CHAMELEON = /['\u2018\u2019]/;
/**
* Get the distance to the end of the first word in a string of text.
*/
var getWordDistance = function getWordDistance(text) {
var isRTL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var dist = 0;
var started = false;
while (text.length > 0) {
var charDist = getCharacterDistance(text, isRTL);
var _splitByCharacterDist = splitByCharacterDistance(text, charDist, isRTL),
_splitByCharacterDist2 = _slicedToArray(_splitByCharacterDist, 2),
_char2 = _splitByCharacterDist2[0],
remaining = _splitByCharacterDist2[1];
if (_isWordCharacter(_char2, remaining, isRTL)) {
started = true;
dist += charDist;
} else if (!started) {
dist += charDist;
} else {
break;
}
text = remaining;
}
return dist;
};
/**
* Split a string in two parts at a given distance starting from the end when
* `isRTL` is set to `true`.
*/
var splitByCharacterDistance = function splitByCharacterDistance(str, dist, isRTL) {
if (isRTL) {
var at = str.length - dist;
return [str.slice(at, str.length), str.slice(0, at)];
}
return [str.slice(0, dist), str.slice(dist)];
};
/**
* Check if a character is a word character. The `remaining` argument is used
* because sometimes you must read subsequent characters to truly determine it.
*/
var _isWordCharacter = function isWordCharacter(_char3, remaining) {
var isRTL = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (SPACE.test(_char3)) {
return false;
}
// Chameleons count as word characters as long as they're in a word, so
// recurse to see if the next one is a word character or not.
if (CHAMELEON.test(_char3)) {
var charDist = getCharacterDistance(remaining, isRTL);
var _splitByCharacterDist3 = splitByCharacterDistance(remaining, charDist, isRTL),
_splitByCharacterDist4 = _slicedToArray(_splitByCharacterDist3, 2),
nextChar = _splitByCharacterDist4[0],
nextRemaining = _splitByCharacterDist4[1];
if (_isWordCharacter(nextChar, nextRemaining, isRTL)) {
return true;
}
}
if (PUNCTUATION.test(_char3)) {
return false;
}
return true;
};
/**
* Iterate on codepoints from right to left.
*/
var codepointsIteratorRTL = /*#__PURE__*/regenerator.mark(function codepointsIteratorRTL(str) {
var end, i, char1, char2;
return regenerator.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
end = str.length - 1;
i = 0;
case 1:
if (!(i < str.length)) {
_context.next = 5;
break;
}
char1 = str.charAt(end - i);
if (!isLowSurrogate(char1.charCodeAt(0))) {
_context.next = 3;
break;
}
char2 = str.charAt(end - i - 1);
if (!isHighSurrogate(char2.charCodeAt(0))) {
_context.next = 3;
break;
}
_context.next = 2;
return char2 + char1;
case 2:
i++;
return _context.abrupt("continue", 4);
case 3:
_context.next = 4;
return char1;
case 4:
i++;
_context.next = 1;
break;
case 5:
case "end":
return _context.stop();
}
}, codepointsIteratorRTL);
});
/**
* Is `charCode` a high surrogate.
*
* https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
*/
var isHighSurrogate = function isHighSurrogate(charCode) {
return charCode >= 0xd800 && charCode <= 0xdbff;
};
/**
* Is `charCode` a low surrogate.
*
* https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
*/
var isLowSurrogate = function isLowSurrogate(charCode) {
return charCode >= 0xdc00 && charCode <= 0xdfff;
};
var CodepointType;
(function (CodepointType) {
CodepointType[CodepointType["None"] = 0] = "None";
CodepointType[CodepointType["Extend"] = 1] = "Extend";
CodepointType[CodepointType["ZWJ"] = 2] = "ZWJ";
CodepointType[CodepointType["RI"] = 4] = "RI";
CodepointType[CodepointType["Prepend"] = 8] = "Prepend";
CodepointType[CodepointType["SpacingMark"] = 16] = "SpacingMark";
CodepointType[CodepointType["L"] = 32] = "L";
CodepointType[CodepointType["V"] = 64] = "V";
CodepointType[CodepointType["T"] = 128] = "T";
CodepointType[CodepointType["LV"] = 256] = "LV";
CodepointType[CodepointType["LVT"] = 512] = "LVT";
CodepointType[CodepointType["ExtPict"] = 1024] = "ExtPict";
CodepointType[CodepointType["Any"] = 2048] = "Any";
CodepointType[CodepointType["InCBConsonant"] = 4096] = "InCBConsonant";
CodepointType[CodepointType["InCBExtend"] = 8192] = "InCBExtend";
CodepointType[CodepointType["InCBLinker"] = 16384] = "InCBLinker";
})(CodepointType || (CodepointType = {}));
var reExtend = /^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05C9\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B53-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC0\u0CC2\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1AF0\u1B00-\u1B03\u1B34-\u1B3D\u1B42-\u1B44\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF3\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA953\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9C0\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDECB-\uDECF\uDEF0-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC0\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34-\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF4D\uDF57\uDF66-\uDF6C\uDF70-\uDF74\uDFB8\uDFBB-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFC9\uDFCE-\uDFD0\uDFD2\uDFE1\uDFE2]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB7\uDF1D\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B-\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99\uDF60\uDF62-\uDF64\uDF66]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDDF0\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD29\uDD2D-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD27\uDD28\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDE50-\uDE52\uDE5B\uDE5C\uDE5F\uDE80\uDE81]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/;
var rePrepend = /^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/;
var reSpacingMark = /^(?:[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E\u094F\u0982\u0983\u09BF\u09C0\u09C7\u09C8\u09CB\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB\u0ACC\u0B02\u0B03\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82\u0C83\u0CBE\u0CC0\u0CC1\u0CC3\u0CC4\u0CC7\u0CC8\u0CCA\u0CCB\u0D02\u0D03\u0D3F\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82\u0D83\u0DD0\u0DD1\u0DD8-\u0DDE\u0DF2\u0DF3\u0E33\u0EB3\u0F3E\u0F3F\u0F7F\u1031\u103B\u103C\u1056\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7\u17C8\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1A19\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43\u1B44\u1B82\u1BA1\u1BA6\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1C24-\u1C2B\u1C34\u1C35\u1CE1\u1CF7\uA823\uA824\uA827\uA880\uA881\uA8B4-\uA8C3\uA952\uA953\uA983\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9C0\uAA2F\uAA30\uAA33\uAA34\uAA4D\uAAEB\uAAEE\uAAEF\uAAF5\uABE3\uABE4\uABE6\uABE7\uABE9\uABEA\uABEC]|\uD804[\uDC00\uDC02\uDC82\uDCB0-\uDCB2\uDCB7\uDCB8\uDD2C\uDD45\uDD46\uDD82\uDDB3-\uDDB5\uDDBF\uDDC0\uDDCE\uDE2C-\uDE2E\uDE32\uDE33\uDE35\uDEE0-\uDEE2\uDF02\uDF03\uDF3F\uDF41-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF62\uDF63]|\uD805[\uDC35-\uDC37\uDC40\uDC41\uDC45\uDCB1\uDCB2\uDCB9\uDCBB\uDCBC\uDCBE\uDCC1\uDDB0\uDDB1\uDDB8-\uDDBB\uDDBE\uDE30-\uDE32\uDE3B\uDE3C\uDE3E\uDEAC\uDEAE\uDEAF\uDEB6\uDF26]|\uD806[\uDC2C-\uDC2E\uDC38\uDD31-\uDD35\uDD37\uDD38\uDD3D\uDD40\uDD42\uDDD1-\uDDD3\uDDDC-\uDDDF\uDDE4\uDE39\uDE57\uDE58\uDE97]|\uD807[\uDC2F\uDC3E\uDCA9\uDCB1\uDCB4\uDD8A-\uDD8E\uDD93\uDD94\uDD96\uDEF5\uDEF6]|\uD81B[\uDF51-\uDF87\uDFF0\uDFF1]|\uD834[\uDD66\uDD6D])$/;
var reL = /^[\u1100-\u115F\uA960-\uA97C]$/;
var reV = /^[\u1160-\u11A7\uD7B0-\uD7C6]$/;
var reT = /^[\u11A8-\u11FF\uD7CB-\uD7FB]$/;
var reLV = /^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/;
var reLVT = /^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\uC3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/;
var reExtPict = /^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDC2C-\uDC2F\uDC94-\uDC9F\uDCAF\uDCB0\uDCC0\uDCCF\uDCD0\uDCF6-\uDCFF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAF-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDE5F\uDE66-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFA]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDEE5\uDEE9\uDEEB-\uDEF0\uDEF3-\uDEFF\uDFDC-\uDFF0]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE\uDCAF\uDCBC-\uDCBF\uDCC2-\uDCCF\uDCD9-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE58-\uDE5F\uDE6E-\uDEFF]|\uD83F[\uDC00-\uDFFD])$/;
var reInCBConsonant = /^(?:[\u0915-\u0939\u0958-\u095F\u0978-\u097F\u0995-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC\u09DD\u09DF\u09F0\u09F1\u0A95-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0AF9\u0B15-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B5C\u0B5D\u0B5F\u0B71\u0C15-\u0C28\u0C2A-\u0C39\u0C58-\u0C5A\u0D15-\u0D3A\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1780-\u17B3\u1A20-\u1A54\u1B0B\u1B0C\u1B13-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBB-\u1BBD\uA989-\uA98B\uA98F-\uA9B2\uA9E0-\uA9E4\uA9E7-\uA9EF\uA9FA-\uA9FE\uAA60-\uAA6F\uAA71-\uAA73\uAA7A\uAA7E\uAA7F\uAAE0-\uAAEA\uABC0-\uABDA]|\uD802[\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35]|\uD804[\uDD03-\uDD26\uDD44\uDD47\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5]|\uD806[\uDD00-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDE00\uDE0B-\uDE32\uDE50\uDE5C-\uDE83]|\uD807[\uDF04-\uDF10\uDF12-\uDF33])$/;
var reInCBExtend = /^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4C\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC0\u0CC2\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D1\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B03\u1B34-\u1B3D\u1B42\u1B43\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8-\u1BAA\u1BAC\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF3\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA953\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD32\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC0\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34-\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF4D\uDF57\uDF66-\uDF6C\uDF70-\uDF74\uDFB8\uDFBB-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFC9\uDFCE\uDFCF\uDFD2\uDFE1\uDFE2]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB7\uDF1D\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B-\uDD3D\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDF60\uDF62-\uDF64\uDF66]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF41\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD29\uDD2D-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/;
var reInCBLinker = /^(?:[\u094D\u09CD\u0ACD\u0B4D\u0C4D\u0D4D\u1039\u17D2\u1A60\u1B44\u1BAB\uA9C0\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807\uDF42)$/;
var getCodepointType = function getCodepointType(_char4, code) {
var type = CodepointType.Any;
if (_char4.search(reExtend) !== -1) {
type |= CodepointType.Extend;
}
if (code === 0x200d) {
type |= CodepointType.ZWJ;
}
if (code >= 0x1f1e6 && code <= 0x1f1ff) {
type |= CodepointType.RI;
}
if (_char4.search(rePrepend) !== -1) {
type |= CodepointType.Prepend;
}
if (_char4.search(reSpacingMark) !== -1) {
type |= CodepointType.SpacingMark;
}
if (_char4.search(reL) !== -1) {
type |= CodepointType.L;
}
if (_char4.search(reV) !== -1) {
type |= CodepointType.V;
}
if (_char4.search(reT) !== -1) {
type |= CodepointType.T;
}
if (_char4.search(reLV) !== -1) {
type |= CodepointType.LV;
}
if (_char4.search(reLVT) !== -1) {
type |= CodepointType.LVT;
}
if (_char4.search(reExtPict) !== -1) {
type |= CodepointType.ExtPict;
}
if (_char4.search(reInCBConsonant) !== -1) {
type |= CodepointType.InCBConsonant;
}
if (_char4.search(reInCBExtend) !== -1) {
type |= CodepointType.InCBExtend;
}
if (_char4.search(reInCBLinker) !== -1) {
type |= CodepointType.InCBLinker;
}
return type;
};
function intersects(x, y) {
return (x & y) !== 0;
}
var NonBoundaryPairs = [
// GB6
[CodepointType.L, CodepointType.L | CodepointType.V | CodepointType.LV | CodepointType.LVT],
// GB7
[CodepointType.LV | CodepointType.V, CodepointType.V | CodepointType.T],
// GB8
[CodepointType.LVT | CodepointType.T, CodepointType.T],
// GB9
[CodepointType.Any, CodepointType.Extend | CodepointType.ZWJ],
// GB9a
[CodepointType.Any, CodepointType.SpacingMark],
// GB9b
[CodepointType.Prepend, CodepointType.Any],
// GB9c
[CodepointType.InCBLinker | CodepointType.InCBExtend, CodepointType.InCBConsonant],
// GB11
[CodepointType.ZWJ, CodepointType.ExtPict],
// GB12 and GB13
[CodepointType.RI, CodepointType.RI]];
function isBoundaryPair(left, right) {
return NonBoundaryPairs.findIndex(function (r) {
return intersects(left, r[0]) && intersects(right, r[1]);
}) === -1;
}
var endingEmojiZWJ = /(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDC2C-\uDC2F\uDC94-\uDC9F\uDCAF\uDCB0\uDCC0\uDCCF\uDCD0\uDCF6-\uDCFF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAF-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDE5F\uDE66-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFA]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDEE5\uDEE9\uDEEB-\uDEF0\uDEF3-\uDEFF\uDFDC-\uDFF0]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE\uDCAF\uDCBC-\uDCBF\uDCC2-\uDCCF\uDCD9-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE58-\uDE5F\uDE6E-\uDEFF]|\uD83F[\uDC00-\uDFFD])(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05C9\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B53-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC0\u0CC2\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1AF0\u1B00-\u1B03\u1B34-\u1B3D\u1B42-\u1B44\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF3\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA953\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9C0\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDECB-\uDECF\uDEF0-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC0\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34-\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF4D\uDF57\uDF66-\uDF6C\uDF70-\uDF74\uDFB8\uDFBB-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFC9\uDFCE-\uDFD0\uDFD2\uDFE1\uDFE2]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB7\uDF1D\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B-\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99\uDF60\uDF62-\uDF64\uDF66]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDDF0\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD29\uDD2D-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD27\uDD28\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDE50-\uDE52\uDE5B\uDE5C\uDE5F\uDE80\uDE81]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])*\u200D$/;
var endsWithEmojiZWJ = function endsWithEmojiZWJ(str) {
return str.search(endingEmojiZWJ) !== -1;
};
// GB9c: Consonant [Extend Linker]* Linker [Extend Linker]* left context.
var endingConjunctLinker = /(?:[\u0915-\u0939\u0958-\u095F\u0978-\u097F\u0995-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC\u09DD\u09DF\u09F0\u09F1\u0A95-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0AF9\u0B15-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B5C\u0B5D\u0B5F\u0B71\u0C15-\u0C28\u0C2A-\u0C39\u0C58-\u0C5A\u0D15-\u0D3A\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1780-\u17B3\u1A20-\u1A54\u1B0B\u1B0C\u1B13-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBB-\u1BBD\uA989-\uA98B\uA98F-\uA9B2\uA9E0-\uA9E4\uA9E7-\uA9EF\uA9FA-\uA9FE\uAA60-\uAA6F\uAA71-\uAA73\uAA7A\uAA7E\uAA7F\uAAE0-\uAAEA\uABC0-\uABDA]|\uD802[\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35]|\uD804[\uDD03-\uDD26\uDD44\uDD47\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5]|\uD806[\uDD00-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDE00\uDE0B-\uDE32\uDE50\uDE5C-\uDE83]|\uD807[\uDF04-\uDF10\uDF12-\uDF33])(?:(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC0\u0CC2\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B03\u1B34-\u1B3D\u1B42-\u1B44\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF3\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA953\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9C0\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC0\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34-\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF4D\uDF57\uDF66-\uDF6C\uDF70-\uDF74\uDFB8\uDFBB-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFC9\uDFCE-\uDFD0\uDFD2\uDFE1\uDFE2]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB7\uDF1D\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B-\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99\uDF60\uDF62-\uDF64\uDF66]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD29\uDD2D-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]))*(?:[\u094D\u09CD\u0ACD\u0B4D\u0C4D\u0D4D\u1039\u17D2\u1A60\u1B44\u1BAB\uA9C0\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807\uDF42)(?:(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC0\u0CC2\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B03\u1B34-\u1B3D\u1B42-\u1B44\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF3\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA953\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9C0\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC0\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34-\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF4D\uDF57\uDF66-\uDF6C\uDF70-\uDF74\uDFB8\uDFBB-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFC9\uDFCE-\uDFD0\uDFD2\uDFE1\uDFE2]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB7\uDF1D\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B-\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99\uDF60\uDF62-\uDF64\uDF66]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD29\uDD2D-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]))*$/;
var endsWithConjunctLinker = function endsWithConjunctLinker(str) {
return str.search(endingConjunctLinker) !== -1;
};
var endingRIs = /(?:\uD83C[\uDDE6-\uDDFF])+$/g;
var endsWithOddNumberOfRIs = function endsWithOddNumberOfRIs(str) {
var match = str.match(endingRIs);
if (match === null) {
return false;
} else {
// A RI is represented by a surrogate pair.
var numRIs = match[0].length / 2;
return numRIs % 2 === 1;
}
};
var isEditor = function isEditor(value) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$deep = _ref.deep,
deep = _ref$deep === void 0 ? false : _ref$deep;
if (!isObject(value)) {
return false;
}
var isEditor = typeof value.above === 'function' && typeof value.addMark === 'function' && typeof value.after === 'function' && typeof value.apply === 'function' && typeof value.before === 'function' && typeof value.collapse === 'function' && typeof value["delete"] === 'function' && typeof value.deleteBackward === 'function' && typeof value.deleteForward === 'function' && typeof value.deleteFragment === 'function' && typeof value.deselect === 'function' && typeof value.edges === 'function' && typeof value.elementReadOnly === 'function' && typeof value.end === 'function' && typeof value.first === 'function' && typeof value.fragment === 'function' && typeof value.getDirtyPaths === 'function' && typeof value.getFragment === 'function' && typeof value.getMarks === 'function' && typeof value.hasBlocks === 'function' && typeof value.hasInlines === 'function' && typeof value.hasPath === 'function' && typeof value.hasTexts === 'function' && typeof value.insertBreak === 'function' && typeof value.insertFragment === 'function' && typeof value.insertNode === 'function' && typeof value.insertNodes === 'function' && typeof value.insertSoftBreak === 'function' && typeof value.insertText === 'function' && typeof value.isBlock === 'function' && typeof value.isEdge === 'function' && typeof value.isElementReadOnly === 'function' && typeof value.isEmpty === 'function' && typeof value.isEnd === 'function' && typeof value.isInline === 'function' && typeof value.isNormalizing === 'function' && typeof value.isSelectable === 'function' && typeof value.isStart === 'function' && typeof value.isVoid === 'function' && typeof value.last === 'function' && typeof value.leaf === 'function' && typeof value.levels === 'function' && typeof value.liftNodes === 'function' && typeof value.markableVoid === 'function' && typeof value.mergeNodes === 'function' && typeof value.move === 'function' && typeof value.moveNodes === 'function' && typeof value.next === 'function' && typeof value.node === 'function' && typeof value.nodes === 'function' && typeof value.normalize === 'function' && typeof value.normalizeNode === 'function' && typeof value.onChange === 'function' && typeof value.parent === 'function' && typeof value.path === 'function' && typeof value.pathRef === 'function' && typeof value.pathRefs === 'function' && typeof value.point === 'function' && typeof value.pointRef === 'function' && typeof value.pointRefs === 'function' && typeof value.positions === 'function' && typeof value.previous === 'function' && typeof value.range === 'function' && typeof value.rangeRef === 'function' && typeof value.rangeRefs === 'function' && typeof value.removeMark === 'function' && typeof value.removeNodes === 'function' && typeof value.select === 'function' && typeof value.setNodes === 'function' && typeof value.setNormalizing === 'function' && typeof value.setPoint === 'function' && typeof value.setSelection === 'function' && typeof value.shouldMergeNodesRemovePrevNode === 'function' && typeof value.shouldNormalize === 'function' && typeof value.splitNodes === 'function' && typeof value.start === 'function' && typeof value.string === 'function' && typeof value.unhangRange === 'function' && typeof value.unsetNodes === 'function' && typeof value.unwrapNodes === 'function' && typeof value["void"] === 'function' && typeof value.withoutNormalizing === 'function' && typeof value.wrapNodes === 'function' && (value.marks === null || isObject(value.marks)) && (value.selection === null || Range.isRange(value.selection)) && (deep ? Node.isNodeList(value.children) && Operation.isOperationList(value.operations) : Array.isArray(value.children) && Array.isArray(value.operations));
return isEditor;
};
// eslint-disable-next-line no-redeclare
var Editor = {
above: function above(editor, options) {
return editor.above(options);
},
addMark: function addMark(editor, key, value) {
editor.addMark(key, value);
},
after: function after(editor, at, options) {
return editor.after(at, options);
},
before: function before(editor, at, options) {
return editor.before(at, options);
},
deleteBackward: function deleteBackward(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$unit = options.unit,
unit = _options$unit === void 0 ? 'character' : _options$unit;
editor.deleteBackward(unit);
},
deleteForward: function deleteForward(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$unit2 = options.unit,
unit = _options$unit2 === void 0 ? 'character' : _options$unit2;
editor.deleteForward(unit);
},
deleteFragment: function deleteFragment(editor, options) {
editor.deleteFragment(options);
},
edges: function edges(editor, at) {
return editor.edges(at);
},
elementReadOnly: function elementReadOnly(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return editor.elementReadOnly(options);
},
end: function end(editor, at) {
return editor.end(at);
},
first: function first(editor, at) {
return editor.first(at);
},
fragment: function fragment(editor, at) {
return editor.fragment(at);
},
hasBlocks: function hasBlocks(editor, element) {
return editor.hasBlocks(element);
},
hasInlines: function hasInlines(editor, element) {
return editor.hasInlines(element);
},
hasPath: function hasPath(editor, path) {
return editor.hasPath(path);
},
hasTexts: function hasTexts(editor, element) {
return editor.hasTexts(element);
},
insertBreak: function insertBreak(editor) {
editor.insertBreak();
},
insertFragment: function insertFragment(editor, fragment, options) {
editor.insertFragment(fragment, options);
},
insertNode: function insertNode(editor, node) {
editor.insertNode(node);
},
insertSoftBreak: function insertSoftBreak(editor) {
editor.insertSoftBreak();
},
insertText: function insertText(editor, text) {
editor.insertText(text);
},
isBlock: function isBlock(editor, value) {
return editor.isBlock(value);
},
isEdge: function isEdge(editor, point, at) {
return editor.isEdge(point, at);
},
isEditor: isEditor,
isElementReadOnly: function isElementReadOnly(editor, element) {
return editor.isElementReadOnly(element);
},
isEmpty: function isEmpty(editor, element) {
return editor.isEmpty(element);
},
isEnd: function isEnd(editor, point, at) {
return editor.isEnd(point, at);
},
isInline: function isInline(editor, value) {
return editor.isInline(value);
},
isNormalizing: function isNormalizing(editor) {
return editor.isNormalizing();
},
isSelectable: function isSelectable(editor, value) {
return editor.isSelectable(value);
},
isStart: function isStart(editor, point, at) {
return editor.isStart(point, at);
},
isVoid: function isVoid(editor, value) {
return editor.isVoid(value);
},
last: function last(editor, at) {
return editor.last(at);
},
leaf: function leaf(editor, at, options) {
return editor.leaf(at, options);
},
levels: function levels(editor, options) {
return editor.levels(options);
},
marks: function marks(editor) {
return editor.getMarks();
},
next: function next(editor, options) {
return editor.next(options);
},
node: function node(editor, at, options) {
return editor.node(at, options);
},
nodes: function nodes(editor, options) {
return editor.nodes(options);
},
normalize: function normalize(editor, options) {
editor.normalize(options);
},
parent: function parent(editor, at, options) {
return editor.parent(at, options);
},
path: function path(editor, at, options) {
return editor.path(at, options);
},
pathRef: function pathRef(editor, path, options) {
return editor.pathRef(path, options);
},
pathRefs: function pathRefs(editor) {
return editor.pathRefs();
},
point: function point(editor, at, options) {
return editor.point(at, options);
},
pointRef: function pointRef(editor, point, options) {
return editor.pointRef(point, options);
},
pointRefs: function pointRefs(editor) {
return editor.pointRefs();
},
positions: function positions(editor, options) {
return editor.positions(options);
},
previous: function previous(editor, options) {
return editor.previous(options);
},
range: function range(editor, at, to) {
return editor.range(at, to);
},
rangeRef: function rangeRef(editor, range, options) {
return editor.rangeRef(range, options);
},
rangeRefs: function rangeRefs(editor) {
return editor.rangeRefs();
},
removeMark: function removeMark(editor, key) {
editor.removeMark(key);
},
setNormalizing: function setNormalizing(editor, isNormalizing) {
editor.setNormalizing(isNormalizing);
},
start: function start(editor, at) {
return editor.start(at);
},
string: function string(editor, at, options) {
return editor.string(at, options);
},
unhangRange: function unhangRange(editor, range, options) {
return editor.unhangRange(range, options);
},
"void": function _void(editor, options) {
return editor["void"](options);
},
withoutNormalizing: function withoutNormalizing(editor, fn) {
editor.withoutNormalizing(fn);
},
shouldMergeNodesRemovePrevNode: function shouldMergeNodesRemovePrevNode(editor, prevNode, curNode) {
return editor.shouldMergeNodesRemovePrevNode(prevNode, curNode);
}
};
// eslint-disable-next-line no-redeclare
var Location = {
isLocation: function isLocation(value) {
return Path.isPath(value) || Point.isPoint(value) || Range.isRange(value);
},
isPath: function isPath(at) {
return Array.isArray(at);
},
isPoint: function isPoint(at) {
return 'offset' in at;
},
isRange: function isRange(at) {
return 'anchor' in at;
},
isSpan: function isSpan(at) {
return Array.isArray(at) && Array.isArray(at[0]);
}
};
// eslint-disable-next-line no-redeclare
var Span = {
isSpan: function isSpan(value) {
return Array.isArray(value) && value.length === 2 && value.every(Path.isPath);
}
};
function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
// eslint-disable-next-line no-redeclare
var Point = {
compare: function compare(point, another) {
var result = Path.compare(point.path, another.path);
if (result === 0) {
if (point.offset < another.offset) return -1;
if (point.offset > another.offset) return 1;
return 0;
}
return result;
},
isAfter: function isAfter(point, another) {
return Point.compare(point, another) === 1;
},
isBefore: function isBefore(point, another) {
return Point.compare(point, another) === -1;
},
equals: function equals(point, another) {
// PERF: ensure the offsets are equal first since they are cheaper to check.
return point.offset === another.offset && Path.equals(point.path, another.path);
},
isPoint: function isPoint(value) {
return isObject(value) && typeof value.offset === 'number' && Path.isPath(value.path);
},
transform: function transform(point, op) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (point === null) {
return null;
}
var _options$affinity = options.affinity,
affinity = _options$affinity === void 0 ? 'forward' : _options$affinity;
var path = point.path,
offset = point.offset;
switch (op.type) {
case 'insert_node':
case 'move_node':
{
path = Path.transform(path, op, options);
break;
}
case 'insert_text':
{
if (Path.equals(op.path, path) && (op.offset < offset || op.offset === offset && affinity === 'forward')) {
offset += op.text.length;
}
break;
}
case 'merge_node':
{
if (Path.equals(op.path, path)) {
offset += op.position;
}
path = Path.transform(path, op, options);
break;
}
case 'remove_text':
{
if (Path.equals(op.path, path) && op.offset <= offset) {
offset -= Math.min(offset - op.offset, op.text.length);
}
break;
}
case 'remove_node':
{
if (Path.equals(op.path, path) || Path.isAncestor(op.path, path)) {
return null;
}
path = Path.transform(path, op, options);
break;
}
case 'split_node':
{
if (Path.equals(op.path, path)) {
if (op.position === offset && affinity == null) {
return null;
} else if (op.position < offset || op.position === offset && affinity === 'forward') {
offset -= op.position;
path = Path.transform(path, op, _objectSpread$d(_objectSpread$d({}, options), {}, {
affinity: 'forward'
}));
}
} else {
path = Path.transform(path, op, options);
}
break;
}
default:
return point;
}
return {
path: path,
offset: offset
};
}
};
var _scrubber = undefined;
/**
* This interface implements a stringify() function, which is used by Slate
* internally when generating exceptions containing end user data. Developers
* using Slate may call Scrubber.setScrubber() to alter the behavior of this
* stringify() function.
*
* For example, to prevent the cleartext logging of 'text' fields within Nodes:
*
* import { Scrubber } from 'slate';
* Scrubber.setScrubber((key, val) => {
* if (key === 'text') return '...scrubbed...'
* return val
* });
*
*/
// eslint-disable-next-line no-redeclare
var Scrubber = {
setScrubber: function setScrubber(scrubber) {
_scrubber = scrubber;
},
stringify: function stringify(value) {
return JSON.stringify(value, _scrubber);
}
};
var _excluded$2 = ["text"],
_excluded2$2 = ["anchor", "focus", "merge"];
function _createForOfIteratorHelper$j(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$j(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$j(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$j(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$j(r, a) : void 0; } }
function _arrayLikeToArray$j(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
// eslint-disable-next-line no-redeclare
var Text = {
equals: function equals(text, another) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _options$loose = options.loose,
loose = _options$loose === void 0 ? false : _options$loose;
function omitText(obj) {
obj.text;
var rest = _objectWithoutProperties(obj, _excluded$2);
return rest;
}
return _isDeepEqual(loose ? omitText(text) : text, loose ? omitText(another) : another);
},
isText: function isText(value) {
return isObject(value) && typeof value.text === 'string';
},
isTextList: function isTextList(value) {
return Array.isArray(value) && value.every(function (val) {
return Text.isText(val);
});
},
isTextProps: function isTextProps(props) {
return props.text !== undefined;
},
matches: function matches(text, props) {
for (var key in props) {
if (key === 'text') {
continue;
}
if (!text.hasOwnProperty(key) || text[key] !== props[key]) {
return false;
}
}
return true;
},
decorations: function decorations(node, _decorations) {
var leaves = [{
leaf: _objectSpread$c({}, node)
}];
var _iterator = _createForOfIteratorHelper$j(_decorations),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var dec = _step.value;
var anchor = dec.anchor,
focus = dec.focus,
mergeDecoration = dec.merge,
rest = _objectWithoutProperties(dec, _excluded2$2);
var _Range$edges = Range.edges(dec),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
_start = _Range$edges2[0],
_end = _Range$edges2[1];
var next = [];
var leafEnd = 0;
var decorationStart = _start.offset;
var decorationEnd = _end.offset;
var merge = mergeDecoration !== null && mergeDecoration !== void 0 ? mergeDecoration : Object.assign;
var _iterator3 = _createForOfIteratorHelper$j(leaves),
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var leaf = _step3.value.leaf;
var length = leaf.text.length;
var leafStart = leafEnd;
leafEnd += length;
// If the range encompasses the entire leaf, add the range.
if (decorationStart <= leafStart && leafEnd <= decorationEnd) {
merge(leaf, rest);
next.push({
leaf: leaf
});
continue;
}
// If the range expanded and match the leaf, or starts after, or ends before it, continue.
if (decorationStart !== decorationEnd && (decorationStart === leafEnd || decorationEnd === leafStart) || decorationStart > leafEnd || decorationEnd < leafStart || decorationEnd === leafStart && leafStart !== 0) {
next.push({
leaf: leaf
});
continue;
}
// Otherwise we need to split the leaf, at the start, end, or both,
// and add the range to the middle intersecting section. Do the end
// split first since we don't need to update the offset that way.
var middle = leaf;
var before = void 0;
var after = void 0;
if (decorationEnd < leafEnd) {
var off = decorationEnd - leafStart;
after = {
leaf: _objectSpread$c(_objectSpread$c({}, middle), {}, {
text: middle.text.slice(off)
})
};
middle = _objectSpread$c(_objectSpread$c({}, middle), {}, {
text: middle.text.slice(0, off)
});
}
if (decorationStart > leafStart) {
var _off = decorationStart - leafStart;
before = {
leaf: _objectSpread$c(_objectSpread$c({}, middle), {}, {
text: middle.text.slice(0, _off)
})
};
middle = _objectSpread$c(_objectSpread$c({}, middle), {}, {
text: middle.text.slice(_off)
});
}
merge(middle, rest);
if (before) {
next.push(before);
}
next.push({
leaf: middle
});
if (after) {
next.push(after);
}
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
leaves = next;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (leaves.length > 1) {
var currentOffset = 0;
var _iterator2 = _createForOfIteratorHelper$j(leaves.entries()),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _step2$value = _slicedToArray(_step2.value, 2),
index = _step2$value[0],
item = _step2$value[1];
var start = currentOffset;
var end = start + item.leaf.text.length;
var position = {
start: start,
end: end
};
if (index === 0) position.isFirst = true;
if (index === leaves.length - 1) position.isLast = true;
item.position = position;
currentOffset = end;
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
}
return leaves;
}
};
function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var insertChildren = function insertChildren(xs, index) {
for (var _len = arguments.length, newValues = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
newValues[_key - 2] = arguments[_key];
}
return [].concat(_toConsumableArray(xs.slice(0, index)), newValues, _toConsumableArray(xs.slice(index)));
};
var replaceChildren = function replaceChildren(xs, index, removeCount) {
for (var _len2 = arguments.length, newValues = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
newValues[_key2 - 3] = arguments[_key2];
}
return [].concat(_toConsumableArray(xs.slice(0, index)), newValues, _toConsumableArray(xs.slice(index + removeCount)));
};
var removeChildren = replaceChildren;
/**
* Replace a descendant with a new node, replacing all ancestors
*/
var modifyDescendant = function modifyDescendant(root, path, f) {
if (path.length === 0) {
throw new Error('Cannot modify the editor');
}
var node = Node.get(root, path);
var slicedPath = path.slice();
var modifiedNode = f(node);
while (slicedPath.length > 1) {
var _index = slicedPath.pop();
var ancestorNode = Node.get(root, slicedPath);
modifiedNode = _objectSpread$b(_objectSpread$b({}, ancestorNode), {}, {
children: replaceChildren(ancestorNode.children, _index, 1, modifiedNode)
});
}
var index = slicedPath.pop();
root.children = replaceChildren(root.children, index, 1, modifiedNode);
};
/**
* Replace the children of a node, replacing all ancestors
*/
var modifyChildren = function modifyChildren(root, path, f) {
if (path.length === 0) {
root.children = f(root.children);
} else {
modifyDescendant(root, path, function (node) {
if (Node.isText(node)) {
throw new Error("Cannot get the element at path [".concat(path, "] because it refers to a leaf node: ").concat(Scrubber.stringify(node)));
}
return _objectSpread$b(_objectSpread$b({}, node), {}, {
children: f(node.children)
});
});
}
};
/**
* Replace a leaf, replacing all ancestors
*/
var modifyLeaf = function modifyLeaf(root, path, f) {
return modifyDescendant(root, path, function (node) {
if (!Node.isText(node)) {
throw new Error("Cannot get the leaf node at path [".concat(path, "] because it refers to a non-leaf node: ").concat(Scrubber.stringify(node)));
}
return f(node);
});
};
function _createForOfIteratorHelper$i(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$i(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$i(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$i(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$i(r, a) : void 0; } }
function _arrayLikeToArray$i(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* The set of properties that cannot be set using set_node.
*/
var NON_SETTABLE_NODE_PROPERTIES = ['children', 'text'].concat(_toConsumableArray(Object.getOwnPropertyNames(Object.prototype)));
/**
* The set of properties that cannot be set using set_selection.
*/
var NON_SETTABLE_SELECTION_PROPERTIES = Object.getOwnPropertyNames(Object.prototype);
// eslint-disable-next-line no-redeclare
var GeneralTransforms = {
transform: function transform(editor, op) {
var transformSelection = false;
switch (op.type) {
case 'insert_node':
{
var path = op.path,
node = op.node;
modifyChildren(editor, Path.parent(path), function (children) {
var index = path[path.length - 1];
if (index > children.length) {
throw new Error("Cannot apply an \"insert_node\" operation at path [".concat(path, "] because the destination is past the end of the node."));
}
return insertChildren(children, index, node);
});
transformSelection = true;
break;
}
case 'insert_text':
{
var _path = op.path,
offset = op.offset,
text = op.text;
if (text.length === 0) break;
modifyLeaf(editor, _path, function (node) {
var before = node.text.slice(0, offset);
var after = node.text.slice(offset);
return _objectSpread$a(_objectSpread$a({}, node), {}, {
text: before + text + after
});
});
transformSelection = true;
break;
}
case 'merge_node':
{
var _path2 = op.path;
var index = _path2[_path2.length - 1];
var prevPath = Path.previous(_path2);
var prevIndex = prevPath[prevPath.length - 1];
if (_path2.length === 0) {
throw new Error("Cannot apply a \"merge_node\" operation at path [".concat(_path2, "] because the root node cannot be merged."));
}
// Defend against malicious paths containing strings
if (typeof index !== 'number' || typeof prevIndex !== 'number') throw new Error('Index must be number');
modifyChildren(editor, Path.parent(_path2), function (children) {
var node = children[index];
var prev = children[prevIndex];
var newNode;
if (Node.isText(node) && Node.isText(prev)) {
newNode = _objectSpread$a(_objectSpread$a({}, prev), {}, {
text: prev.text + node.text
});
} else if (Node.isElement(node) && Node.isElement(prev)) {
newNode = _objectSpread$a(_objectSpread$a({}, prev), {}, {
children: prev.children.concat(node.children)
});
} else {
throw new Error("Cannot apply a \"merge_node\" operation at path [".concat(_path2, "] to nodes of different interfaces: ").concat(Scrubber.stringify(node), " ").concat(Scrubber.stringify(prev)));
}
return replaceChildren(children, prevIndex, 2, newNode);
});
transformSelection = true;
break;
}
case 'move_node':
{
var _path3 = op.path,
newPath = op.newPath;
var _index = _path3[_path3.length - 1];
if (Path.isAncestor(_path3, newPath)) {
throw new Error("Cannot move a path [".concat(_path3, "] to new path [").concat(newPath, "] because the destination is inside itself."));
}
var _node = Node.get(editor, _path3);
modifyChildren(editor, Path.parent(_path3), function (children) {
return removeChildren(children, _index, 1);
});
// This is tricky, but since the `path` and `newPath` both refer to
// the same snapshot in time, there's a mismatch. After either
// removing the original position, the second step's path can be out
// of date. So instead of using the `op.newPath` directly, we
// transform `op.path` to ascertain what the `newPath` would be after
// the operation was applied.
var truePath = Path.transform(_path3, op);
var newIndex = truePath[truePath.length - 1];
modifyChildren(editor, Path.parent(truePath), function (children) {
return insertChildren(children, newIndex, _node);
});
transformSelection = true;
break;
}
case 'remove_node':
{
var _path4 = op.path;
var _index2 = _path4[_path4.length - 1];
modifyChildren(editor, Path.parent(_path4), function (children) {
return removeChildren(children, _index2, 1);
});
// Transform all the points in the value, but if the point was in the
// node that was removed we need to update the range or remove it.
if (editor.selection) {
var selection = _objectSpread$a({}, editor.selection);
var _iterator = _createForOfIteratorHelper$i(Range.points(selection)),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _slicedToArray(_step.value, 2),
point = _step$value[0],
key = _step$value[1];
var result = Point.transform(point, op);
if (selection != null && result != null) {
selection[key] = result;
} else {
var prev = void 0;
var next = void 0;
var _iterator2 = _createForOfIteratorHelper$i(Node.texts(editor)),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _step2$value = _slicedToArray(_step2.value, 2),
n = _step2$value[0],
p = _step2$value[1];
if (Path.compare(p, _path4) === -1) {
prev = [n, p];
} else {
next = [n, p];
break;
}
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
var preferNext = false;
if (prev && next) {
if (Path.isSibling(prev[1], _path4)) {
preferNext = false;
} else if (Path.equals(next[1], _path4)) {
preferNext = true;
} else {
preferNext = Path.common(prev[1], _path4).length < Path.common(next[1], _path4).length;
}
}
if (prev && !preferNext) {
selection[key] = {
path: prev[1],
offset: prev[0].text.length
};
} else if (next) {
selection[key] = {
path: next[1],
offset: 0
};
} else {
selection = null;
}
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (!selection || !Range.equals(selection, editor.selection)) {
editor.selection = selection;
}
}
break;
}
case 'remove_text':
{
var _path5 = op.path,
_offset = op.offset,
_text = op.text;
if (_text.length === 0) break;
modifyLeaf(editor, _path5, function (node) {
var before = node.text.slice(0, _offset);
var after = node.text.slice(_offset + _text.length);
return _objectSpread$a(_objectSpread$a({}, node), {}, {
text: before + after
});
});
transformSelection = true;
break;
}
case 'set_node':
{
var _path6 = op.path,
properties = op.properties,
newProperties = op.newProperties;
if (_path6.length === 0) {
throw new Error("Cannot set properties on the root node!");
}
modifyDescendant(editor, _path6, function (node) {
var newNode = _objectSpread$a({}, node);
for (var _key in newProperties) {
if (NON_SETTABLE_NODE_PROPERTIES.includes(_key)) {
throw new Error("Cannot set the \"".concat(_key, "\" property of nodes!"));
}
var value = newProperties[_key];
// Make sure we're not setting `then` to a function, since this will
// cause the node to be treated as a Promise-like object, which can
// cause unexpected behaviour when returning the node from async
// functions.
if (_key === 'then' && typeof value === 'function') {
throw new Error('Cannot set the "then" property of a node to a function');
}
if (value == null) {
delete newNode[_key];
} else {
newNode[_key] = value;
}
}
// properties that were previously defined, but are now missing, must be deleted
for (var _key2 in properties) {
if (!Object.hasOwn(newProperties, _key2)) {
delete newNode[_key2];
}
}
return newNode;
});
break;
}
case 'set_selection':
{
var _newProperties = op.newProperties;
if (_newProperties == null) {
editor.selection = null;
break;
}
if (editor.selection == null) {
if (!(_newProperties.anchor && _newProperties.focus)) {
throw new Error("Cannot apply an incomplete \"set_selection\" operation properties ".concat(Scrubber.stringify(_newProperties), " when there is no current selection."));
}
editor.selection = _objectSpread$a({}, _newProperties);
break;
}
var _selection = _objectSpread$a({}, editor.selection);
for (var _key3 in _newProperties) {
if (NON_SETTABLE_SELECTION_PROPERTIES.includes(_key3)) {
throw new Error("Cannot set the \"".concat(_key3, "\" property of the selection!"));
}
var value = _newProperties[_key3];
// Make sure we're not setting `then` to a function, since this will
// cause the selection to be treated as a Promise-like object, which
// can cause unexpected behaviour when returning the selection from
// async functions.
if (_key3 === 'then' && typeof value === 'function') {
throw new Error('Cannot set the "then" property of the selection to a function');
}
if (value == null) {
if (_key3 === 'anchor' || _key3 === 'focus') {
throw new Error("Cannot remove the \"".concat(_key3, "\" selection property"));
}
delete _selection[_key3];
} else {
_selection[_key3] = value;
}
}
editor.selection = _selection;
break;
}
case 'split_node':
{
var _path7 = op.path,
position = op.position,
_properties = op.properties;
var _index3 = _path7[_path7.length - 1];
if (_path7.length === 0) {
throw new Error("Cannot apply a \"split_node\" operation at path [".concat(_path7, "] because the root node cannot be split."));
}
// Defend against malicious paths containing strings
if (typeof _index3 !== 'number') throw new Error('Index must be number');
modifyChildren(editor, Path.parent(_path7), function (children) {
var node = children[_index3];
var newNode;
var nextNode;
if (Node.isText(node)) {
var before = node.text.slice(0, position);
var after = node.text.slice(position);
newNode = _objectSpread$a(_objectSpread$a({}, node), {}, {
text: before
});
nextNode = {
text: after
};
} else {
var _before = node.children.slice(0, position);
var _after = node.children.slice(position);
newNode = _objectSpread$a(_objectSpread$a({}, node), {}, {
children: _before
});
nextNode = {
children: _after
};
}
for (var _key4 in _properties) {
if (NON_SETTABLE_NODE_PROPERTIES.includes(_key4)) {
throw new Error("Cannot set the \"".concat(_key4, "\" property of nodes!"));
}
var _value = _properties[_key4];
// Make sure we're not setting `then` to a function, since this will
// cause the node to be treated as a Promise-like object, which can
// cause unexpected behaviour when returning the node from async
// functions.
if (_key4 === 'then' && typeof _value === 'function') {
throw new Error('Cannot set the "then" property of a node to a function');
}
if (_value != null) {
nextNode[_key4] = _value;
}
}
return replaceChildren(children, _index3, 1, newNode, nextNode);
});
transformSelection = true;
break;
}
}
if (transformSelection && editor.selection) {
var _selection2 = _objectSpread$a({}, editor.selection);
var _iterator3 = _createForOfIteratorHelper$i(Range.points(_selection2)),
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var _step3$value = _slicedToArray(_step3.value, 2),
_point = _step3$value[0],
_key5 = _step3$value[1];
_selection2[_key5] = Point.transform(_point, op);
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
if (!Range.equals(_selection2, editor.selection)) {
editor.selection = _selection2;
}
}
}
};
// eslint-disable-next-line no-redeclare
var NodeTransforms = {
insertNodes: function insertNodes(editor, nodes, options) {
editor.insertNodes(nodes, options);
},
liftNodes: function liftNodes(editor, options) {
editor.liftNodes(options);
},
mergeNodes: function mergeNodes(editor, options) {
editor.mergeNodes(options);
},
moveNodes: function moveNodes(editor, options) {
editor.moveNodes(options);
},
removeNodes: function removeNodes(editor, options) {
editor.removeNodes(options);
},
setNodes: function setNodes(editor, props, options) {
editor.setNodes(props, options);
},
splitNodes: function splitNodes(editor, options) {
editor.splitNodes(options);
},
unsetNodes: function unsetNodes(editor, props, options) {
editor.unsetNodes(props, options);
},
unwrapNodes: function unwrapNodes(editor, options) {
editor.unwrapNodes(options);
},
wrapNodes: function wrapNodes(editor, element, options) {
editor.wrapNodes(element, options);
}
};
// eslint-disable-next-line no-redeclare
var SelectionTransforms = {
collapse: function collapse(editor, options) {
editor.collapse(options);
},
deselect: function deselect(editor) {
editor.deselect();
},
move: function move(editor, options) {
editor.move(options);
},
select: function select(editor, target) {
editor.select(target);
},
setPoint: function setPoint(editor, props, options) {
editor.setPoint(props, options);
},
setSelection: function setSelection(editor, props) {
editor.setSelection(props);
}
};
// eslint-disable-next-line no-redeclare
var TextTransforms = {
"delete": function _delete(editor, options) {
editor["delete"](options);
},
insertFragment: function insertFragment(editor, fragment, options) {
editor.insertFragment(fragment, options);
},
insertText: function insertText(editor, text) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
Editor.withoutNormalizing(editor, function () {
var _options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var _options$at = options.at,
at = _options$at === void 0 ? getDefaultInsertLocation(editor) : _options$at;
if (Location.isPath(at)) {
at = Editor.range(editor, at);
}
if (Location.isRange(at)) {
if (Range.isCollapsed(at)) {
at = at.anchor;
} else {
var end = Range.end(at);
if (!voids && Editor["void"](editor, {
at: end
})) {
return;
}
var start = Range.start(at);
var startRef = Editor.pointRef(editor, start);
var endRef = Editor.pointRef(editor, end);
Transforms["delete"](editor, {
at: at,
voids: voids
});
var startPoint = startRef.unref();
var endPoint = endRef.unref();
at = startPoint || endPoint;
Transforms.setSelection(editor, {
anchor: at,
focus: at
});
}
}
if (!voids && Editor["void"](editor, {
at: at
}) || Editor.elementReadOnly(editor, {
at: at
})) {
return;
}
var _at = at,
path = _at.path,
offset = _at.offset;
if (text.length > 0) editor.apply({
type: 'insert_text',
path: path,
offset: offset,
text: text
});
});
}
};
function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Transforms = _objectSpread$9(_objectSpread$9(_objectSpread$9(_objectSpread$9({}, GeneralTransforms), NodeTransforms), SelectionTransforms), TextTransforms);
// perf
var BATCHING_DIRTY_PATHS = new WeakMap();
var isBatchingDirtyPaths = function isBatchingDirtyPaths(editor) {
return BATCHING_DIRTY_PATHS.get(editor) || false;
};
var batchDirtyPaths = function batchDirtyPaths(editor, fn, update) {
var value = BATCHING_DIRTY_PATHS.get(editor) || false;
BATCHING_DIRTY_PATHS.set(editor, true);
try {
fn();
update();
} finally {
BATCHING_DIRTY_PATHS.set(editor, value);
}
};
function _createForOfIteratorHelper$h(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$h(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$h(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$h(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$h(r, a) : void 0; } }
function _arrayLikeToArray$h(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
/**
* update editor dirty paths
*
* @param newDirtyPaths: Path[]; new dirty paths
* @param transform: (p: Path) => Path | null; how to transform existing dirty paths
*/
function updateDirtyPaths(editor, newDirtyPaths, transform) {
var oldDirtyPaths = DIRTY_PATHS.get(editor) || [];
var oldDirtyPathKeys = DIRTY_PATH_KEYS.get(editor) || new Set();
var dirtyPaths;
var dirtyPathKeys;
var add = function add(path) {
if (path) {
var key = path.join(',');
if (!dirtyPathKeys.has(key)) {
dirtyPathKeys.add(key);
dirtyPaths.push(path);
}
}
};
if (transform) {
dirtyPaths = [];
dirtyPathKeys = new Set();
var _iterator = _createForOfIteratorHelper$h(oldDirtyPaths),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var path = _step.value;
var newPath = transform(path);
add(newPath);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
} else {
dirtyPaths = oldDirtyPaths;
dirtyPathKeys = oldDirtyPathKeys;
}
var _iterator2 = _createForOfIteratorHelper$h(newDirtyPaths),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _path = _step2.value;
add(_path);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
DIRTY_PATHS.set(editor, dirtyPaths);
DIRTY_PATH_KEYS.set(editor, dirtyPathKeys);
}
function _createForOfIteratorHelper$g(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$g(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$g(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$g(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$g(r, a) : void 0; } }
function _arrayLikeToArray$g(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var apply = function apply(editor, op) {
var _iterator = _createForOfIteratorHelper$g(Editor.pathRefs(editor)),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var ref = _step.value;
PathRef.transform(ref, op);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var _iterator2 = _createForOfIteratorHelper$g(Editor.pointRefs(editor)),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _ref = _step2.value;
PointRef.transform(_ref, op);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
var _iterator3 = _createForOfIteratorHelper$g(Editor.rangeRefs(editor)),
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var _ref2 = _step3.value;
RangeRef.transform(_ref2, op);
}
// update dirty paths
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
if (!isBatchingDirtyPaths(editor)) {
var transform = Path.operationCanTransformPath(op) ? function (p) {
return Path.transform(p, op);
} : undefined;
updateDirtyPaths(editor, editor.getDirtyPaths(op), transform);
}
Transforms.transform(editor, op);
editor.operations.push(op);
Editor.normalize(editor, {
operation: op
});
// Clear any formats applied to the cursor if the selection changes.
if (op.type === 'set_selection') {
editor.marks = null;
}
if (!FLUSHING.get(editor)) {
FLUSHING.set(editor, true);
Promise.resolve().then(function () {
FLUSHING.set(editor, false);
editor.onChange({
operation: op
});
editor.operations = [];
});
}
};
function _createForOfIteratorHelper$f(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$f(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$f(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$f(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$f(r, a) : void 0; } }
function _arrayLikeToArray$f(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
/**
* Get the "dirty" paths generated from an operation.
*/
var getDirtyPaths = function getDirtyPaths(editor, op) {
switch (op.type) {
case 'insert_text':
case 'remove_text':
case 'set_node':
{
var path = op.path;
return Path.levels(path);
}
case 'insert_node':
{
var node = op.node,
_path = op.path;
var levels = Path.levels(_path);
var descendants = Node.isText(node) ? [] : Array.from(Node.nodes(node), function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return _path.concat(p);
});
return [].concat(_toConsumableArray(levels), _toConsumableArray(descendants));
}
case 'merge_node':
{
var _path2 = op.path;
var ancestors = Path.ancestors(_path2);
var previousPath = Path.previous(_path2);
return [].concat(_toConsumableArray(ancestors), [previousPath]);
}
case 'move_node':
{
var _path3 = op.path,
newPath = op.newPath;
if (Path.equals(_path3, newPath)) {
return [];
}
var oldAncestors = [];
var newAncestors = [];
var _iterator = _createForOfIteratorHelper$f(Path.ancestors(_path3)),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var ancestor = _step.value;
var p = Path.transform(ancestor, op);
oldAncestors.push(p);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var _iterator2 = _createForOfIteratorHelper$f(Path.ancestors(newPath)),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _ancestor = _step2.value;
var _p = Path.transform(_ancestor, op);
newAncestors.push(_p);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
var newParent = newAncestors[newAncestors.length - 1];
var newIndex = newPath[newPath.length - 1];
var resultPath = newParent.concat(newIndex);
return [].concat(oldAncestors, newAncestors, [resultPath]);
}
case 'remove_node':
{
var _path4 = op.path;
var _ancestors = Path.ancestors(_path4);
return _toConsumableArray(_ancestors);
}
case 'split_node':
{
var _path5 = op.path;
var _levels = Path.levels(_path5);
var nextPath = Path.next(_path5);
return [].concat(_toConsumableArray(_levels), [nextPath]);
}
default:
{
return [];
}
}
};
var getFragment = function getFragment(editor) {
var selection = editor.selection;
if (selection) {
return Node.fragment(editor, selection);
}
return [];
};
var normalizeNode = function normalizeNode(editor, entry, options) {
var _entry = _slicedToArray(entry, 2),
node = _entry[0],
path = _entry[1]; // node is not yet normalized, treat as hostile
// There are no core normalizations for text nodes.
if (Node.isText(node)) {
return;
}
if (!('children' in node)) {
node.children = [];
}
var element = node; // we will have to refetch the element any time we modify its children since it clones to a new immutable reference when we do
// Ensure that elements have at least one child.
if (element !== editor && element.children.length === 0) {
var child = {
text: ''
};
Transforms.insertNodes(editor, child, {
at: path.concat(0),
voids: true
});
element = Node.get(editor, path);
}
// Determine whether the node should have only block or only inline children.
// - The editor should have only block children.
// - Inline elements should have only inline children.
// - Elements that begin with a text child or an inline element child should have only inline children.
// - All other elements should have only block children.
var shouldHaveInlines = !(element === editor) && (editor.isInline(element) || Node.isText(element.children[0]) || editor.isInline(element.children[0]));
if (shouldHaveInlines) {
// Since we'll be applying operations while iterating, we also modify `n` when adding/removing nodes.
for (var n = 0; n < element.children.length; n++) {
var _child = element.children[n];
var prev = element.children[n - 1];
if (Node.isText(_child)) {
if (prev != null && Node.isText(prev)) {
// Merge adjacent text nodes that are empty or match.
if (_child.text === '') {
Transforms.removeNodes(editor, {
at: path.concat(n),
voids: true
});
element = Node.get(editor, path);
n--;
} else if (prev.text === '') {
Transforms.removeNodes(editor, {
at: path.concat(n - 1),
voids: true
});
element = Node.get(editor, path);
n--;
} else if (Text.equals(_child, prev, {
loose: true
})) {
Transforms.mergeNodes(editor, {
at: path.concat(n),
voids: true
});
element = Node.get(editor, path);
n--;
}
}
} else {
if (editor.isInline(_child)) {
// Ensure that inline nodes are surrounded by text nodes.
if (prev == null || !Node.isText(prev)) {
var newChild = {
text: ''
};
Transforms.insertNodes(editor, newChild, {
at: path.concat(n),
voids: true
});
element = Node.get(editor, path);
n++;
}
if (n === element.children.length - 1) {
var _newChild = {
text: ''
};
Transforms.insertNodes(editor, _newChild, {
at: path.concat(n + 1),
voids: true
});
element = Node.get(editor, path);
n++;
}
} else {
// Allow only inline nodes to be in other inline nodes, or in parent blocks that only
// contain inlines and text.
Transforms.unwrapNodes(editor, {
at: path.concat(n),
voids: true
});
element = Node.get(editor, path);
n--;
}
}
}
} else {
// Since we'll be applying operations while iterating, we also modify `n` when adding/removing nodes
for (var _n = 0; _n < element.children.length; _n++) {
var _child2 = element.children[_n];
// Allow only block nodes in the top-level children and parent blocks that only contain block nodes
if (Node.isText(_child2) || editor.isInline(_child2)) {
if (options !== null && options !== void 0 && options.fallbackElement) {
Transforms.wrapNodes(editor, options.fallbackElement(), {
at: path.concat(_n),
voids: true
});
} else {
Transforms.removeNodes(editor, {
at: path.concat(_n),
voids: true
});
}
element = Node.get(editor, path);
_n--;
}
}
}
};
var shouldNormalize = function shouldNormalize(editor, _ref) {
var iteration = _ref.iteration,
initialDirtyPathsLength = _ref.initialDirtyPathsLength;
var maxIterations = initialDirtyPathsLength * 42; // HACK: better way?
if (iteration > maxIterations) {
throw new Error("Could not completely normalize the editor after ".concat(maxIterations, " iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state."));
}
return true;
};
var above = function above(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids,
_options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
match = options.match;
if (!at) {
return;
}
var path = Editor.path(editor, at);
// If `at` is a Range that spans mulitple nodes, `path` will be their common ancestor.
// Otherwise `path` will be a text node and/or the same as `at`, in which cases we want to start with its parent.
if (!Location.isRange(at) || Path.equals(at.focus.path, at.anchor.path)) {
if (path.length === 0) return;
path = Path.parent(path);
}
var reverse = mode === 'lowest';
var _Editor$levels = Editor.levels(editor, {
at: path,
voids: voids,
match: match,
reverse: reverse
}),
_Editor$levels2 = _slicedToArray(_Editor$levels, 1),
firstMatch = _Editor$levels2[0];
return firstMatch; // if nothing matches this returns undefined
};
function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var addMark = function addMark(editor, key, value) {
var selection = editor.selection;
if (selection) {
var match = function match(node, path) {
if (!Node.isText(node)) {
return false; // marks can only be applied to text
}
var _Editor$parent = Editor.parent(editor, path),
_Editor$parent2 = _slicedToArray(_Editor$parent, 2),
parentNode = _Editor$parent2[0];
_Editor$parent2[1];
return !editor.isVoid(parentNode) || editor.markableVoid(parentNode);
};
var expandedSelection = Range.isExpanded(selection);
var markAcceptingVoidSelected = false;
if (!expandedSelection) {
var _Editor$node = Editor.node(editor, selection),
_Editor$node2 = _slicedToArray(_Editor$node, 2),
selectedNode = _Editor$node2[0],
selectedPath = _Editor$node2[1];
if (selectedNode && match(selectedNode, selectedPath)) {
var _Editor$parent3 = Editor.parent(editor, selectedPath),
_Editor$parent4 = _slicedToArray(_Editor$parent3, 1),
parentNode = _Editor$parent4[0];
markAcceptingVoidSelected = parentNode && editor.markableVoid(parentNode);
}
}
if (expandedSelection || markAcceptingVoidSelected) {
Transforms.setNodes(editor, _defineProperty({}, key, value), {
match: match,
split: true,
voids: true
});
} else {
var marks = _objectSpread$8(_objectSpread$8({}, Editor.marks(editor) || {}), {}, _defineProperty({}, key, value));
editor.marks = marks;
if (!FLUSHING.get(editor)) {
editor.onChange();
}
}
}
};
function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _createForOfIteratorHelper$e(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$e(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$e(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$e(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$e(r, a) : void 0; } }
function _arrayLikeToArray$e(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var after = function after(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var anchor = Editor.point(editor, at, {
edge: 'end'
});
var focus = Editor.end(editor, []);
var range = {
anchor: anchor,
focus: focus
};
var _options$distance = options.distance,
distance = _options$distance === void 0 ? 1 : _options$distance;
var d = 0;
var target;
var _iterator = _createForOfIteratorHelper$e(Editor.positions(editor, _objectSpread$7(_objectSpread$7({}, options), {}, {
at: range
}))),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var p = _step.value;
if (d > distance) {
break;
}
if (d !== 0) {
target = p;
}
d++;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return target;
};
function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _createForOfIteratorHelper$d(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$d(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$d(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$d(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$d(r, a) : void 0; } }
function _arrayLikeToArray$d(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var before = function before(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var anchor = Editor.start(editor, []);
var focus = Editor.point(editor, at, {
edge: 'start'
});
var range = {
anchor: anchor,
focus: focus
};
var _options$distance = options.distance,
distance = _options$distance === void 0 ? 1 : _options$distance;
var d = 0;
var target;
var _iterator = _createForOfIteratorHelper$d(Editor.positions(editor, _objectSpread$6(_objectSpread$6({}, options), {}, {
at: range,
reverse: true
}))),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var p = _step.value;
if (d > distance) {
break;
}
if (d !== 0) {
target = p;
}
d++;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return target;
};
var deleteBackward = function deleteBackward(editor, unit) {
var selection = editor.selection;
if (selection && Range.isCollapsed(selection)) {
Transforms["delete"](editor, {
unit: unit,
reverse: true
});
}
};
var deleteForward = function deleteForward(editor, unit) {
var selection = editor.selection;
if (selection && Range.isCollapsed(selection)) {
Transforms["delete"](editor, {
unit: unit
});
}
};
var deleteFragment = function deleteFragment(editor) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$direction = _ref.direction,
direction = _ref$direction === void 0 ? 'forward' : _ref$direction;
var selection = editor.selection;
if (selection && Range.isExpanded(selection)) {
Transforms["delete"](editor, {
reverse: direction === 'backward'
});
}
};
var edges = function edges(editor, at) {
return [Editor.start(editor, at), Editor.end(editor, at)];
};
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var elementReadOnly = function elementReadOnly(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Editor.above(editor, _objectSpread$5(_objectSpread$5({}, options), {}, {
match: function match(n) {
return Node.isElement(n) && Editor.isElementReadOnly(editor, n);
}
}));
};
var end = function end(editor, at) {
return Editor.point(editor, at, {
edge: 'end'
});
};
var first = function first(editor, at) {
var path = Editor.path(editor, at, {
edge: 'start'
});
return Editor.node(editor, path);
};
var fragment = function fragment(editor, at) {
var range = Editor.range(editor, at);
return Node.fragment(editor, range);
};
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var getVoid = function getVoid(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Editor.above(editor, _objectSpread$4(_objectSpread$4({}, options), {}, {
match: function match(n) {
return Node.isElement(n) && Editor.isVoid(editor, n);
}
}));
};
var hasBlocks = function hasBlocks(editor, element) {
return element.children.some(function (n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
});
};
var hasInlines = function hasInlines(editor, element) {
return element.children.some(function (n) {
return Node.isText(n) || Editor.isInline(editor, n);
});
};
var hasPath = function hasPath(editor, path) {
return Node.has(editor, path);
};
var hasTexts = function hasTexts(editor, element) {
return element.children.every(function (n) {
return Node.isText(n);
});
};
var insertBreak = function insertBreak(editor) {
Transforms.splitNodes(editor, {
always: true
});
};
var insertNode = function insertNode(editor, node, options) {
Transforms.insertNodes(editor, node, options);
};
var insertSoftBreak = function insertSoftBreak(editor) {
Transforms.splitNodes(editor, {
always: true
});
};
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var insertText = function insertText(editor, text) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var selection = editor.selection,
marks = editor.marks;
if (selection) {
if (marks) {
var node = _objectSpread$3({
text: text
}, marks);
Transforms.insertNodes(editor, node, {
at: options.at,
voids: options.voids
});
} else {
Transforms.insertText(editor, text, options);
}
editor.marks = null;
}
};
var isBlock = function isBlock(editor, value) {
return !editor.isInline(value);
};
var isEdge = function isEdge(editor, point, at) {
return Editor.isStart(editor, point, at) || Editor.isEnd(editor, point, at);
};
var isEmpty = function isEmpty(editor, element) {
var children = element.children;
var _children = _slicedToArray(children, 1),
first = _children[0];
return children.length === 0 || children.length === 1 && Node.isText(first) && first.text === '' && !editor.isVoid(element);
};
var isEnd = function isEnd(editor, point, at) {
var end = Editor.end(editor, at);
return Point.equals(point, end);
};
var isNormalizing = function isNormalizing(editor) {
var isNormalizing = NORMALIZING.get(editor);
return isNormalizing === undefined ? true : isNormalizing;
};
var isStart = function isStart(editor, point, at) {
// PERF: If the offset isn't `0` we know it's not the start.
if (point.offset !== 0) {
return false;
}
var start = Editor.start(editor, at);
return Point.equals(point, start);
};
var last = function last(editor, at) {
var path = Editor.path(editor, at, {
edge: 'end'
});
return Editor.node(editor, path);
};
var leaf = function leaf(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var path = Editor.path(editor, at, options);
var node = Node.leaf(editor, path);
return [node, path];
};
function _createForOfIteratorHelper$c(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$c(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$c(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$c(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$c(r, a) : void 0; } }
function _arrayLikeToArray$c(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function levels(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return /*#__PURE__*/regenerator.mark(function _callee() {
var _options$at, at, _options$reverse, reverse, _options$voids, voids, match, levels, path, _iterator, _step, _step$value, n, p, _t;
return regenerator.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_options$at = options.at, at = _options$at === void 0 ? editor.selection : _options$at, _options$reverse = options.reverse, reverse = _options$reverse === void 0 ? false : _options$reverse, _options$voids = options.voids, voids = _options$voids === void 0 ? false : _options$voids;
match = options.match;
if (match == null) {
match = function match() {
return true;
};
}
if (at) {
_context.next = 1;
break;
}
return _context.abrupt("return");
case 1:
levels = [];
path = Editor.path(editor, at);
_iterator = _createForOfIteratorHelper$c(Node.levels(editor, path));
_context.prev = 2;
_iterator.s();
case 3:
if ((_step = _iterator.n()).done) {
_context.next = 6;
break;
}
_step$value = _slicedToArray(_step.value, 2), n = _step$value[0], p = _step$value[1];
if (match(n, p)) {
_context.next = 4;
break;
}
return _context.abrupt("continue", 5);
case 4:
levels.push([n, p]);
if (!(!voids && Node.isElement(n) && Editor.isVoid(editor, n))) {
_context.next = 5;
break;
}
return _context.abrupt("continue", 6);
case 5:
_context.next = 3;
break;
case 6:
_context.next = 8;
break;
case 7:
_context.prev = 7;
_t = _context["catch"](2);
_iterator.e(_t);
case 8:
_context.prev = 8;
_iterator.f();
return _context.finish(8);
case 9:
if (reverse) {
levels.reverse();
}
return _context.delegateYield(levels, "t0", 10);
case 10:
case "end":
return _context.stop();
}
}, _callee, null, [[2, 7, 8, 9]]);
})();
}
var _excluded$1 = ["text"],
_excluded2$1 = ["text"];
var marks = function marks(editor) {
var marks = editor.marks,
selection = editor.selection;
if (!selection) {
return null;
}
var anchor = selection.anchor,
focus = selection.focus;
if (marks) {
return marks;
}
if (Range.isExpanded(selection)) {
var isBackward = Range.isBackward(selection);
if (isBackward) {
var _ref = [anchor, focus];
focus = _ref[0];
anchor = _ref[1];
}
/**
* COMPAT: Make sure hanging ranges (caused by double clicking in Firefox)
* do not adversely affect the returned marks.
*/
var isEnd = Editor.isEnd(editor, anchor, anchor.path);
if (isEnd) {
var after = Editor.after(editor, anchor);
if (after) {
anchor = after;
}
}
var _Editor$nodes = Editor.nodes(editor, {
match: Node.isText,
at: {
anchor: anchor,
focus: focus
}
}),
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
match = _Editor$nodes2[0];
if (match) {
var _match = _slicedToArray(match, 1),
_node = _match[0];
_node.text;
var _rest = _objectWithoutProperties(_node, _excluded$1);
return _rest;
} else {
return {};
}
}
var _anchor = anchor,
path = _anchor.path;
var _Editor$leaf = Editor.leaf(editor, path),
_Editor$leaf2 = _slicedToArray(_Editor$leaf, 1),
node = _Editor$leaf2[0];
if (anchor.offset === 0) {
var prev = Editor.previous(editor, {
at: path,
match: Node.isText
});
var markedVoid = Editor.above(editor, {
match: function match(n) {
return Node.isElement(n) && Editor.isVoid(editor, n) && editor.markableVoid(n);
}
});
if (!markedVoid) {
var block = Editor.above(editor, {
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
}
});
if (prev && block) {
var _prev = _slicedToArray(prev, 2),
prevNode = _prev[0],
prevPath = _prev[1];
var _block = _slicedToArray(block, 2),
blockPath = _block[1];
if (Path.isAncestor(blockPath, prevPath)) {
node = prevNode;
}
}
}
}
var _node2 = node;
_node2.text;
var rest = _objectWithoutProperties(_node2, _excluded2$1);
return rest;
};
var next = function next(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var match = options.match,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at;
if (!at) {
return;
}
var pointAfterLocation = Editor.after(editor, at, {
voids: voids
});
if (!pointAfterLocation) return;
var _Editor$last = Editor.last(editor, []),
_Editor$last2 = _slicedToArray(_Editor$last, 2),
to = _Editor$last2[1];
var span = [pointAfterLocation.path, to];
if (Location.isPath(at) && at.length === 0) {
throw new Error("Cannot get the next node from the root node!");
}
if (match == null) {
if (Location.isPath(at)) {
var _Editor$parent = Editor.parent(editor, at),
_Editor$parent2 = _slicedToArray(_Editor$parent, 1),
parent = _Editor$parent2[0];
match = function match(n) {
return parent.children.includes(n);
};
} else {
match = function match() {
return true;
};
}
}
var _Editor$nodes = Editor.nodes(editor, {
at: span,
match: match,
mode: mode,
voids: voids
}),
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
next = _Editor$nodes2[0];
return next;
};
var node = function node(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var path = Editor.path(editor, at, options);
var node = Node.get(editor, path);
return [node, path];
};
function _createForOfIteratorHelper$b(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$b(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$b(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$b(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$b(r, a) : void 0; } }
function _arrayLikeToArray$b(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function nodes(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return /*#__PURE__*/regenerator.mark(function _callee() {
var _options$at, at, _options$mode, mode, _options$universal, universal, _options$reverse, reverse, _options$voids, voids, _pass, match, from, to, first, last, nodeEntries, matches, hit, _iterator, _step, _step$value, node, path, isLower, emit, _t;
return regenerator.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_options$at = options.at, at = _options$at === void 0 ? editor.selection : _options$at, _options$mode = options.mode, mode = _options$mode === void 0 ? 'all' : _options$mode, _options$universal = options.universal, universal = _options$universal === void 0 ? false : _options$universal, _options$reverse = options.reverse, reverse = _options$reverse === void 0 ? false : _options$reverse, _options$voids = options.voids, voids = _options$voids === void 0 ? false : _options$voids, _pass = options.pass;
match = options.match;
if (!match) {
match = function match() {
return true;
};
}
if (at) {
_context.next = 1;
break;
}
return _context.abrupt("return");
case 1:
if (Location.isSpan(at)) {
from = at[0];
to = at[1];
} else {
first = Editor.path(editor, at, {
edge: 'start'
});
last = Editor.path(editor, at, {
edge: 'end'
});
from = reverse ? last : first;
to = reverse ? first : last;
}
nodeEntries = Node.nodes(editor, {
reverse: reverse,
from: from,
to: to,
pass: function pass(_ref) {
var _ref2 = _slicedToArray(_ref, 2),
node = _ref2[0],
path = _ref2[1];
if (_pass && _pass([node, path])) return true;
if (!Node.isElement(node)) return false;
if (!voids && (Editor.isVoid(editor, node) || Editor.isElementReadOnly(editor, node))) return true;
return false;
}
});
matches = [];
_iterator = _createForOfIteratorHelper$b(nodeEntries);
_context.prev = 2;
_iterator.s();
case 3:
if ((_step = _iterator.n()).done) {
_context.next = 11;
break;
}
_step$value = _slicedToArray(_step.value, 2), node = _step$value[0], path = _step$value[1];
isLower = hit && Path.compare(path, hit[1]) === 0; // In highest mode any node lower than the last hit is not a match.
if (!(mode === 'highest' && isLower)) {
_context.next = 4;
break;
}
return _context.abrupt("continue", 10);
case 4:
if (match(node, path)) {
_context.next = 6;
break;
}
if (!(universal && !isLower && Node.isText(node))) {
_context.next = 5;
break;
}
return _context.abrupt("return");
case 5:
return _context.abrupt("continue", 10);
case 6:
if (!(mode === 'lowest' && isLower)) {
_context.next = 7;
break;
}
hit = [node, path];
return _context.abrupt("continue", 10);
case 7:
// In lowest mode we emit the last hit, once it's guaranteed lowest.
emit = mode === 'lowest' ? hit : [node, path];
if (!emit) {
_context.next = 9;
break;
}
if (!universal) {
_context.next = 8;
break;
}
matches.push(emit);
_context.next = 9;
break;
case 8:
_context.next = 9;
return emit;
case 9:
hit = [node, path];
case 10:
_context.next = 3;
break;
case 11:
_context.next = 13;
break;
case 12:
_context.prev = 12;
_t = _context["catch"](2);
_iterator.e(_t);
case 13:
_context.prev = 13;
_iterator.f();
return _context.finish(13);
case 14:
if (!(mode === 'lowest' && hit)) {
_context.next = 16;
break;
}
if (!universal) {
_context.next = 15;
break;
}
matches.push(hit);
_context.next = 16;
break;
case 15:
_context.next = 16;
return hit;
case 16:
if (!universal) {
_context.next = 17;
break;
}
return _context.delegateYield(matches, "t0", 17);
case 17:
case "end":
return _context.stop();
}
}, _callee, null, [[2, 12, 13, 14]]);
})();
}
function _createForOfIteratorHelper$a(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$a(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$a(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$a(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$a(r, a) : void 0; } }
function _arrayLikeToArray$a(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var normalize = function normalize(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$force = options.force,
force = _options$force === void 0 ? false : _options$force,
operation = options.operation;
var getDirtyPaths = function getDirtyPaths(editor) {
return DIRTY_PATHS.get(editor) || [];
};
var getDirtyPathKeys = function getDirtyPathKeys(editor) {
return DIRTY_PATH_KEYS.get(editor) || new Set();
};
var popDirtyPath = function popDirtyPath(editor) {
var path = getDirtyPaths(editor).pop();
var key = path.join(',');
getDirtyPathKeys(editor)["delete"](key);
return path;
};
if (!Editor.isNormalizing(editor)) {
return;
}
if (force) {
var allPaths = Array.from(Node.nodes(editor), function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return p;
});
var allPathKeys = new Set(allPaths.map(function (p) {
return p.join(',');
}));
DIRTY_PATHS.set(editor, allPaths);
DIRTY_PATH_KEYS.set(editor, allPathKeys);
}
if (getDirtyPaths(editor).length === 0) {
return;
}
Editor.withoutNormalizing(editor, function () {
/*
Fix dirty elements with no children.
editor.normalizeNode() does fix this, but some normalization fixes also require it to work.
Running an initial pass avoids the catch-22 race condition.
*/
var _iterator = _createForOfIteratorHelper$a(getDirtyPaths(editor)),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _dirtyPath = _step.value;
if (Node.has(editor, _dirtyPath)) {
var _entry = Editor.node(editor, _dirtyPath);
var _entry2 = _slicedToArray(_entry, 2),
node = _entry2[0],
_ = _entry2[1];
/*
The default normalizer inserts an empty text node in this scenario, but it can be customised.
So there is some risk here.
As long as the normalizer only inserts child nodes for this case it is safe to do in any order;
by definition adding children to an empty node can't cause other paths to change.
*/
if (Node.isElement(node) && node.children.length === 0) {
editor.normalizeNode(_entry, {
operation: operation,
force: force
});
}
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var dirtyPaths = getDirtyPaths(editor);
var initialDirtyPathsLength = dirtyPaths.length;
var iteration = 0;
while (dirtyPaths.length !== 0) {
if (!editor.shouldNormalize({
dirtyPaths: dirtyPaths,
iteration: iteration,
initialDirtyPathsLength: initialDirtyPathsLength,
operation: operation
})) {
return;
}
var dirtyPath = popDirtyPath(editor);
// If the node doesn't exist in the tree, it does not need to be normalized.
if (Node.has(editor, dirtyPath)) {
var entry = Editor.node(editor, dirtyPath);
editor.normalizeNode(entry, {
operation: operation,
force: force
});
}
iteration++;
dirtyPaths = getDirtyPaths(editor);
}
});
};
var parent = function parent(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var path = Editor.path(editor, at, options);
var parentPath = Path.parent(path);
var entry = Editor.node(editor, parentPath);
return entry;
};
var pathRef = function pathRef(editor, path) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _options$affinity = options.affinity,
affinity = _options$affinity === void 0 ? 'forward' : _options$affinity;
var ref = {
current: path,
affinity: affinity,
unref: function unref() {
var current = ref.current;
var pathRefs = Editor.pathRefs(editor);
pathRefs["delete"](ref);
ref.current = null;
return current;
}
};
var refs = Editor.pathRefs(editor);
refs.add(ref);
return ref;
};
var pathRefs = function pathRefs(editor) {
var refs = PATH_REFS.get(editor);
if (!refs) {
refs = new Set();
PATH_REFS.set(editor, refs);
}
return refs;
};
var path = function path(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var depth = options.depth,
edge = options.edge;
if (Location.isPath(at)) {
if (edge === 'start') {
var _Node$first = Node.first(editor, at),
_Node$first2 = _slicedToArray(_Node$first, 2),
firstPath = _Node$first2[1];
at = firstPath;
} else if (edge === 'end') {
var _Node$last = Node.last(editor, at),
_Node$last2 = _slicedToArray(_Node$last, 2),
lastPath = _Node$last2[1];
at = lastPath;
}
}
if (Location.isRange(at)) {
if (edge === 'start') {
at = Range.start(at);
} else if (edge === 'end') {
at = Range.end(at);
} else {
at = Path.common(at.anchor.path, at.focus.path);
}
}
if (Location.isPoint(at)) {
at = at.path;
}
if (depth != null) {
at = at.slice(0, depth);
}
return at;
};
var pointRef = function pointRef(editor, point) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _options$affinity = options.affinity,
affinity = _options$affinity === void 0 ? 'forward' : _options$affinity;
var ref = {
current: point,
affinity: affinity,
unref: function unref() {
var current = ref.current;
var pointRefs = Editor.pointRefs(editor);
pointRefs["delete"](ref);
ref.current = null;
return current;
}
};
var refs = Editor.pointRefs(editor);
refs.add(ref);
return ref;
};
var pointRefs = function pointRefs(editor) {
var refs = POINT_REFS.get(editor);
if (!refs) {
refs = new Set();
POINT_REFS.set(editor, refs);
}
return refs;
};
var point = function point(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _options$edge = options.edge,
edge = _options$edge === void 0 ? 'start' : _options$edge;
if (Location.isPath(at)) {
var path;
if (edge === 'end') {
var _Node$last = Node.last(editor, at),
_Node$last2 = _slicedToArray(_Node$last, 2),
lastPath = _Node$last2[1];
path = lastPath;
} else {
var _Node$first = Node.first(editor, at),
_Node$first2 = _slicedToArray(_Node$first, 2),
firstPath = _Node$first2[1];
path = firstPath;
}
var node = Node.get(editor, path);
if (!Node.isText(node)) {
throw new Error("Cannot get the ".concat(edge, " point in the node at path [").concat(at, "] because it has no ").concat(edge, " text node."));
}
return {
path: path,
offset: edge === 'end' ? node.text.length : 0
};
}
if (Location.isRange(at)) {
var _Range$edges = Range.edges(at),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
start = _Range$edges2[0],
end = _Range$edges2[1];
return edge === 'start' ? start : end;
}
return at;
};
function _createForOfIteratorHelper$9(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$9(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$9(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$9(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$9(r, a) : void 0; } }
function _arrayLikeToArray$9(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function positions(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return /*#__PURE__*/regenerator.mark(function _callee() {
var _options$at, at, _options$unit, unit, _options$reverse, reverse, _options$voids, voids, range, _Range$edges, _Range$edges2, start, end, first, isNewBlock, blockText, distance, leafTextRemaining, leafTextOffset, skippedPaths, _iterator, _step, _loop, _ret, calcDistance, _t;
return regenerator.wrap(function (_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
calcDistance = function _calcDistance(text, unit, reverse) {
if (unit === 'character') {
return getCharacterDistance(text, reverse);
} else if (unit === 'word') {
return getWordDistance(text, reverse);
} else if (unit === 'line' || unit === 'block') {
return text.length;
}
return 1;
};
_options$at = options.at, at = _options$at === void 0 ? editor.selection : _options$at, _options$unit = options.unit, unit = _options$unit === void 0 ? 'offset' : _options$unit, _options$reverse = options.reverse, reverse = _options$reverse === void 0 ? false : _options$reverse, _options$voids = options.voids, voids = _options$voids === void 0 ? false : _options$voids;
if (at) {
_context3.next = 1;
break;
}
return _context3.abrupt("return");
case 1:
/**
* Algorithm notes:
*
* Each step `distance` is dynamic depending on the underlying text
* and the `unit` specified. Each step, e.g., a line or word, may
* span multiple text nodes, so we iterate through the text both on
* two levels in step-sync:
*
* `leafText` stores the text on a text leaf level, and is advanced
* through using the counters `leafTextOffset` and `leafTextRemaining`.
*
* `blockText` stores the text on a block level, and is shortened
* by `distance` every time it is advanced.
*
* We only maintain a window of one blockText and one leafText because
* a block node always appears before all of its leaf nodes.
*/
range = Editor.range(editor, at);
_Range$edges = Range.edges(range), _Range$edges2 = _slicedToArray(_Range$edges, 2), start = _Range$edges2[0], end = _Range$edges2[1];
first = reverse ? end : start;
isNewBlock = false;
blockText = '';
distance = 0; // Distance for leafText to catch up to blockText.
leafTextRemaining = 0;
leafTextOffset = 0;
skippedPaths = []; // Iterate through all nodes in range, grabbing entire textual content
// of block nodes in blockText, and text nodes in leafText.
// Exploits the fact that nodes are sequenced in such a way that we first
// encounter the block node, then all of its text nodes, so when iterating
// through the blockText and leafText we just need to remember a window of
// one block node and leaf node, respectively.
_iterator = _createForOfIteratorHelper$9(Editor.nodes(editor, {
at: at,
reverse: reverse,
voids: voids
}));
_context3.prev = 2;
_loop = /*#__PURE__*/regenerator.mark(function _loop() {
var _marked, _step$value, node, path, hasSkippedAncestor, maybeYield, nextPath, e, s, isFirst;
return regenerator.wrap(function (_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
maybeYield = function _maybeYield(point) {
return regenerator.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (hasSkippedAncestor) {
_context.next = 1;
break;
}
_context.next = 1;
return point;
case 1:
case "end":
return _context.stop();
}
}, _marked);
};
_marked = /*#__PURE__*/regenerator.mark(maybeYield);
_step$value = _slicedToArray(_step.value, 2), node = _step$value[0], path = _step$value[1];
// If the node is inside a skipped ancestor, do not return any points, but
// still process its content so that the iteration state remains correct.
hasSkippedAncestor = skippedPaths.some(function (p) {
return Path.isAncestor(p, path);
});
if (!Node.isElement(node)) {
_context2.next = 8;
break;
}
if (editor.isSelectable(node)) {
_context2.next = 4;
break;
}
/**
* If the node is not selectable, skip it and its descendants
*/
skippedPaths.push(path);
if (!reverse) {
_context2.next = 2;
break;
}
if (!Path.hasPrevious(path)) {
_context2.next = 1;
break;
}
return _context2.delegateYield(maybeYield(Editor.end(editor, Path.previous(path))), "t0", 1);
case 1:
return _context2.abrupt("return", 0);
case 2:
nextPath = Path.next(path);
if (!Editor.hasPath(editor, nextPath)) {
_context2.next = 3;
break;
}
return _context2.delegateYield(maybeYield(Editor.start(editor, nextPath)), "t1", 3);
case 3:
return _context2.abrupt("return", 0);
case 4:
if (!(!voids && (editor.isVoid(node) || editor.isElementReadOnly(node)))) {
_context2.next = 6;
break;
}
return _context2.delegateYield(maybeYield(Editor.start(editor, path)), "t2", 5);
case 5:
return _context2.abrupt("return", 0);
case 6:
if (!editor.isInline(node)) {
_context2.next = 7;
break;
}
return _context2.abrupt("return", 0);
case 7:
// Block element node - set `blockText` to its text content.
if (Editor.hasInlines(editor, node)) {
// We always exhaust block nodes before encountering a new one:
// console.assert(blockText === '',
// `blockText='${blockText}' - `+
// `not exhausted before new block node`, path)
// Ensure range considered is capped to `range`, in the
// start/end edge cases where block extends beyond range.
// Equivalent to this, but presumably more performant:
// blockRange = Editor.range(editor, ...Editor.edges(editor, path))
// blockRange = Range.intersection(range, blockRange) // intersect
// blockText = Editor.string(editor, blockRange, { voids })
e = Path.isAncestor(path, end.path) ? end : Editor.end(editor, path);
s = Path.isAncestor(path, start.path) ? start : Editor.start(editor, path);
blockText = Editor.string(editor, {
anchor: s,
focus: e
}, {
voids: voids
});
isNewBlock = true;
}
case 8:
if (!Node.isText(node)) {
_context2.next = 15;
break;
}
isFirst = Path.equals(path, first.path); // Proof that we always exhaust text nodes before encountering a new one:
// console.assert(leafTextRemaining <= 0,
// `leafTextRemaining=${leafTextRemaining} - `+
// `not exhausted before new leaf text node`, path)
// Reset `leafText` counters for new text node.
if (isFirst) {
leafTextRemaining = reverse ? first.offset : node.text.length - first.offset;
leafTextOffset = first.offset; // Works for reverse too.
} else {
leafTextRemaining = node.text.length;
leafTextOffset = reverse ? leafTextRemaining : 0;
}
// Yield position at the start of node (potentially).
if (!(isFirst || isNewBlock || unit === 'offset')) {
_context2.next = 10;
break;
}
return _context2.delegateYield(maybeYield({
path: path,
offset: leafTextOffset
}), "t3", 9);
case 9:
isNewBlock = false;
case 10:
if (!(distance === 0)) {
_context2.next = 12;
break;
}
if (!(blockText === '')) {
_context2.next = 11;
break;
}
return _context2.abrupt("continue", 15);
case 11:
distance = calcDistance(blockText, unit, reverse);
// Split the string at the previously found distance and use the
// remaining string for the next iteration.
blockText = splitByCharacterDistance(blockText, distance, reverse)[1];
case 12:
// Advance `leafText` by the current `distance`.
leafTextOffset = reverse ? leafTextOffset - distance : leafTextOffset + distance;
leafTextRemaining = leafTextRemaining - distance;
// If `leafText` is exhausted, break to get a new leaf node
// and set distance to the overflow amount, so we'll (maybe)
// catch up to blockText in the next leaf text node.
if (!(leafTextRemaining < 0)) {
_context2.next = 13;
break;
}
distance = -leafTextRemaining;
return _context2.abrupt("continue", 15);
case 13:
// Successfully walked `distance` offsets through `leafText`
// to catch up with `blockText`, so we can reset `distance`
// and yield this position in this node.
distance = 0;
return _context2.delegateYield(maybeYield({
path: path,
offset: leafTextOffset
}), "t4", 14);
case 14:
_context2.next = 10;
break;
case 15:
case "end":
return _context2.stop();
}
}, _loop);
});
_iterator.s();
case 3:
if ((_step = _iterator.n()).done) {
_context3.next = 6;
break;
}
return _context3.delegateYield(_loop(), "t0", 4);
case 4:
_ret = _context3.t0;
if (!(_ret === 0)) {
_context3.next = 5;
break;
}
return _context3.abrupt("continue", 5);
case 5:
_context3.next = 3;
break;
case 6:
_context3.next = 8;
break;
case 7:
_context3.prev = 7;
_t = _context3["catch"](2);
_iterator.e(_t);
case 8:
_context3.prev = 8;
_iterator.f();
return _context3.finish(8);
case 9:
case "end":
return _context3.stop();
}
}, _callee, null, [[2, 7, 8, 9]]);
})();
}
var previous = function previous(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var match = options.match,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at;
if (!at) {
return;
}
var pointBeforeLocation = Editor.before(editor, at, {
voids: voids
});
if (!pointBeforeLocation) {
return;
}
var _Editor$first = Editor.first(editor, []),
_Editor$first2 = _slicedToArray(_Editor$first, 2),
to = _Editor$first2[1];
// The search location is from the start of the document to the path of
// the point before the location passed in
var span = [pointBeforeLocation.path, to];
if (Location.isPath(at) && at.length === 0) {
throw new Error("Cannot get the previous node from the root node!");
}
if (match == null) {
if (Location.isPath(at)) {
var _Editor$parent = Editor.parent(editor, at),
_Editor$parent2 = _slicedToArray(_Editor$parent, 1),
parent = _Editor$parent2[0];
match = function match(n) {
return parent.children.includes(n);
};
} else {
match = function match() {
return true;
};
}
}
var _Editor$nodes = Editor.nodes(editor, {
reverse: true,
at: span,
match: match,
mode: mode,
voids: voids
}),
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
previous = _Editor$nodes2[0];
return previous;
};
var rangeRef = function rangeRef(editor, range) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _options$affinity = options.affinity,
affinity = _options$affinity === void 0 ? 'forward' : _options$affinity;
var ref = {
current: range,
affinity: affinity,
unref: function unref() {
var current = ref.current;
var rangeRefs = Editor.rangeRefs(editor);
rangeRefs["delete"](ref);
ref.current = null;
return current;
}
};
var refs = Editor.rangeRefs(editor);
refs.add(ref);
return ref;
};
var rangeRefs = function rangeRefs(editor) {
var refs = RANGE_REFS.get(editor);
if (!refs) {
refs = new Set();
RANGE_REFS.set(editor, refs);
}
return refs;
};
var range = function range(editor, at, to) {
if (Location.isRange(at) && !to) {
return at;
}
var start = Editor.start(editor, at);
var end = Editor.end(editor, to || at);
return {
anchor: start,
focus: end
};
};
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var removeMark = function removeMark(editor, key) {
var selection = editor.selection;
if (selection) {
var match = function match(node, path) {
if (!Node.isText(node)) {
return false; // marks can only be applied to text
}
var _Editor$parent = Editor.parent(editor, path),
_Editor$parent2 = _slicedToArray(_Editor$parent, 2),
parentNode = _Editor$parent2[0];
_Editor$parent2[1];
return !editor.isVoid(parentNode) || editor.markableVoid(parentNode);
};
var expandedSelection = Range.isExpanded(selection);
var markAcceptingVoidSelected = false;
if (!expandedSelection) {
var _Editor$node = Editor.node(editor, selection),
_Editor$node2 = _slicedToArray(_Editor$node, 2),
selectedNode = _Editor$node2[0],
selectedPath = _Editor$node2[1];
if (selectedNode && match(selectedNode, selectedPath)) {
var _Editor$parent3 = Editor.parent(editor, selectedPath),
_Editor$parent4 = _slicedToArray(_Editor$parent3, 1),
parentNode = _Editor$parent4[0];
markAcceptingVoidSelected = parentNode && editor.markableVoid(parentNode);
}
}
if (expandedSelection || markAcceptingVoidSelected) {
Transforms.unsetNodes(editor, key, {
match: match,
split: true,
voids: true
});
} else {
var marks = _objectSpread$2({}, Editor.marks(editor) || {});
delete marks[key];
editor.marks = marks;
if (!FLUSHING.get(editor)) {
editor.onChange();
}
}
}
};
var setNormalizing = function setNormalizing(editor, isNormalizing) {
NORMALIZING.set(editor, isNormalizing);
};
var start = function start(editor, at) {
return Editor.point(editor, at, {
edge: 'start'
});
};
function _createForOfIteratorHelper$8(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$8(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$8(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$8(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$8(r, a) : void 0; } }
function _arrayLikeToArray$8(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var string = function string(editor, at) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var range = Editor.range(editor, at);
var _Range$edges = Range.edges(range),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
start = _Range$edges2[0],
end = _Range$edges2[1];
var text = '';
var _iterator = _createForOfIteratorHelper$8(Editor.nodes(editor, {
at: range,
match: Node.isText,
voids: voids
})),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _slicedToArray(_step.value, 2),
node = _step$value[0],
path = _step$value[1];
var t = node.text;
if (Path.equals(path, end.path)) {
t = t.slice(0, end.offset);
}
if (Path.equals(path, start.path)) {
t = t.slice(start.offset);
}
text += t;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return text;
};
function _createForOfIteratorHelper$7(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$7(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$7(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$7(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$7(r, a) : void 0; } }
function _arrayLikeToArray$7(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var unhangRange = function unhangRange(editor, range) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var _Range$edges = Range.edges(range),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
start = _Range$edges2[0],
end = _Range$edges2[1];
// PERF: exit early if we can guarantee that the range isn't hanging.
if (start.offset !== 0 || end.offset !== 0 || Range.isCollapsed(range) || Path.hasPrevious(end.path)) {
return range;
}
var endBlock = Editor.above(editor, {
at: end,
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
},
voids: voids
});
var blockPath = endBlock ? endBlock[1] : [];
var first = Editor.start(editor, start);
var before = {
anchor: first,
focus: end
};
var skip = true;
var _iterator = _createForOfIteratorHelper$7(Editor.nodes(editor, {
at: before,
match: Node.isText,
reverse: true,
voids: voids
})),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _slicedToArray(_step.value, 2),
node = _step$value[0],
path = _step$value[1];
if (skip) {
skip = false;
continue;
}
if (node.text !== '' || Path.isBefore(path, blockPath)) {
end = {
path: path,
offset: node.text.length
};
break;
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return {
anchor: start,
focus: end
};
};
var withoutNormalizing = function withoutNormalizing(editor, fn) {
var value = Editor.isNormalizing(editor);
Editor.setNormalizing(editor, false);
try {
fn();
} finally {
Editor.setNormalizing(editor, value);
}
Editor.normalize(editor);
};
var shouldMergeNodesRemovePrevNode = function shouldMergeNodesRemovePrevNode(editor, _ref, _ref2) {
var _ref3 = _slicedToArray(_ref, 2),
prevNode = _ref3[0],
prevPath = _ref3[1];
var _ref4 = _slicedToArray(_ref2, 2);
_ref4[0];
var curNodePath = _ref4[1];
// If the target node that we're merging with is empty, remove it instead
// of merging the two. This is a common rich text editor behavior to
// prevent losing formatting when deleting entire nodes when you have a
// hanging selection.
// if prevNode is first child in parent,don't remove it.
return Node.isElement(prevNode) && Editor.isEmpty(editor, prevNode) && Path.isSibling(prevPath, curNodePath) || Node.isText(prevNode) && prevNode.text === '' && prevPath[prevPath.length - 1] !== 0;
};
function _createForOfIteratorHelper$6(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$6(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$6(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$6(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$6(r, a) : void 0; } }
function _arrayLikeToArray$6(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var findEmptyBlockNextToVoid = function findEmptyBlockNextToVoid(editor, point, reverse) {
var blockEntry = Editor.above(editor, {
at: point,
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
}
});
if (!blockEntry) {
return undefined;
}
var _blockEntry = _slicedToArray(blockEntry, 2),
block = _blockEntry[0],
blockPath = _blockEntry[1];
if (!Node.isElement(block) || Editor.isVoid(editor, block) || !Editor.isEmpty(editor, block)) {
return undefined;
}
if (reverse && !Path.hasPrevious(blockPath)) {
return undefined;
}
var siblingPath = reverse ? Path.previous(blockPath) : Path.next(blockPath);
if (!Node.has(editor, siblingPath)) {
return undefined;
}
var sibling = Node.get(editor, siblingPath);
if (!Node.isElement(sibling) || !Editor.isBlock(editor, sibling) || !Editor.isVoid(editor, sibling)) {
return undefined;
}
return [blockPath, siblingPath];
};
var isEmptyInline = function isEmptyInline(editor, node) {
return Node.isElement(node) && Editor.isInline(editor, node) && !Editor.isVoid(editor, node) && Editor.isEmpty(editor, node);
};
var findEmptyInlineToDelete = function findEmptyInlineToDelete(editor, point, reverse) {
var inlinePath = Path.parent(point.path);
if (inlinePath.length > 0 && isEmptyInline(editor, Node.get(editor, inlinePath))) {
return inlinePath;
}
var text = Node.get(editor, point.path);
var atEdge = reverse ? point.offset === 0 : Node.isText(text) && point.offset === text.text.length;
if (!atEdge) {
return undefined;
}
if (reverse && !Path.hasPrevious(point.path)) {
return undefined;
}
var siblingPath = reverse ? Path.previous(point.path) : Path.next(point.path);
if (Node.has(editor, siblingPath) && isEmptyInline(editor, Node.get(editor, siblingPath))) {
return siblingPath;
}
return undefined;
};
var deleteText = function deleteText(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Editor.withoutNormalizing(editor, function () {
var _Editor$void, _Editor$void2;
var _options$reverse = options.reverse,
reverse = _options$reverse === void 0 ? false : _options$reverse,
_options$unit = options.unit,
unit = _options$unit === void 0 ? 'character' : _options$unit,
_options$distance = options.distance,
distance = _options$distance === void 0 ? 1 : _options$distance,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var _options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
_options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging;
if (!at) {
return;
}
var isCollapsed = false;
if (Location.isRange(at) && Range.isCollapsed(at)) {
isCollapsed = true;
at = at.anchor;
}
if (Location.isPoint(at)) {
var emptyBlockNextToVoid = !voids && (unit === 'character' || unit === 'word') && distance === 1 ? findEmptyBlockNextToVoid(editor, at, reverse) : undefined;
if (emptyBlockNextToVoid) {
var _emptyBlockNextToVoid = _slicedToArray(emptyBlockNextToVoid, 2),
blockPath = _emptyBlockNextToVoid[0],
voidPath = _emptyBlockNextToVoid[1];
var voidRef = Editor.pathRef(editor, voidPath);
Transforms.removeNodes(editor, {
at: blockPath
});
var target = voidRef.unref();
if (target && options.at == null) {
Transforms.select(editor, reverse ? Editor.end(editor, target) : Editor.start(editor, target));
}
return;
}
var furthestVoid = Editor["void"](editor, {
at: at,
mode: 'highest'
});
var emptyInlinePath = unit === 'character' && distance === 1 ? findEmptyInlineToDelete(editor, at, reverse) : undefined;
if (!voids && furthestVoid) {
var _furthestVoid = _slicedToArray(furthestVoid, 2),
_voidPath = _furthestVoid[1];
at = _voidPath;
} else if (emptyInlinePath) {
at = emptyInlinePath;
} else {
var opts = {
unit: unit,
distance: distance
};
var _target = reverse ? Editor.before(editor, at, opts) || Editor.start(editor, []) : Editor.after(editor, at, opts) || Editor.end(editor, []);
at = {
anchor: at,
focus: _target
};
hanging = true;
}
}
if (Location.isPath(at)) {
// When deleting a void backward from the cursor, keep the cursor before
// it instead of letting it move into the following node.
var before = options.at == null && reverse ? Editor.before(editor, at) : undefined;
var beforeRef = before && Path.isAncestor(Path.parent(at), before.path) ? Editor.pointRef(editor, before) : undefined;
Transforms.removeNodes(editor, {
at: at,
voids: voids
});
if (editor.children.length === 0 && options.at == null) {
beforeRef === null || beforeRef === void 0 || beforeRef.unref();
Transforms.insertNodes(editor, {
children: [{
text: ''
}]
}, {
at: [0],
select: true
});
return;
}
var _point = beforeRef && beforeRef.unref();
if (_point) {
Transforms.select(editor, _point);
}
return;
}
if (Range.isCollapsed(at)) {
return;
}
if (!hanging) {
var _Range$edges = Range.edges(at),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
_end = _Range$edges2[1];
var endOfDoc = Editor.end(editor, []);
if (!Point.equals(_end, endOfDoc)) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
}
var _Range$edges3 = Range.edges(at),
_Range$edges4 = _slicedToArray(_Range$edges3, 2),
start = _Range$edges4[0],
end = _Range$edges4[1];
var startBlock = Editor.above(editor, {
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
},
at: start,
voids: voids
});
var endBlock = Editor.above(editor, {
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
},
at: end,
voids: voids
});
var isAcrossBlocks = startBlock && endBlock && !Path.equals(startBlock[1], endBlock[1]);
var isSingleText = Path.equals(start.path, end.path);
var startNonEditable = voids ? null : (_Editor$void = Editor["void"](editor, {
at: start,
mode: 'highest'
})) !== null && _Editor$void !== void 0 ? _Editor$void : Editor.elementReadOnly(editor, {
at: start,
mode: 'highest'
});
var endNonEditable = voids ? null : (_Editor$void2 = Editor["void"](editor, {
at: end,
mode: 'highest'
})) !== null && _Editor$void2 !== void 0 ? _Editor$void2 : Editor.elementReadOnly(editor, {
at: end,
mode: 'highest'
});
// If the start or end points are inside an inline void, nudge them out.
if (startNonEditable) {
var _before = Editor.before(editor, start);
if (_before && startBlock && Path.isAncestor(startBlock[1], _before.path)) {
start = _before;
}
}
if (endNonEditable) {
var after = Editor.after(editor, end);
if (after && endBlock && Path.isAncestor(endBlock[1], after.path)) {
end = after;
}
}
// Get the highest nodes that are completely inside the range, as well as
// the start and end nodes.
var matches = [];
var lastPath;
var _iterator = _createForOfIteratorHelper$6(Editor.nodes(editor, {
at: at,
voids: voids
})),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var entry = _step.value;
var _entry = _slicedToArray(entry, 2),
_node2 = _entry[0],
_path2 = _entry[1];
if (lastPath && Path.compare(_path2, lastPath) === 0) {
continue;
}
if (!voids && Node.isElement(_node2) && (Editor.isVoid(editor, _node2) || Editor.isElementReadOnly(editor, _node2)) || !Path.isCommon(_path2, start.path) && !Path.isCommon(_path2, end.path)) {
matches.push(entry);
lastPath = _path2;
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var pathRefs = Array.from(matches, function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return Editor.pathRef(editor, p);
});
var startRef = Editor.pointRef(editor, start);
var endRef = Editor.pointRef(editor, end);
var removedText = '';
if (!isSingleText && !startNonEditable) {
var _point2 = startRef.current;
var _Editor$leaf = Editor.leaf(editor, _point2),
_Editor$leaf2 = _slicedToArray(_Editor$leaf, 1),
node = _Editor$leaf2[0];
var path = _point2.path;
var _start = start,
offset = _start.offset;
var text = node.text.slice(offset);
if (text.length > 0) {
editor.apply({
type: 'remove_text',
path: path,
offset: offset,
text: text
});
removedText = text;
}
}
pathRefs.reverse().map(function (r) {
return r.unref();
}).filter(function (r) {
return r !== null;
}).forEach(function (p) {
return Transforms.removeNodes(editor, {
at: p,
voids: voids
});
});
if (!endNonEditable) {
var _point3 = endRef.current;
var _Editor$leaf3 = Editor.leaf(editor, _point3),
_Editor$leaf4 = _slicedToArray(_Editor$leaf3, 1),
_node = _Editor$leaf4[0];
var _path = _point3.path;
var _offset = isSingleText ? start.offset : 0;
var _text = _node.text.slice(_offset, end.offset);
if (_text.length > 0) {
editor.apply({
type: 'remove_text',
path: _path,
offset: _offset,
text: _text
});
removedText = _text;
}
}
if (!isSingleText && isAcrossBlocks && endRef.current && startRef.current) {
Transforms.mergeNodes(editor, {
at: endRef.current,
hanging: true,
voids: voids
});
}
// For certain scripts, deleting N character(s) backward should delete
// N code point(s) instead of an entire grapheme cluster.
// Therefore, the remaining code points should be inserted back.
// Bengali: \u0980-\u09FF
// Thai: \u0E00-\u0E7F
// Burmese (Myanmar): \u1000-\u109F
// Hindi (Devanagari): \u0900-\u097F
// Khmer: \u1780-\u17FF
// Malayalam: \u0D00-\u0D7F
// Oriya: \u0B00-\u0B7F
// Punjabi (Gurmukhi): \u0A00-\u0A7F
// Tamil: \u0B80-\u0BFF
// Telugu: \u0C00-\u0C7F
if (isCollapsed && reverse && unit === 'character' && removedText.length > 1 && removedText.match(/[\u0980-\u09FF\u0E00-\u0E7F\u1000-\u109F\u0900-\u097F\u1780-\u17FF\u0D00-\u0D7F\u0B00-\u0B7F\u0A00-\u0A7F\u0B80-\u0BFF\u0C00-\u0C7F]+/)) {
Transforms.insertText(editor, removedText.slice(0, removedText.length - distance));
}
var startUnref = startRef.unref();
var endUnref = endRef.unref();
var point = reverse ? startUnref || endUnref : endUnref || startUnref;
if (options.at == null && point) {
Transforms.select(editor, point);
}
});
};
function _createForOfIteratorHelper$5(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$5(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$5(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$5(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$5(r, a) : void 0; } }
function _arrayLikeToArray$5(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var insertFragment = function insertFragment(editor, fragment) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
Editor.withoutNormalizing(editor, function () {
var _options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var _options$at = options.at,
at = _options$at === void 0 ? getDefaultInsertLocation(editor) : _options$at,
_options$batchDirty = options.batchDirty,
batchDirty = _options$batchDirty === void 0 ? true : _options$batchDirty;
if (!fragment.length) {
return;
}
if (Location.isRange(at)) {
if (!hanging) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
if (Range.isCollapsed(at)) {
at = at.anchor;
} else {
var _Range$edges = Range.edges(at),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
end = _Range$edges2[1];
if (!voids && Editor["void"](editor, {
at: end
})) {
return;
}
var pointRef = Editor.pointRef(editor, end);
Transforms["delete"](editor, {
at: at
});
at = pointRef.unref();
}
} else if (Location.isPath(at)) {
at = Editor.start(editor, at);
}
if (!voids && Editor["void"](editor, {
at: at
})) {
return;
}
// If the insert point is at the edge of an inline node, move it outside
// instead since it will need to be split otherwise.
var inlineElementMatch = Editor.above(editor, {
at: at,
match: function match(n) {
return Node.isElement(n) && Editor.isInline(editor, n);
},
mode: 'highest',
voids: voids
});
if (inlineElementMatch) {
var _inlineElementMatch = _slicedToArray(inlineElementMatch, 2),
_inlinePath = _inlineElementMatch[1];
if (Editor.isEnd(editor, at, _inlinePath)) {
var after = Editor.after(editor, _inlinePath);
at = after;
} else if (Editor.isStart(editor, at, _inlinePath)) {
var before = Editor.before(editor, _inlinePath);
at = before;
}
}
var blockMatch = Editor.above(editor, {
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
},
at: at,
voids: voids
});
var _blockMatch = _slicedToArray(blockMatch, 2),
blockPath = _blockMatch[1];
var isBlockStart = Editor.isStart(editor, at, blockPath);
var isBlockEnd = Editor.isEnd(editor, at, blockPath);
var isBlockEmpty = isBlockStart && isBlockEnd;
var _Node$first = Node.first({
children: fragment
}, []),
_Node$first2 = _slicedToArray(_Node$first, 2),
firstLeafPath = _Node$first2[1];
var _Node$last = Node.last({
children: fragment
}, []),
_Node$last2 = _slicedToArray(_Node$last, 2),
lastLeafPath = _Node$last2[1];
// For each node in the fragment, determine what level of wrapping should
// be kept. At minimum, all text nodes will be inserted, but if
// `shouldInsert` returns true for some ancestor of a particular text node,
// then the entire ancestor will be inserted rather than inserting the text
// nodes individually.
var shouldInsert = function shouldInsert(_ref) {
var _ref2 = _slicedToArray(_ref, 2),
n = _ref2[0],
p = _ref2[1];
var isRoot = p.length === 0;
if (isRoot) {
return false;
}
// If the destination block is empty, insert all top-level blocks of the
// fragment.
if (isBlockEmpty) {
return true;
}
// Unless we're at the start of the destination block, unwrap any
// non-void blocks that contain the first leaf node in the fragment.
if (!isBlockStart && Path.isAncestor(p, firstLeafPath) && Node.isElement(n) && !editor.isVoid(n) && !editor.isInline(n)) {
return false;
}
// Unless we're at the end of the destination block, unwrap any non-void
// blocks that contain the last leaf node in the fragment.
if (!isBlockEnd && Path.isAncestor(p, lastLeafPath) && Node.isElement(n) && !editor.isVoid(n) && !editor.isInline(n)) {
return false;
}
// Always insert void nodes, inline elements and text nodes.
return true;
};
// Whether the current node is in the first block of the fragment.
var starting = true;
// Inline nodes in the first block of the fragment, to be merged with the
// destination block.
var starts = [];
// Blocks in the middle of the fragment.
var middles = [];
// Inline nodes in the last block of the fragment, to be merged with the
// destination block. If the fragment contains only one block, this will be
// empty.
var ends = [];
var _iterator = _createForOfIteratorHelper$5(Node.nodes({
children: fragment
}, {
pass: shouldInsert
})),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var entry = _step.value;
var _entry = _slicedToArray(entry, 2),
node = _entry[0],
_path = _entry[1];
// If we encounter a block that does not contain the first leaf, we're no
// longer in the first block of the fragment.
if (starting && Node.isElement(node) && !editor.isInline(node) && !Path.isAncestor(_path, firstLeafPath)) {
starting = false;
}
if (shouldInsert(entry)) {
if (Node.isElement(node) && !editor.isInline(node)) {
starting = false;
middles.push(node);
} else if (starting) {
starts.push(node);
} else {
ends.push(node);
}
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var _Editor$nodes = Editor.nodes(editor, {
at: at,
match: function match(n) {
return Node.isText(n) || Editor.isInline(editor, n);
},
mode: 'highest',
voids: voids
}),
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
inlineMatch = _Editor$nodes2[0];
var _inlineMatch = _slicedToArray(inlineMatch, 2),
inlinePath = _inlineMatch[1];
var isInlineStart = Editor.isStart(editor, at, inlinePath);
var isInlineEnd = Editor.isEnd(editor, at, inlinePath);
var middleRef = Editor.pathRef(editor, isBlockEnd && !ends.length ? Path.next(blockPath) : blockPath);
var endRef = Editor.pathRef(editor, isInlineEnd ? Path.next(inlinePath) : inlinePath);
// If the fragment contains inlines in multiple distinct blocks, split the
// destination block.
var splitBlock = ends.length > 0;
Transforms.splitNodes(editor, {
at: at,
match: function match(n) {
return splitBlock ? Node.isElement(n) && Editor.isBlock(editor, n) : Node.isText(n) || Editor.isInline(editor, n);
},
mode: splitBlock ? 'lowest' : 'highest',
always: splitBlock && (!isBlockStart || starts.length > 0) && (!isBlockEnd || ends.length > 0),
voids: voids
});
var startRef = Editor.pathRef(editor, !isInlineStart || isInlineStart && isInlineEnd ? Path.next(inlinePath) : inlinePath);
Transforms.insertNodes(editor, starts, {
at: startRef.current,
match: function match(n) {
return Node.isText(n) || Editor.isInline(editor, n);
},
mode: 'highest',
voids: voids,
batchDirty: batchDirty
});
if (isBlockEmpty && !starts.length && middles.length && !ends.length) {
Transforms.removeNodes(editor, {
at: blockPath,
voids: voids
});
}
Transforms.insertNodes(editor, middles, {
at: middleRef.current,
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
},
mode: 'lowest',
voids: voids,
batchDirty: batchDirty
});
Transforms.insertNodes(editor, ends, {
at: endRef.current,
match: function match(n) {
return Node.isText(n) || Editor.isInline(editor, n);
},
mode: 'highest',
voids: voids,
batchDirty: batchDirty
});
if (!options.at) {
var path;
if (ends.length > 0 && endRef.current) {
path = Path.previous(endRef.current);
} else if (middles.length > 0 && middleRef.current) {
path = Path.previous(middleRef.current);
} else if (startRef.current) {
path = Path.previous(startRef.current);
}
if (path) {
var _end = Editor.end(editor, path);
Transforms.select(editor, _end);
}
}
startRef.unref();
middleRef.unref();
endRef.unref();
});
};
var collapse = function collapse(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$edge = options.edge,
edge = _options$edge === void 0 ? 'anchor' : _options$edge;
var selection = editor.selection;
if (!selection) {
return;
} else if (edge === 'anchor') {
Transforms.select(editor, selection.anchor);
} else if (edge === 'focus') {
Transforms.select(editor, selection.focus);
} else if (edge === 'start') {
var _Range$edges = Range.edges(selection),
_Range$edges2 = _slicedToArray(_Range$edges, 1),
start = _Range$edges2[0];
Transforms.select(editor, start);
} else if (edge === 'end') {
var _Range$edges3 = Range.edges(selection),
_Range$edges4 = _slicedToArray(_Range$edges3, 2),
end = _Range$edges4[1];
Transforms.select(editor, end);
}
};
var deselect = function deselect(editor) {
var selection = editor.selection;
if (selection) {
editor.apply({
type: 'set_selection',
properties: selection,
newProperties: null
});
}
};
var move = function move(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var selection = editor.selection;
var _options$distance = options.distance,
distance = _options$distance === void 0 ? 1 : _options$distance,
_options$unit = options.unit,
unit = _options$unit === void 0 ? 'character' : _options$unit,
_options$reverse = options.reverse,
reverse = _options$reverse === void 0 ? false : _options$reverse;
var _options$edge = options.edge,
edge = _options$edge === void 0 ? null : _options$edge;
if (!selection) {
return;
}
if (edge === 'start') {
edge = Range.isBackward(selection) ? 'focus' : 'anchor';
}
if (edge === 'end') {
edge = Range.isBackward(selection) ? 'anchor' : 'focus';
}
var anchor = selection.anchor,
focus = selection.focus;
var opts = {
distance: distance,
unit: unit
};
var props = {};
if (edge == null || edge === 'anchor') {
var point = reverse ? Editor.before(editor, anchor, opts) : Editor.after(editor, anchor, opts);
if (point) {
props.anchor = point;
}
}
if (edge == null || edge === 'focus') {
var _point = reverse ? Editor.before(editor, focus, opts) : Editor.after(editor, focus, opts);
if (_point) {
props.focus = _point;
}
}
Transforms.setSelection(editor, props);
};
var select = function select(editor, target) {
var selection = editor.selection;
target = Editor.range(editor, target);
if (selection) {
Transforms.setSelection(editor, target);
return;
}
if (!Location.isRange(target)) {
throw new Error("When setting the selection and the current selection is `null` you must provide at least an `anchor` and `focus`, but you passed: ".concat(Scrubber.stringify(target)));
}
editor.apply({
type: 'set_selection',
properties: selection,
newProperties: target
});
};
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var setPoint = function setPoint(editor, props) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var selection = editor.selection;
var _options$edge = options.edge,
edge = _options$edge === void 0 ? 'both' : _options$edge;
if (!selection) {
return;
}
if (edge === 'start') {
edge = Range.isBackward(selection) ? 'focus' : 'anchor';
}
if (edge === 'end') {
edge = Range.isBackward(selection) ? 'anchor' : 'focus';
}
var anchor = selection.anchor,
focus = selection.focus;
var point = edge === 'anchor' ? anchor : focus;
Transforms.setSelection(editor, _defineProperty({}, edge === 'anchor' ? 'anchor' : 'focus', _objectSpread$1(_objectSpread$1({}, point), props)));
};
var setSelection = function setSelection(editor, props) {
var selection = editor.selection;
var oldProps = {};
var newProps = {};
if (!selection) {
return;
}
for (var k in props) {
if (NON_SETTABLE_SELECTION_PROPERTIES.includes(k)) {
continue;
}
var value = Object.hasOwn(selection, k) ? selection[k] : undefined;
var newValue = props[k];
if (compareSelectionProps(k, value, newValue)) {
oldProps[k] = selection[k];
newProps[k] = props[k];
}
}
if (Object.keys(oldProps).length > 0) {
editor.apply({
type: 'set_selection',
properties: oldProps,
newProperties: newProps
});
}
};
function compareSelectionProps(key, value, newValue) {
if ((key === 'anchor' || key === 'focus') && Point.isPoint(value) && Point.isPoint(newValue)) {
return !Point.equals(value, newValue);
}
return value !== newValue;
}
function _createForOfIteratorHelper$4(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$4(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$4(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$4(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$4(r, a) : void 0; } }
function _arrayLikeToArray$4(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var insertNodes = function insertNodes(editor, nodes) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
Editor.withoutNormalizing(editor, function () {
var _options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids,
_options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$batchDirty = options.batchDirty,
batchDirty = _options$batchDirty === void 0 ? true : _options$batchDirty;
var at = options.at,
match = options.match,
select = options.select;
if (Node.isNode(nodes)) {
nodes = [nodes];
}
if (nodes.length === 0) {
return;
}
var _nodes = nodes,
_nodes2 = _slicedToArray(_nodes, 1),
node = _nodes2[0];
if (!at) {
at = getDefaultInsertLocation(editor);
if (select !== false) {
select = true;
}
}
if (select == null) {
select = false;
}
if (Location.isRange(at)) {
if (!hanging) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
if (Range.isCollapsed(at)) {
at = at.anchor;
} else {
var _Range$edges = Range.edges(at),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
end = _Range$edges2[1];
var pointRef = Editor.pointRef(editor, end);
Transforms["delete"](editor, {
at: at
});
at = pointRef.unref();
}
}
if (Location.isPoint(at)) {
if (match == null) {
if (Node.isText(node)) {
match = function match(n) {
return Node.isText(n);
};
} else if (editor.isInline(node)) {
match = function match(n) {
return Node.isText(n) || Editor.isInline(editor, n);
};
} else {
match = function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
}
var _Editor$nodes = Editor.nodes(editor, {
at: at.path,
match: match,
mode: mode,
voids: voids
}),
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
entry = _Editor$nodes2[0];
if (entry) {
var _entry = _slicedToArray(entry, 2),
matchPath = _entry[1];
var pathRef = Editor.pathRef(editor, matchPath);
var isAtEnd = Editor.isEnd(editor, at, matchPath);
Transforms.splitNodes(editor, {
at: at,
match: match,
mode: mode,
voids: voids
});
var path = pathRef.unref();
at = isAtEnd ? Path.next(path) : path;
} else {
return;
}
}
var parentPath = Path.parent(at);
var index = at[at.length - 1];
if (!voids && Editor["void"](editor, {
at: parentPath
})) {
return;
}
if (batchDirty) {
// PERF: batch update dirty paths
// batched ops used to transform existing dirty paths
var batchedOps = [];
var newDirtyPaths = Path.levels(parentPath);
batchDirtyPaths(editor, function () {
var _iterator = _createForOfIteratorHelper$4(nodes),
_step;
try {
var _loop = function _loop() {
var node = _step.value;
var path = parentPath.concat(index);
index++;
var op = {
type: 'insert_node',
path: path,
node: node
};
editor.apply(op);
at = Path.next(at);
batchedOps.push(op);
if (Node.isText(node)) {
newDirtyPaths.push(path);
} else {
newDirtyPaths.push.apply(newDirtyPaths, _toConsumableArray(Array.from(Node.nodes(node), function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return path.concat(p);
})));
}
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}, function () {
updateDirtyPaths(editor, newDirtyPaths, function (p) {
var newPath = p;
for (var _i = 0, _batchedOps = batchedOps; _i < _batchedOps.length; _i++) {
var op = _batchedOps[_i];
if (Path.operationCanTransformPath(op)) {
newPath = Path.transform(newPath, op);
if (!newPath) {
return null;
}
}
}
return newPath;
});
});
} else {
var _iterator2 = _createForOfIteratorHelper$4(nodes),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _node = _step2.value;
var _path = parentPath.concat(index);
index++;
editor.apply({
type: 'insert_node',
path: _path,
node: _node
});
at = Path.next(at);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
}
at = Path.previous(at);
if (select) {
var point = Editor.end(editor, at);
if (point) {
Transforms.select(editor, point);
}
}
});
};
var liftNodes = function liftNodes(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Editor.withoutNormalizing(editor, function () {
var _options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
_options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var match = options.match;
if (!at) {
return;
}
if (match == null) {
match = Location.isPath(at) ? matchPath(editor, at) : function (n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
var matches = Editor.nodes(editor, {
at: at,
match: match,
mode: mode,
voids: voids
});
var pathRefs = Array.from(matches, function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return Editor.pathRef(editor, p);
});
for (var _i = 0, _pathRefs = pathRefs; _i < _pathRefs.length; _i++) {
var pathRef = _pathRefs[_i];
var path = pathRef.unref();
if (path.length < 2) {
throw new Error("Cannot lift node at a path [".concat(path, "] because it has a depth of less than `2`."));
}
var parentNodeEntry = Editor.node(editor, Path.parent(path));
var _parentNodeEntry = _slicedToArray(parentNodeEntry, 2),
parent = _parentNodeEntry[0],
parentPath = _parentNodeEntry[1];
var index = path[path.length - 1];
var length = parent.children.length;
if (length === 1) {
var toPath = Path.next(parentPath);
Transforms.moveNodes(editor, {
at: path,
to: toPath,
voids: voids
});
Transforms.removeNodes(editor, {
at: parentPath,
voids: voids
});
} else if (index === 0) {
Transforms.moveNodes(editor, {
at: path,
to: parentPath,
voids: voids
});
} else if (index === length - 1) {
var _toPath = Path.next(parentPath);
Transforms.moveNodes(editor, {
at: path,
to: _toPath,
voids: voids
});
} else {
var splitPath = Path.next(path);
var _toPath2 = Path.next(parentPath);
Transforms.splitNodes(editor, {
at: splitPath,
voids: voids
});
Transforms.moveNodes(editor, {
at: path,
to: _toPath2,
voids: voids
});
}
}
});
};
var _excluded = ["text"],
_excluded2 = ["children"];
var _hasSingleChildNest = function hasSingleChildNest(editor, node) {
return node !== editor && (Node.isText(node) || Editor.isVoid(editor, node) || node.children.length === 1 && _hasSingleChildNest(editor, node.children[0]));
};
var mergeNodes = function mergeNodes(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Editor.withoutNormalizing(editor, function () {
var match = options.match,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at;
var _options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids,
_options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode;
if (!at) {
return;
}
var isPathMerge = Location.isPath(at);
var pathAt = isPathMerge ? at : null;
var usesDefaultSiblingMatch = match == null && isPathMerge;
if (match == null) {
if (isPathMerge) {
var _Editor$parent = Editor.parent(editor, at),
_Editor$parent2 = _slicedToArray(_Editor$parent, 1),
parent = _Editor$parent2[0];
match = function match(n) {
return parent.children.includes(n);
};
} else {
match = function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
}
if (!hanging && Location.isRange(at)) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
if (Location.isRange(at)) {
if (Range.isCollapsed(at)) {
at = at.anchor;
} else {
var _Range$edges = Range.edges(at),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
end = _Range$edges2[1];
var pointRef = Editor.pointRef(editor, end);
Transforms["delete"](editor, {
at: at
});
at = pointRef.unref();
if (options.at == null) {
Transforms.select(editor, at);
}
}
}
var _Editor$nodes = Editor.nodes(editor, {
at: at,
match: match,
voids: voids,
mode: mode
}),
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
current = _Editor$nodes2[0];
var previousPath = usesDefaultSiblingMatch && pathAt && Path.hasPrevious(pathAt) ? Path.previous(pathAt) : null;
var prev = previousPath ? Editor.node(editor, previousPath) : Editor.previous(editor, {
at: at,
match: match,
voids: voids,
mode: mode
});
if (!current || !prev) {
return;
}
var _current = _slicedToArray(current, 2),
node = _current[0],
path = _current[1];
var _prev = _slicedToArray(prev, 2),
prevNode = _prev[0],
prevPath = _prev[1];
if (path.length === 0 || prevPath.length === 0) {
return;
}
var newPath = Path.next(prevPath);
var commonPath = Path.common(path, prevPath);
var isPreviousSibling = Path.isSibling(path, prevPath);
var levels = Array.from(Editor.levels(editor, {
at: path
}), function (_ref) {
var _ref2 = _slicedToArray(_ref, 1),
n = _ref2[0];
return n;
}).slice(commonPath.length).slice(0, -1);
// Determine if the merge will leave an ancestor of the path empty as a
// result, in which case we'll want to remove it after merging.
var emptyAncestor = Editor.above(editor, {
at: path,
mode: 'highest',
match: function match(n) {
return levels.includes(n) && _hasSingleChildNest(editor, n);
}
});
var emptyRef = emptyAncestor && Editor.pathRef(editor, emptyAncestor[1]);
var properties;
var position;
// Ensure that the nodes are equivalent, and figure out what the position
// and extra properties of the merge will be.
if (Node.isText(node) && Node.isText(prevNode)) {
node.text;
var rest = _objectWithoutProperties(node, _excluded);
position = prevNode.text.length;
properties = rest;
} else if (Node.isElement(node) && Node.isElement(prevNode)) {
node.children;
var _rest = _objectWithoutProperties(node, _excluded2);
position = prevNode.children.length;
properties = _rest;
} else {
throw new Error("Cannot merge the node at path [".concat(path, "] with the previous sibling because it is not the same kind: ").concat(Scrubber.stringify(node), " ").concat(Scrubber.stringify(prevNode)));
}
// If the node isn't already the next sibling of the previous node, move
// it so that it is before merging.
if (!isPreviousSibling) {
Transforms.moveNodes(editor, {
at: path,
to: newPath,
voids: voids
});
}
// If there was going to be an empty ancestor of the node that was merged,
// we remove it from the tree.
if (emptyRef) {
Transforms.removeNodes(editor, {
at: emptyRef.current,
voids: voids
});
}
if (Editor.shouldMergeNodesRemovePrevNode(editor, prev, current)) {
Transforms.removeNodes(editor, {
at: prevPath,
voids: voids
});
} else {
editor.apply({
type: 'merge_node',
path: newPath,
position: position,
properties: properties
});
}
if (emptyRef) {
emptyRef.unref();
}
});
};
var moveNodes = function moveNodes(editor, options) {
Editor.withoutNormalizing(editor, function () {
var to = options.to,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
_options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var match = options.match;
if (!at) {
return;
}
if (match == null) {
match = Location.isPath(at) ? matchPath(editor, at) : function (n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
var toRef = Editor.pathRef(editor, to);
var targets = Editor.nodes(editor, {
at: at,
match: match,
mode: mode,
voids: voids
});
var pathRefs = Array.from(targets, function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return Editor.pathRef(editor, p);
});
for (var _i = 0, _pathRefs = pathRefs; _i < _pathRefs.length; _i++) {
var pathRef = _pathRefs[_i];
var path = pathRef.unref();
var newPath = toRef.current;
if (path.length !== 0) {
editor.apply({
type: 'move_node',
path: path,
newPath: newPath
});
}
if (toRef.current && Path.isSibling(newPath, path) && Path.isAfter(newPath, path)) {
// When performing a sibling move to a later index, the path at the destination is shifted
// to before the insertion point instead of after. To ensure our group of nodes are inserted
// in the correct order we increment toRef to account for that
toRef.current = Path.next(toRef.current);
}
}
toRef.unref();
});
};
var removeNodes = function removeNodes(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Editor.withoutNormalizing(editor, function () {
var _options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids,
_options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode;
var _options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
match = options.match;
if (!at) {
return;
}
if (match == null) {
match = Location.isPath(at) ? matchPath(editor, at) : function (n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
if (!hanging && Location.isRange(at)) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
var depths = Editor.nodes(editor, {
at: at,
match: match,
mode: mode,
voids: voids
});
var pathRefs = Array.from(depths, function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return Editor.pathRef(editor, p);
});
for (var _i = 0, _pathRefs = pathRefs; _i < _pathRefs.length; _i++) {
var pathRef = _pathRefs[_i];
var path = pathRef.unref();
if (path) {
var _Editor$node = Editor.node(editor, path),
_Editor$node2 = _slicedToArray(_Editor$node, 1),
node = _Editor$node2[0];
editor.apply({
type: 'remove_node',
path: path,
node: node
});
}
}
});
};
function _createForOfIteratorHelper$3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var setNodes = function setNodes(editor, props) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
Editor.withoutNormalizing(editor, function () {
var match = options.match,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
compare = options.compare,
merge = options.merge;
var _options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging,
_options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$split = options.split,
split = _options$split === void 0 ? false : _options$split,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
if (!at) {
return;
}
if (match == null) {
match = Location.isPath(at) ? matchPath(editor, at) : function (n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
if (!hanging && Location.isRange(at)) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
if (split && Location.isRange(at)) {
if (Range.isCollapsed(at) && Editor.leaf(editor, at.anchor)[0].text.length > 0) {
// If the range is collapsed in a non-empty node and 'split' is true, there's nothing to
// set that won't get normalized away
return;
}
var rangeRef = Editor.rangeRef(editor, at, {
affinity: 'inward'
});
var _Range$edges = Range.edges(at),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
start = _Range$edges2[0],
end = _Range$edges2[1];
var splitMode = mode === 'lowest' ? 'lowest' : 'highest';
var endAtEndOfNode = Editor.isEnd(editor, end, end.path);
Transforms.splitNodes(editor, {
at: end,
match: match,
mode: splitMode,
voids: voids,
always: !endAtEndOfNode
});
var startAtStartOfNode = Editor.isStart(editor, start, start.path);
Transforms.splitNodes(editor, {
at: start,
match: match,
mode: splitMode,
voids: voids,
always: !startAtStartOfNode
});
at = rangeRef.unref();
if (options.at == null) {
Transforms.select(editor, at);
}
}
if (!compare) {
compare = function compare(prop, nodeProp) {
return prop !== nodeProp;
};
}
var _iterator = _createForOfIteratorHelper$3(Editor.nodes(editor, {
at: at,
match: match,
mode: mode,
voids: voids
})),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _slicedToArray(_step.value, 2),
node = _step$value[0],
path = _step$value[1];
var properties = {};
var newProperties = {};
// You can't set properties on the editor node.
if (path.length === 0) {
continue;
}
var hasChanges = false;
for (var k in props) {
if (NON_SETTABLE_NODE_PROPERTIES.includes(k)) {
continue;
}
var value = Object.hasOwn(node, k) ? node[k] : undefined;
var newValue = props[k];
if (compare(newValue, value)) {
hasChanges = true;
// Omit new properties from the old properties list
if (Object.hasOwn(node, k)) properties[k] = value;
// Omit properties that have been removed from the new properties list
if (merge) {
if (newValue != null) newProperties[k] = merge(value, newValue);
} else {
if (newValue != null) newProperties[k] = newValue;
}
}
}
if (hasChanges) {
editor.apply({
type: 'set_node',
path: path,
properties: properties,
newProperties: newProperties
});
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
});
};
function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0; } }
function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
/**
* Convert a range into a point by deleting it's content.
*/
var deleteRange = function deleteRange(editor, range) {
if (Range.isCollapsed(range)) {
return range.anchor;
} else {
var _Range$edges = Range.edges(range),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
end = _Range$edges2[1];
var pointRef = Editor.pointRef(editor, end);
Transforms["delete"](editor, {
at: range
});
return pointRef.unref();
}
};
var splitNodes = function splitNodes(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Editor.withoutNormalizing(editor, function () {
var _options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var match = options.match,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
_options$height = options.height,
height = _options$height === void 0 ? 0 : _options$height,
_options$always = options.always,
always = _options$always === void 0 ? false : _options$always;
if (!at) return;
if (match == null) {
match = function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
if (Location.isRange(at)) {
at = deleteRange(editor, at);
if (!at) return;
}
// If the target is a path, the default height-skipping and position
// counters need to account for us potentially splitting at a non-leaf.
if (Location.isPath(at)) {
var path = at;
var point = Editor.point(editor, path);
var _Editor$parent = Editor.parent(editor, path),
_Editor$parent2 = _slicedToArray(_Editor$parent, 1),
parent = _Editor$parent2[0];
match = function match(n) {
return n === parent;
};
height = point.path.length - path.length + 1;
at = point;
always = true;
}
var beforeRef = Editor.pointRef(editor, at, {
affinity: 'backward'
});
var afterRef;
try {
var _Editor$nodes = Editor.nodes(editor, {
at: at,
match: match,
mode: mode,
voids: voids
}),
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
highest = _Editor$nodes2[0];
if (!highest) {
return;
}
var voidMatch = Editor["void"](editor, {
at: at,
mode: 'highest'
});
var nudge = 0;
if (!voids && voidMatch) {
var _voidMatch = _slicedToArray(voidMatch, 2),
voidNode = _voidMatch[0],
voidPath = _voidMatch[1];
if (editor.isInline(voidNode)) {
var after = Editor.after(editor, voidPath);
if (!after) {
var text = {
text: ''
};
var afterPath = Path.next(voidPath);
Transforms.insertNodes(editor, text, {
at: afterPath,
voids: voids
});
after = Editor.point(editor, afterPath);
}
at = after;
always = true;
}
var siblingHeight = at.path.length - voidPath.length;
height = siblingHeight + 1;
always = true;
}
afterRef = Editor.pointRef(editor, at);
var depth = at.path.length - height;
var _highest = _slicedToArray(highest, 2),
highestPath = _highest[1];
var lowestPath = at.path.slice(0, depth);
var position = height === 0 ? at.offset : at.path[depth] + nudge;
var _iterator = _createForOfIteratorHelper$2(Editor.levels(editor, {
at: lowestPath,
reverse: true,
voids: voids
})),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _slicedToArray(_step.value, 2),
node = _step$value[0],
_path = _step$value[1];
var split = false;
if (_path.length < highestPath.length || _path.length === 0 || !voids && Node.isElement(node) && Editor.isVoid(editor, node)) {
break;
}
var _point2 = beforeRef.current;
var isEnd = Editor.isEnd(editor, _point2, _path);
if (always || !beforeRef || !Editor.isEdge(editor, _point2, _path)) {
split = true;
var properties = Node.extractProps(node);
editor.apply({
type: 'split_node',
path: _path,
position: position,
properties: properties
});
}
position = _path[_path.length - 1] + (split || isEnd ? 1 : 0);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (options.at == null) {
var _point = afterRef.current || Editor.end(editor, []);
Transforms.select(editor, _point);
}
} finally {
var _afterRef;
beforeRef.unref();
(_afterRef = afterRef) === null || _afterRef === void 0 || _afterRef.unref();
}
});
};
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var unsetNodes = function unsetNodes(editor, props) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!Array.isArray(props)) {
props = [props];
}
var obj = {};
var _iterator = _createForOfIteratorHelper$1(props),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var key = _step.value;
obj[key] = null;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
Transforms.setNodes(editor, obj, options);
};
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var unwrapNodes = function unwrapNodes(editor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Editor.withoutNormalizing(editor, function () {
var _options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging,
_options$split = options.split,
split = _options$split === void 0 ? false : _options$split,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var _options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at,
match = options.match;
if (!at) {
return;
}
if (!hanging && Range.isRange(at)) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
if (match == null) {
match = Location.isPath(at) ? matchPath(editor, at) : function (n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
if (Location.isPath(at)) {
at = Editor.range(editor, at);
}
var rangeRef = Location.isRange(at) ? Editor.rangeRef(editor, at) : null;
var matches = Editor.nodes(editor, {
at: at,
match: match,
mode: mode,
voids: voids
});
var pathRefs = Array.from(matches, function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
p = _ref2[1];
return Editor.pathRef(editor, p);
}
// unwrapNode will call liftNode which does not support splitting the node when nested.
// If we do not reverse the order and call it from top to the bottom, it will remove all blocks
// that wrap target node. So we reverse the order.
).reverse();
var _iterator = _createForOfIteratorHelper(pathRefs),
_step;
try {
var _loop = function _loop() {
var pathRef = _step.value;
var path = pathRef.unref();
var _Editor$node = Editor.node(editor, path),
_Editor$node2 = _slicedToArray(_Editor$node, 1),
node = _Editor$node2[0];
var range = Editor.range(editor, path);
if (split && rangeRef) {
range = Range.intersection(rangeRef.current, range);
}
Transforms.liftNodes(editor, {
at: range,
match: function match(n) {
return !Node.isText(node) && node.children.includes(n);
},
voids: voids
});
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (rangeRef) {
rangeRef.unref();
}
});
};
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var wrapNodes = function wrapNodes(editor, element) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
Editor.withoutNormalizing(editor, function () {
var _options$mode = options.mode,
mode = _options$mode === void 0 ? 'lowest' : _options$mode,
_options$hanging = options.hanging,
hanging = _options$hanging === void 0 ? false : _options$hanging,
_options$split = options.split,
split = _options$split === void 0 ? false : _options$split,
_options$voids = options.voids,
voids = _options$voids === void 0 ? false : _options$voids;
var match = options.match,
_options$at = options.at,
at = _options$at === void 0 ? editor.selection : _options$at;
if (!at) {
return;
}
if (!hanging && Range.isRange(at)) {
at = Editor.unhangRange(editor, at, {
voids: voids
});
}
if (match == null) {
if (Location.isPath(at)) {
match = matchPath(editor, at);
} else if (editor.isInline(element)) {
match = function match(n) {
return Node.isElement(n) && Editor.isInline(editor, n) || Node.isText(n);
};
} else {
match = function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
};
}
}
if (split && Location.isRange(at)) {
var _Range$edges = Range.edges(at),
_Range$edges2 = _slicedToArray(_Range$edges, 2),
start = _Range$edges2[0],
end = _Range$edges2[1];
var rangeRef = Editor.rangeRef(editor, at, {
affinity: 'inward'
});
// Always split if we're in the middle of a block, to ensure that text
// node boundaries are handled correctly.
var isAtBlockEdge = function isAtBlockEdge(point) {
var blockAbove = Editor.above(editor, {
at: point,
match: function match(n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
}
});
return blockAbove && Editor.isEdge(editor, point, blockAbove[1]);
};
Transforms.splitNodes(editor, {
at: end,
match: match,
voids: voids,
always: !isAtBlockEdge(end)
});
Transforms.splitNodes(editor, {
at: start,
match: match,
voids: voids,
always: !isAtBlockEdge(start)
});
at = rangeRef.unref();
if (options.at == null) {
Transforms.select(editor, at);
}
}
var roots = Array.from(Editor.nodes(editor, {
at: at,
match: editor.isInline(element) ? function (n) {
return Node.isElement(n) && Editor.isBlock(editor, n);
} : function (n) {
return Node.isEditor(n);
},
mode: 'lowest',
voids: voids
}));
var _loop = function _loop() {
var _roots$_i = _slicedToArray(_roots[_i], 2),
rootPath = _roots$_i[1];
var a = Location.isRange(at) ? Range.intersection(at, Editor.range(editor, rootPath)) : at;
if (!a) {
return 0; // continue
}
var matches = Array.from(Editor.nodes(editor, {
at: a,
match: match,
mode: mode,
voids: voids
}));
if (matches.length > 0) {
var first = matches[0];
var last = matches[matches.length - 1];
var _first = _slicedToArray(first, 2),
firstPath = _first[1];
var _last = _slicedToArray(last, 2),
lastPath = _last[1];
if (firstPath.length === 0 && lastPath.length === 0) {
// if there's no matching parent - usually means the node is an editor - don't do anything
return 0; // continue
}
var commonPath = Path.equals(firstPath, lastPath) ? Path.parent(firstPath) : Path.common(firstPath, lastPath);
var range = Editor.range(editor, firstPath, lastPath);
var commonNodeEntry = Editor.node(editor, commonPath);
var _commonNodeEntry = _slicedToArray(commonNodeEntry, 1),
commonNode = _commonNodeEntry[0];
var depth = commonPath.length + 1;
var wrapperPath = Path.next(lastPath.slice(0, depth));
var wrapper = _objectSpread(_objectSpread({}, element), {}, {
children: []
});
Transforms.insertNodes(editor, wrapper, {
at: wrapperPath,
voids: voids
});
Transforms.moveNodes(editor, {
at: range,
match: function match(n) {
return !Node.isText(commonNode) && commonNode.children.includes(n);
},
to: wrapperPath.concat(0),
voids: voids
});
}
},
_ret;
for (var _i = 0, _roots = roots; _i < _roots.length; _i++) {
_ret = _loop();
if (_ret === 0) continue;
}
});
};
/**
* Create a new Slate `Editor` object.
*/
var createEditor = function createEditor() {
var editor = {
children: [],
operations: [],
selection: null,
marks: null,
isElementReadOnly: function isElementReadOnly() {
return false;
},
isInline: function isInline() {
return false;
},
isSelectable: function isSelectable() {
return true;
},
isVoid: function isVoid() {
return false;
},
markableVoid: function markableVoid() {
return false;
},
onChange: function onChange() {},
// Core
apply: function apply$1() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return apply.apply(void 0, [editor].concat(args));
},
// Editor
addMark: function addMark$1() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return addMark.apply(void 0, [editor].concat(args));
},
deleteBackward: function deleteBackward$1() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return deleteBackward.apply(void 0, [editor].concat(args));
},
deleteForward: function deleteForward$1() {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
return deleteForward.apply(void 0, [editor].concat(args));
},
deleteFragment: function deleteFragment$1() {
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
return deleteFragment.apply(void 0, [editor].concat(args));
},
getFragment: function getFragment$1() {
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
return getFragment.apply(void 0, [editor].concat(args));
},
insertBreak: function insertBreak$1() {
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
}
return insertBreak.apply(void 0, [editor].concat(args));
},
insertSoftBreak: function insertSoftBreak$1() {
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
args[_key8] = arguments[_key8];
}
return insertSoftBreak.apply(void 0, [editor].concat(args));
},
insertFragment: function insertFragment$1() {
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
args[_key9] = arguments[_key9];
}
return insertFragment.apply(void 0, [editor].concat(args));
},
insertNode: function insertNode$1() {
for (var _len0 = arguments.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
args[_key0] = arguments[_key0];
}
return insertNode.apply(void 0, [editor].concat(args));
},
insertText: function insertText$1() {
for (var _len1 = arguments.length, args = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
args[_key1] = arguments[_key1];
}
return insertText.apply(void 0, [editor].concat(args));
},
normalizeNode: function normalizeNode$1() {
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
args[_key10] = arguments[_key10];
}
return normalizeNode.apply(void 0, [editor].concat(args));
},
removeMark: function removeMark$1() {
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
args[_key11] = arguments[_key11];
}
return removeMark.apply(void 0, [editor].concat(args));
},
getDirtyPaths: function getDirtyPaths$1() {
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
args[_key12] = arguments[_key12];
}
return getDirtyPaths.apply(void 0, [editor].concat(args));
},
shouldNormalize: function shouldNormalize$1() {
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
args[_key13] = arguments[_key13];
}
return shouldNormalize.apply(void 0, [editor].concat(args));
},
// Editor interface
above: function above$1() {
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
args[_key14] = arguments[_key14];
}
return above.apply(void 0, [editor].concat(args));
},
after: function after$1() {
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
args[_key15] = arguments[_key15];
}
return after.apply(void 0, [editor].concat(args));
},
before: function before$1() {
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
args[_key16] = arguments[_key16];
}
return before.apply(void 0, [editor].concat(args));
},
collapse: function collapse$1() {
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
args[_key17] = arguments[_key17];
}
return collapse.apply(void 0, [editor].concat(args));
},
"delete": function _delete() {
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
args[_key18] = arguments[_key18];
}
return deleteText.apply(void 0, [editor].concat(args));
},
deselect: function deselect$1() {
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
args[_key19] = arguments[_key19];
}
return deselect.apply(void 0, [editor].concat(args));
},
edges: function edges$1() {
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
args[_key20] = arguments[_key20];
}
return edges.apply(void 0, [editor].concat(args));
},
elementReadOnly: function elementReadOnly$1() {
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
args[_key21] = arguments[_key21];
}
return elementReadOnly.apply(void 0, [editor].concat(args));
},
end: function end$1() {
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
args[_key22] = arguments[_key22];
}
return end.apply(void 0, [editor].concat(args));
},
first: function first$1() {
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
args[_key23] = arguments[_key23];
}
return first.apply(void 0, [editor].concat(args));
},
fragment: function fragment$1() {
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
args[_key24] = arguments[_key24];
}
return fragment.apply(void 0, [editor].concat(args));
},
getMarks: function getMarks() {
for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
args[_key25] = arguments[_key25];
}
return marks.apply(void 0, [editor].concat(args));
},
hasBlocks: function hasBlocks$1() {
for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
args[_key26] = arguments[_key26];
}
return hasBlocks.apply(void 0, [editor].concat(args));
},
hasInlines: function hasInlines$1() {
for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
args[_key27] = arguments[_key27];
}
return hasInlines.apply(void 0, [editor].concat(args));
},
hasPath: function hasPath$1() {
for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
args[_key28] = arguments[_key28];
}
return hasPath.apply(void 0, [editor].concat(args));
},
hasTexts: function hasTexts$1() {
for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
args[_key29] = arguments[_key29];
}
return hasTexts.apply(void 0, [editor].concat(args));
},
insertNodes: function insertNodes$1() {
for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
args[_key30] = arguments[_key30];
}
return insertNodes.apply(void 0, [editor].concat(args));
},
isBlock: function isBlock$1() {
for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
args[_key31] = arguments[_key31];
}
return isBlock.apply(void 0, [editor].concat(args));
},
isEdge: function isEdge$1() {
for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
args[_key32] = arguments[_key32];
}
return isEdge.apply(void 0, [editor].concat(args));
},
isEmpty: function isEmpty$1() {
for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
args[_key33] = arguments[_key33];
}
return isEmpty.apply(void 0, [editor].concat(args));
},
isEnd: function isEnd$1() {
for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) {
args[_key34] = arguments[_key34];
}
return isEnd.apply(void 0, [editor].concat(args));
},
isNormalizing: function isNormalizing$1() {
for (var _len35 = arguments.length, args = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) {
args[_key35] = arguments[_key35];
}
return isNormalizing.apply(void 0, [editor].concat(args));
},
isStart: function isStart$1() {
for (var _len36 = arguments.length, args = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) {
args[_key36] = arguments[_key36];
}
return isStart.apply(void 0, [editor].concat(args));
},
last: function last$1() {
for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) {
args[_key37] = arguments[_key37];
}
return last.apply(void 0, [editor].concat(args));
},
leaf: function leaf$1() {
for (var _len38 = arguments.length, args = new Array(_len38), _key38 = 0; _key38 < _len38; _key38++) {
args[_key38] = arguments[_key38];
}
return leaf.apply(void 0, [editor].concat(args));
},
levels: function levels$1() {
for (var _len39 = arguments.length, args = new Array(_len39), _key39 = 0; _key39 < _len39; _key39++) {
args[_key39] = arguments[_key39];
}
return levels.apply(void 0, [editor].concat(args));
},
liftNodes: function liftNodes$1() {
for (var _len40 = arguments.length, args = new Array(_len40), _key40 = 0; _key40 < _len40; _key40++) {
args[_key40] = arguments[_key40];
}
return liftNodes.apply(void 0, [editor].concat(args));
},
mergeNodes: function mergeNodes$1() {
for (var _len41 = arguments.length, args = new Array(_len41), _key41 = 0; _key41 < _len41; _key41++) {
args[_key41] = arguments[_key41];
}
return mergeNodes.apply(void 0, [editor].concat(args));
},
move: function move$1() {
for (var _len42 = arguments.length, args = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) {
args[_key42] = arguments[_key42];
}
return move.apply(void 0, [editor].concat(args));
},
moveNodes: function moveNodes$1() {
for (var _len43 = arguments.length, args = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) {
args[_key43] = arguments[_key43];
}
return moveNodes.apply(void 0, [editor].concat(args));
},
next: function next$1() {
for (var _len44 = arguments.length, args = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) {
args[_key44] = arguments[_key44];
}
return next.apply(void 0, [editor].concat(args));
},
node: function node$1() {
for (var _len45 = arguments.length, args = new Array(_len45), _key45 = 0; _key45 < _len45; _key45++) {
args[_key45] = arguments[_key45];
}
return node.apply(void 0, [editor].concat(args));
},
nodes: function nodes$1() {
for (var _len46 = arguments.length, args = new Array(_len46), _key46 = 0; _key46 < _len46; _key46++) {
args[_key46] = arguments[_key46];
}
return nodes.apply(void 0, [editor].concat(args));
},
normalize: function normalize$1() {
for (var _len47 = arguments.length, args = new Array(_len47), _key47 = 0; _key47 < _len47; _key47++) {
args[_key47] = arguments[_key47];
}
return normalize.apply(void 0, [editor].concat(args));
},
parent: function parent$1() {
for (var _len48 = arguments.length, args = new Array(_len48), _key48 = 0; _key48 < _len48; _key48++) {
args[_key48] = arguments[_key48];
}
return parent.apply(void 0, [editor].concat(args));
},
path: function path$1() {
for (var _len49 = arguments.length, args = new Array(_len49), _key49 = 0; _key49 < _len49; _key49++) {
args[_key49] = arguments[_key49];
}
return path.apply(void 0, [editor].concat(args));
},
pathRef: function pathRef$1() {
for (var _len50 = arguments.length, args = new Array(_len50), _key50 = 0; _key50 < _len50; _key50++) {
args[_key50] = arguments[_key50];
}
return pathRef.apply(void 0, [editor].concat(args));
},
pathRefs: function pathRefs$1() {
for (var _len51 = arguments.length, args = new Array(_len51), _key51 = 0; _key51 < _len51; _key51++) {
args[_key51] = arguments[_key51];
}
return pathRefs.apply(void 0, [editor].concat(args));
},
point: function point$1() {
for (var _len52 = arguments.length, args = new Array(_len52), _key52 = 0; _key52 < _len52; _key52++) {
args[_key52] = arguments[_key52];
}
return point.apply(void 0, [editor].concat(args));
},
pointRef: function pointRef$1() {
for (var _len53 = arguments.length, args = new Array(_len53), _key53 = 0; _key53 < _len53; _key53++) {
args[_key53] = arguments[_key53];
}
return pointRef.apply(void 0, [editor].concat(args));
},
pointRefs: function pointRefs$1() {
for (var _len54 = arguments.length, args = new Array(_len54), _key54 = 0; _key54 < _len54; _key54++) {
args[_key54] = arguments[_key54];
}
return pointRefs.apply(void 0, [editor].concat(args));
},
positions: function positions$1() {
for (var _len55 = arguments.length, args = new Array(_len55), _key55 = 0; _key55 < _len55; _key55++) {
args[_key55] = arguments[_key55];
}
return positions.apply(void 0, [editor].concat(args));
},
previous: function previous$1() {
for (var _len56 = arguments.length, args = new Array(_len56), _key56 = 0; _key56 < _len56; _key56++) {
args[_key56] = arguments[_key56];
}
return previous.apply(void 0, [editor].concat(args));
},
range: function range$1() {
for (var _len57 = arguments.length, args = new Array(_len57), _key57 = 0; _key57 < _len57; _key57++) {
args[_key57] = arguments[_key57];
}
return range.apply(void 0, [editor].concat(args));
},
rangeRef: function rangeRef$1() {
for (var _len58 = arguments.length, args = new Array(_len58), _key58 = 0; _key58 < _len58; _key58++) {
args[_key58] = arguments[_key58];
}
return rangeRef.apply(void 0, [editor].concat(args));
},
rangeRefs: function rangeRefs$1() {
for (var _len59 = arguments.length, args = new Array(_len59), _key59 = 0; _key59 < _len59; _key59++) {
args[_key59] = arguments[_key59];
}
return rangeRefs.apply(void 0, [editor].concat(args));
},
removeNodes: function removeNodes$1() {
for (var _len60 = arguments.length, args = new Array(_len60), _key60 = 0; _key60 < _len60; _key60++) {
args[_key60] = arguments[_key60];
}
return removeNodes.apply(void 0, [editor].concat(args));
},
select: function select$1() {
for (var _len61 = arguments.length, args = new Array(_len61), _key61 = 0; _key61 < _len61; _key61++) {
args[_key61] = arguments[_key61];
}
return select.apply(void 0, [editor].concat(args));
},
setNodes: function setNodes$1() {
for (var _len62 = arguments.length, args = new Array(_len62), _key62 = 0; _key62 < _len62; _key62++) {
args[_key62] = arguments[_key62];
}
return setNodes.apply(void 0, [editor].concat(args));
},
setNormalizing: function setNormalizing$1() {
for (var _len63 = arguments.length, args = new Array(_len63), _key63 = 0; _key63 < _len63; _key63++) {
args[_key63] = arguments[_key63];
}
return setNormalizing.apply(void 0, [editor].concat(args));
},
setPoint: function setPoint$1() {
for (var _len64 = arguments.length, args = new Array(_len64), _key64 = 0; _key64 < _len64; _key64++) {
args[_key64] = arguments[_key64];
}
return setPoint.apply(void 0, [editor].concat(args));
},
setSelection: function setSelection$1() {
for (var _len65 = arguments.length, args = new Array(_len65), _key65 = 0; _key65 < _len65; _key65++) {
args[_key65] = arguments[_key65];
}
return setSelection.apply(void 0, [editor].concat(args));
},
splitNodes: function splitNodes$1() {
for (var _len66 = arguments.length, args = new Array(_len66), _key66 = 0; _key66 < _len66; _key66++) {
args[_key66] = arguments[_key66];
}
return splitNodes.apply(void 0, [editor].concat(args));
},
start: function start$1() {
for (var _len67 = arguments.length, args = new Array(_len67), _key67 = 0; _key67 < _len67; _key67++) {
args[_key67] = arguments[_key67];
}
return start.apply(void 0, [editor].concat(args));
},
string: function string$1() {
for (var _len68 = arguments.length, args = new Array(_len68), _key68 = 0; _key68 < _len68; _key68++) {
args[_key68] = arguments[_key68];
}
return string.apply(void 0, [editor].concat(args));
},
unhangRange: function unhangRange$1() {
for (var _len69 = arguments.length, args = new Array(_len69), _key69 = 0; _key69 < _len69; _key69++) {
args[_key69] = arguments[_key69];
}
return unhangRange.apply(void 0, [editor].concat(args));
},
unsetNodes: function unsetNodes$1() {
for (var _len70 = arguments.length, args = new Array(_len70), _key70 = 0; _key70 < _len70; _key70++) {
args[_key70] = arguments[_key70];
}
return unsetNodes.apply(void 0, [editor].concat(args));
},
unwrapNodes: function unwrapNodes$1() {
for (var _len71 = arguments.length, args = new Array(_len71), _key71 = 0; _key71 < _len71; _key71++) {
args[_key71] = arguments[_key71];
}
return unwrapNodes.apply(void 0, [editor].concat(args));
},
"void": function _void() {
for (var _len72 = arguments.length, args = new Array(_len72), _key72 = 0; _key72 < _len72; _key72++) {
args[_key72] = arguments[_key72];
}
return getVoid.apply(void 0, [editor].concat(args));
},
withoutNormalizing: function withoutNormalizing$1() {
for (var _len73 = arguments.length, args = new Array(_len73), _key73 = 0; _key73 < _len73; _key73++) {
args[_key73] = arguments[_key73];
}
return withoutNormalizing.apply(void 0, [editor].concat(args));
},
wrapNodes: function wrapNodes$1() {
for (var _len74 = arguments.length, args = new Array(_len74), _key74 = 0; _key74 < _len74; _key74++) {
args[_key74] = arguments[_key74];
}
return wrapNodes.apply(void 0, [editor].concat(args));
},
shouldMergeNodesRemovePrevNode: function shouldMergeNodesRemovePrevNode$1() {
for (var _len75 = arguments.length, args = new Array(_len75), _key75 = 0; _key75 < _len75; _key75++) {
args[_key75] = arguments[_key75];
}
return shouldMergeNodesRemovePrevNode.apply(void 0, [editor].concat(args));
}
};
return editor;
};
exports.Editor = Editor;
exports.Element = Element;
exports.Location = Location;
exports.Node = Node;
exports.Operation = Operation;
exports.Path = Path;
exports.PathRef = PathRef;
exports.Point = Point;
exports.PointRef = PointRef;
exports.Range = Range;
exports.RangeRef = RangeRef;
exports.Scrubber = Scrubber;
exports.Span = Span;
exports.Text = Text;
exports.Transforms = Transforms;
exports.above = above;
exports.addMark = addMark;
exports.after = after;
exports.apply = apply;
exports.before = before;
exports.collapse = collapse;
exports.createEditor = createEditor;
exports.deleteBackward = deleteBackward;
exports.deleteForward = deleteForward;
exports.deleteFragment = deleteFragment;
exports.deleteText = deleteText;
exports.deselect = deselect;
exports.edges = edges;
exports.elementReadOnly = elementReadOnly;
exports.end = end;
exports.first = first;
exports.fragment = fragment;
exports.getDirtyPaths = getDirtyPaths;
exports.getFragment = getFragment;
exports.getVoid = getVoid;
exports.hasBlocks = hasBlocks;
exports.hasInlines = hasInlines;
exports.hasPath = hasPath;
exports.hasTexts = hasTexts;
exports.insertBreak = insertBreak;
exports.insertFragment = insertFragment;
exports.insertNode = insertNode;
exports.insertNodes = insertNodes;
exports.insertSoftBreak = insertSoftBreak;
exports.insertText = insertText;
exports.isBlock = isBlock;
exports.isEdge = isEdge;
exports.isEditor = isEditor;
exports.isEmpty = isEmpty;
exports.isEnd = isEnd;
exports.isNormalizing = isNormalizing;
exports.isObject = isObject;
exports.isStart = isStart;
exports.last = last;
exports.leaf = leaf;
exports.levels = levels;
exports.liftNodes = liftNodes;
exports.marks = marks;
exports.mergeNodes = mergeNodes;
exports.move = move;
exports.moveNodes = moveNodes;
exports.next = next;
exports.node = node;
exports.nodes = nodes;
exports.normalize = normalize;
exports.normalizeNode = normalizeNode;
exports.parent = parent;
exports.path = path;
exports.pathRef = pathRef;
exports.pathRefs = pathRefs;
exports.point = point;
exports.pointRef = pointRef;
exports.pointRefs = pointRefs;
exports.positions = positions;
exports.previous = previous;
exports.range = range;
exports.rangeRef = rangeRef;
exports.rangeRefs = rangeRefs;
exports.removeMark = removeMark;
exports.removeNodes = removeNodes;
exports.select = select;
exports.setNodes = setNodes;
exports.setNormalizing = setNormalizing;
exports.setPoint = setPoint;
exports.setSelection = setSelection;
exports.shouldMergeNodesRemovePrevNode = shouldMergeNodesRemovePrevNode;
exports.shouldNormalize = shouldNormalize;
exports.splitNodes = splitNodes;
exports.start = start;
exports.string = string;
exports.unhangRange = unhangRange;
exports.unsetNodes = unsetNodes;
exports.unwrapNodes = unwrapNodes;
exports.withoutNormalizing = withoutNormalizing;
exports.wrapNodes = wrapNodes;
}));