@contentful/field-editor-rich-text 2.0.0-next.18 → 2.0.0-next.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/field-editor-rich-text.cjs.development.js +939 -745
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +940 -746
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +4 -2
- package/dist/plugins/Break/createResetNodePlugin.d.ts +2 -0
- package/dist/plugins/Break/index.d.ts +2 -0
- package/dist/plugins/List/transforms/deleteBackwardList.d.ts +2 -0
- package/dist/plugins/List/transforms/unwrapList.d.ts +5 -0
- package/dist/plugins/Quote/shouldResetQuote.d.ts +8 -0
- package/dist/plugins/Quote/toggleQuote.d.ts +2 -2
- package/dist/plugins/Quote/withQuote.d.ts +3 -0
- package/dist/types.d.ts +5 -1
- package/package.json +2 -1
- package/CHANGELOG.md +0 -410
|
@@ -2,12 +2,13 @@ import React__default, { createContext, useContext, useMemo, createElement, useE
|
|
|
2
2
|
import { useEntities, ScheduledIconWithTooltip, MissingEntityCard, AssetThumbnail, getScheduleTooltipContent, EntityProvider } from '@contentful/field-editor-reference';
|
|
3
3
|
import { entityHelpers, shortenStorageUnit, isValidImage, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
|
|
4
4
|
import { BLOCKS, INLINES, TABLE_BLOCKS, TEXT_CONTAINERS, HEADINGS, LIST_ITEM_BLOCKS, MARKS, CONTAINERS, TOP_LEVEL_BLOCKS, VOID_BLOCKS, EMPTY_DOCUMENT } from '@contentful/rich-text-types';
|
|
5
|
-
import { usePlateEditorState, usePlateEditorRef, getNodes, toggleNodeType, getText, getAbove, setNodes, isAncestorEmpty, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, getPluginType, ELEMENT_DEFAULT, findNode, isCollapsed, isRangeAcrossBlocks, wrapNodes,
|
|
5
|
+
import { usePlateEditorState, usePlateEditorRef, getNodes, toggleNodeType, getText, getAbove, setNodes, isAncestorEmpty, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, getPluginType, ELEMENT_DEFAULT, findNode, unwrapNodes, deleteFragment, isCollapsed, isRangeAcrossBlocks, wrapNodes, isMarkActive, toggleMark, someHtmlElement, match, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, getLastChildPath, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateActions, Plate } from '@udecode/plate-core';
|
|
6
6
|
import { css, cx } from 'emotion';
|
|
7
7
|
import deepEquals from 'fast-deep-equal';
|
|
8
8
|
import noop from 'lodash-es/noop';
|
|
9
9
|
import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
|
|
10
10
|
import { createSoftBreakPlugin as createSoftBreakPlugin$1, createExitBreakPlugin as createExitBreakPlugin$1 } from '@udecode/plate-break';
|
|
11
|
+
import { createResetNodePlugin as createResetNodePlugin$1, onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
|
|
11
12
|
import isHotkey from 'is-hotkey';
|
|
12
13
|
import { Text, Element, Editor, Transforms, Range, Node, Path, Point } from 'slate';
|
|
13
14
|
import { ReactEditor, useSelected, useReadOnly, useFocused } from 'slate-react';
|
|
@@ -19,8 +20,7 @@ import { ClockIcon, AssetIcon, EmbeddedEntryBlockIcon, EmbeddedEntryInlineIcon,
|
|
|
19
20
|
import tokens from '@contentful/f36-tokens';
|
|
20
21
|
import find from 'lodash-es/find';
|
|
21
22
|
import flow from 'lodash-es/flow';
|
|
22
|
-
import { getListItemEntry, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1,
|
|
23
|
-
import { onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
|
|
23
|
+
import { getListItemEntry, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, removeFirstListItem, removeListItem, isListNested, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL, ELEMENT_LIC } from '@udecode/plate-list';
|
|
24
24
|
import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1 } from '@udecode/plate-basic-marks';
|
|
25
25
|
import isPlainObject from 'is-plain-obj';
|
|
26
26
|
import { createParagraphPlugin as createParagraphPlugin$1 } from '@udecode/plate-paragraph';
|
|
@@ -307,6 +307,33 @@ var createExitBreakPlugin = function createExitBreakPlugin() {
|
|
|
307
307
|
});
|
|
308
308
|
};
|
|
309
309
|
|
|
310
|
+
var createResetNodePlugin = function createResetNodePlugin() {
|
|
311
|
+
return createResetNodePlugin$1({
|
|
312
|
+
options: {
|
|
313
|
+
rules: []
|
|
314
|
+
},
|
|
315
|
+
then: function then(editor) {
|
|
316
|
+
var rules = editor.plugins.flatMap(function (p) {
|
|
317
|
+
return p.resetNode || [];
|
|
318
|
+
}); // set defaultType to Paragraph if not set
|
|
319
|
+
|
|
320
|
+
for (var _iterator = _createForOfIteratorHelperLoose(rules), _step; !(_step = _iterator()).done;) {
|
|
321
|
+
var rule = _step.value;
|
|
322
|
+
|
|
323
|
+
if (!rule.defaultType) {
|
|
324
|
+
rule.defaultType = BLOCKS.PARAGRAPH;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
options: {
|
|
330
|
+
rules: rules
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
|
|
310
337
|
function createDragAndDropPlugin() {
|
|
311
338
|
var DRAGGABLE_TYPES = [BLOCKS.EMBEDDED_ENTRY, BLOCKS.EMBEDDED_ASSET, BLOCKS.HR, INLINES.EMBEDDED_ENTRY];
|
|
312
339
|
/**
|
|
@@ -418,6 +445,23 @@ function moveToTheNextLine(editor) {
|
|
|
418
445
|
unit: 'line'
|
|
419
446
|
});
|
|
420
447
|
}
|
|
448
|
+
function moveToTheNextChar(editor) {
|
|
449
|
+
Transforms.move(editor, {
|
|
450
|
+
distance: 1,
|
|
451
|
+
unit: 'character'
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function insertEmptyParagraph(editor) {
|
|
455
|
+
var emptyParagraph = {
|
|
456
|
+
type: BLOCKS.PARAGRAPH,
|
|
457
|
+
children: [{
|
|
458
|
+
text: ''
|
|
459
|
+
}],
|
|
460
|
+
data: {},
|
|
461
|
+
isVoid: false
|
|
462
|
+
};
|
|
463
|
+
Transforms.insertNodes(editor, emptyParagraph);
|
|
464
|
+
}
|
|
421
465
|
function getElementFromCurrentSelection(editor) {
|
|
422
466
|
if (!editor.selection) return [];
|
|
423
467
|
return Array.from(Editor.nodes(editor, {
|
|
@@ -1069,201 +1113,197 @@ function createCommonjsModule(fn, module) {
|
|
|
1069
1113
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
1070
1114
|
}
|
|
1071
1115
|
|
|
1072
|
-
var runtime_1 = createCommonjsModule(function (module) {
|
|
1073
|
-
/**
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1116
|
+
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
1117
|
+
/**
|
|
1118
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
1119
|
+
*
|
|
1120
|
+
* This source code is licensed under the MIT license found in the
|
|
1121
|
+
* LICENSE file in the root directory of this source tree.
|
|
1122
|
+
*/
|
|
1123
|
+
var runtime = function (exports) {
|
|
1124
|
+
|
|
1125
|
+
var Op = Object.prototype;
|
|
1126
|
+
var hasOwn = Op.hasOwnProperty;
|
|
1127
|
+
var undefined$1; // More compressible than void 0.
|
|
1128
|
+
|
|
1129
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
1130
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
1131
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
1132
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1133
|
+
|
|
1134
|
+
function define(obj, key, value) {
|
|
1135
|
+
Object.defineProperty(obj, key, {
|
|
1136
|
+
value: value,
|
|
1137
|
+
enumerable: true,
|
|
1138
|
+
configurable: true,
|
|
1139
|
+
writable: true
|
|
1140
|
+
});
|
|
1141
|
+
return obj[key];
|
|
1142
|
+
}
|
|
1079
1143
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1089
|
-
|
|
1090
|
-
function define(obj, key, value) {
|
|
1091
|
-
Object.defineProperty(obj, key, {
|
|
1092
|
-
value: value,
|
|
1093
|
-
enumerable: true,
|
|
1094
|
-
configurable: true,
|
|
1095
|
-
writable: true
|
|
1096
|
-
});
|
|
1097
|
-
return obj[key];
|
|
1098
|
-
}
|
|
1099
|
-
try {
|
|
1100
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
1101
|
-
define({}, "");
|
|
1102
|
-
} catch (err) {
|
|
1103
|
-
define = function(obj, key, value) {
|
|
1104
|
-
return obj[key] = value;
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1144
|
+
try {
|
|
1145
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
1146
|
+
define({}, "");
|
|
1147
|
+
} catch (err) {
|
|
1148
|
+
define = function define(obj, key, value) {
|
|
1149
|
+
return obj[key] = value;
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1107
1152
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1153
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1154
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
1155
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
1156
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
1157
|
+
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
1158
|
+
// .throw, and .return methods.
|
|
1113
1159
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1160
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
1161
|
+
return generator;
|
|
1162
|
+
}
|
|
1117
1163
|
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1164
|
+
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
1165
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
1166
|
+
// have been (and was previously) designed to take a closure to be
|
|
1167
|
+
// invoked without arguments, but in all the cases we care about we
|
|
1168
|
+
// already have an existing method we want to call, so there's no need
|
|
1169
|
+
// to create a new function object. We can even get away with assuming
|
|
1170
|
+
// the method takes exactly one argument, since that happens to be true
|
|
1171
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
1172
|
+
// only additional allocation required is the completion record, which
|
|
1173
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
1174
|
+
|
|
1175
|
+
function tryCatch(fn, obj, arg) {
|
|
1176
|
+
try {
|
|
1177
|
+
return {
|
|
1178
|
+
type: "normal",
|
|
1179
|
+
arg: fn.call(obj, arg)
|
|
1180
|
+
};
|
|
1181
|
+
} catch (err) {
|
|
1182
|
+
return {
|
|
1183
|
+
type: "throw",
|
|
1184
|
+
arg: err
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1137
1187
|
}
|
|
1138
|
-
}
|
|
1139
1188
|
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
// Returning this object from the innerFn has the same effect as
|
|
1146
|
-
// breaking out of the dispatch switch statement.
|
|
1147
|
-
var ContinueSentinel = {};
|
|
1148
|
-
|
|
1149
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
1150
|
-
// .constructor.prototype properties for functions that return Generator
|
|
1151
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
1152
|
-
// minifier not to mangle the names of these two functions.
|
|
1153
|
-
function Generator() {}
|
|
1154
|
-
function GeneratorFunction() {}
|
|
1155
|
-
function GeneratorFunctionPrototype() {}
|
|
1156
|
-
|
|
1157
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
1158
|
-
// don't natively support it.
|
|
1159
|
-
var IteratorPrototype = {};
|
|
1160
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1161
|
-
return this;
|
|
1162
|
-
});
|
|
1189
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
1190
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
1191
|
+
var GenStateExecuting = "executing";
|
|
1192
|
+
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
1193
|
+
// breaking out of the dispatch switch statement.
|
|
1163
1194
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
1169
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
1170
|
-
// of the polyfill.
|
|
1171
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
1172
|
-
}
|
|
1195
|
+
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
1196
|
+
// .constructor.prototype properties for functions that return Generator
|
|
1197
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
1198
|
+
// minifier not to mangle the names of these two functions.
|
|
1173
1199
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
1186
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
1187
|
-
function defineIteratorMethods(prototype) {
|
|
1188
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
1189
|
-
define(prototype, method, function(arg) {
|
|
1190
|
-
return this._invoke(method, arg);
|
|
1191
|
-
});
|
|
1200
|
+
function Generator() {}
|
|
1201
|
+
|
|
1202
|
+
function GeneratorFunction() {}
|
|
1203
|
+
|
|
1204
|
+
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
1205
|
+
// don't natively support it.
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
var IteratorPrototype = {};
|
|
1209
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1210
|
+
return this;
|
|
1192
1211
|
});
|
|
1193
|
-
|
|
1212
|
+
var getProto = Object.getPrototypeOf;
|
|
1213
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1194
1214
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
// do is to check its .name property.
|
|
1201
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
1202
|
-
: false;
|
|
1203
|
-
};
|
|
1215
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
1216
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
1217
|
+
// of the polyfill.
|
|
1218
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
1219
|
+
}
|
|
1204
1220
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1221
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1222
|
+
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
1223
|
+
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
1224
|
+
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
1225
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
1226
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
1227
|
+
|
|
1228
|
+
function defineIteratorMethods(prototype) {
|
|
1229
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
1230
|
+
define(prototype, method, function (arg) {
|
|
1231
|
+
return this._invoke(method, arg);
|
|
1232
|
+
});
|
|
1233
|
+
});
|
|
1211
1234
|
}
|
|
1212
|
-
genFun.prototype = Object.create(Gp);
|
|
1213
|
-
return genFun;
|
|
1214
|
-
};
|
|
1215
1235
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
};
|
|
1236
|
+
exports.isGeneratorFunction = function (genFun) {
|
|
1237
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
1238
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
1239
|
+
// do is to check its .name property.
|
|
1240
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
1241
|
+
};
|
|
1223
1242
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
if (record.type === "throw") {
|
|
1228
|
-
reject(record.arg);
|
|
1243
|
+
exports.mark = function (genFun) {
|
|
1244
|
+
if (Object.setPrototypeOf) {
|
|
1245
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
1229
1246
|
} else {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1247
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
1248
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
genFun.prototype = Object.create(Gp);
|
|
1252
|
+
return genFun;
|
|
1253
|
+
}; // Within the body of any async function, `await x` is transformed to
|
|
1254
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
1255
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
1256
|
+
// meant to be awaited.
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
exports.awrap = function (arg) {
|
|
1260
|
+
return {
|
|
1261
|
+
__await: arg
|
|
1262
|
+
};
|
|
1263
|
+
};
|
|
1264
|
+
|
|
1265
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
1266
|
+
function invoke(method, arg, resolve, reject) {
|
|
1267
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
1268
|
+
|
|
1269
|
+
if (record.type === "throw") {
|
|
1270
|
+
reject(record.arg);
|
|
1271
|
+
} else {
|
|
1272
|
+
var result = record.arg;
|
|
1273
|
+
var value = result.value;
|
|
1274
|
+
|
|
1275
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
1276
|
+
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1277
|
+
invoke("next", value, resolve, reject);
|
|
1278
|
+
}, function (err) {
|
|
1279
|
+
invoke("throw", err, resolve, reject);
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1284
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
1285
|
+
// the .value of the Promise<{value,done}> result for the
|
|
1286
|
+
// current iteration.
|
|
1287
|
+
result.value = unwrapped;
|
|
1288
|
+
resolve(result);
|
|
1289
|
+
}, function (error) {
|
|
1290
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
1291
|
+
// into the async generator function so it can be handled there.
|
|
1292
|
+
return invoke("throw", error, resolve, reject);
|
|
1239
1293
|
});
|
|
1240
1294
|
}
|
|
1241
|
-
|
|
1242
|
-
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
1243
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
1244
|
-
// the .value of the Promise<{value,done}> result for the
|
|
1245
|
-
// current iteration.
|
|
1246
|
-
result.value = unwrapped;
|
|
1247
|
-
resolve(result);
|
|
1248
|
-
}, function(error) {
|
|
1249
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
1250
|
-
// into the async generator function so it can be handled there.
|
|
1251
|
-
return invoke("throw", error, resolve, reject);
|
|
1252
|
-
});
|
|
1253
1295
|
}
|
|
1254
|
-
}
|
|
1255
1296
|
|
|
1256
|
-
|
|
1297
|
+
var previousPromise;
|
|
1257
1298
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1299
|
+
function enqueue(method, arg) {
|
|
1300
|
+
function callInvokeWithMethodAndArg() {
|
|
1301
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
1302
|
+
invoke(method, arg, resolve, reject);
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1264
1305
|
|
|
1265
|
-
|
|
1266
|
-
// If enqueue has been called before, then we want to wait until
|
|
1306
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
1267
1307
|
// all previous Promises have been resolved before calling invoke,
|
|
1268
1308
|
// so that results are always delivered in the correct order. If
|
|
1269
1309
|
// enqueue has not been called before, then it is important to
|
|
@@ -1275,554 +1315,527 @@ var runtime = (function (exports) {
|
|
|
1275
1315
|
// execute code before the first await. Since we implement simple
|
|
1276
1316
|
// async functions in terms of async generators, it is especially
|
|
1277
1317
|
// important to get this right, even though it requires care.
|
|
1278
|
-
previousPromise ? previousPromise.then(
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1318
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
1319
|
+
// invocations of the iterator.
|
|
1320
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
1321
|
+
} // Define the unified helper method that is used to implement .next,
|
|
1322
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
this._invoke = enqueue;
|
|
1284
1326
|
}
|
|
1285
1327
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1328
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
1329
|
+
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1330
|
+
return this;
|
|
1331
|
+
});
|
|
1332
|
+
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
1333
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
1334
|
+
// the final result produced by the iterator.
|
|
1335
|
+
|
|
1336
|
+
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1337
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
1338
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1339
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
1340
|
+
: iter.next().then(function (result) {
|
|
1341
|
+
return result.done ? result.value : iter.next();
|
|
1342
|
+
});
|
|
1343
|
+
};
|
|
1290
1344
|
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
// Note that simple async functions are implemented on top of
|
|
1298
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
1299
|
-
// the final result produced by the iterator.
|
|
1300
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1301
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
1302
|
-
|
|
1303
|
-
var iter = new AsyncIterator(
|
|
1304
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
1305
|
-
PromiseImpl
|
|
1306
|
-
);
|
|
1307
|
-
|
|
1308
|
-
return exports.isGeneratorFunction(outerFn)
|
|
1309
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
1310
|
-
: iter.next().then(function(result) {
|
|
1311
|
-
return result.done ? result.value : iter.next();
|
|
1312
|
-
});
|
|
1313
|
-
};
|
|
1345
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
1346
|
+
var state = GenStateSuspendedStart;
|
|
1347
|
+
return function invoke(method, arg) {
|
|
1348
|
+
if (state === GenStateExecuting) {
|
|
1349
|
+
throw new Error("Generator is already running");
|
|
1350
|
+
}
|
|
1314
1351
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1352
|
+
if (state === GenStateCompleted) {
|
|
1353
|
+
if (method === "throw") {
|
|
1354
|
+
throw arg;
|
|
1355
|
+
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
1356
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
1317
1357
|
|
|
1318
|
-
return function invoke(method, arg) {
|
|
1319
|
-
if (state === GenStateExecuting) {
|
|
1320
|
-
throw new Error("Generator is already running");
|
|
1321
|
-
}
|
|
1322
1358
|
|
|
1323
|
-
|
|
1324
|
-
if (method === "throw") {
|
|
1325
|
-
throw arg;
|
|
1359
|
+
return doneResult();
|
|
1326
1360
|
}
|
|
1327
1361
|
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
return doneResult();
|
|
1331
|
-
}
|
|
1362
|
+
context.method = method;
|
|
1363
|
+
context.arg = arg;
|
|
1332
1364
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1365
|
+
while (true) {
|
|
1366
|
+
var delegate = context.delegate;
|
|
1335
1367
|
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1368
|
+
if (delegate) {
|
|
1369
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1370
|
+
|
|
1371
|
+
if (delegateResult) {
|
|
1372
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
1373
|
+
return delegateResult;
|
|
1374
|
+
}
|
|
1343
1375
|
}
|
|
1344
|
-
}
|
|
1345
1376
|
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1377
|
+
if (context.method === "next") {
|
|
1378
|
+
// Setting context._sent for legacy support of Babel's
|
|
1379
|
+
// function.sent implementation.
|
|
1380
|
+
context.sent = context._sent = context.arg;
|
|
1381
|
+
} else if (context.method === "throw") {
|
|
1382
|
+
if (state === GenStateSuspendedStart) {
|
|
1383
|
+
state = GenStateCompleted;
|
|
1384
|
+
throw context.arg;
|
|
1385
|
+
}
|
|
1350
1386
|
|
|
1351
|
-
|
|
1352
|
-
if (
|
|
1353
|
-
|
|
1354
|
-
throw context.arg;
|
|
1387
|
+
context.dispatchException(context.arg);
|
|
1388
|
+
} else if (context.method === "return") {
|
|
1389
|
+
context.abrupt("return", context.arg);
|
|
1355
1390
|
}
|
|
1356
1391
|
|
|
1357
|
-
|
|
1392
|
+
state = GenStateExecuting;
|
|
1393
|
+
var record = tryCatch(innerFn, self, context);
|
|
1358
1394
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1395
|
+
if (record.type === "normal") {
|
|
1396
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
1397
|
+
// GenStateExecuting and loop back for another invocation.
|
|
1398
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
1362
1399
|
|
|
1363
|
-
|
|
1400
|
+
if (record.arg === ContinueSentinel) {
|
|
1401
|
+
continue;
|
|
1402
|
+
}
|
|
1364
1403
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1404
|
+
return {
|
|
1405
|
+
value: record.arg,
|
|
1406
|
+
done: context.done
|
|
1407
|
+
};
|
|
1408
|
+
} else if (record.type === "throw") {
|
|
1409
|
+
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
1410
|
+
// context.dispatchException(context.arg) call above.
|
|
1372
1411
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1412
|
+
context.method = "throw";
|
|
1413
|
+
context.arg = record.arg;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
1418
|
+
// result, either by returning a { value, done } result from the
|
|
1419
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
1420
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
1424
|
+
var method = delegate.iterator[context.method];
|
|
1425
|
+
|
|
1426
|
+
if (method === undefined$1) {
|
|
1427
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
1428
|
+
// method always terminates the yield* loop.
|
|
1429
|
+
context.delegate = null;
|
|
1430
|
+
|
|
1431
|
+
if (context.method === "throw") {
|
|
1432
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
1433
|
+
if (delegate.iterator["return"]) {
|
|
1434
|
+
// If the delegate iterator has a return method, give it a
|
|
1435
|
+
// chance to clean up.
|
|
1436
|
+
context.method = "return";
|
|
1437
|
+
context.arg = undefined$1;
|
|
1438
|
+
maybeInvokeDelegate(delegate, context);
|
|
1439
|
+
|
|
1440
|
+
if (context.method === "throw") {
|
|
1441
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
1442
|
+
// "return" to "throw", let that override the TypeError below.
|
|
1443
|
+
return ContinueSentinel;
|
|
1444
|
+
}
|
|
1375
1445
|
}
|
|
1376
1446
|
|
|
1377
|
-
return {
|
|
1378
|
-
value: record.arg,
|
|
1379
|
-
done: context.done
|
|
1380
|
-
};
|
|
1381
|
-
|
|
1382
|
-
} else if (record.type === "throw") {
|
|
1383
|
-
state = GenStateCompleted;
|
|
1384
|
-
// Dispatch the exception by looping back around to the
|
|
1385
|
-
// context.dispatchException(context.arg) call above.
|
|
1386
1447
|
context.method = "throw";
|
|
1387
|
-
context.arg =
|
|
1448
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1388
1449
|
}
|
|
1450
|
+
|
|
1451
|
+
return ContinueSentinel;
|
|
1389
1452
|
}
|
|
1390
|
-
};
|
|
1391
|
-
}
|
|
1392
1453
|
|
|
1393
|
-
|
|
1394
|
-
// result, either by returning a { value, done } result from the
|
|
1395
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
1396
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
1397
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
1398
|
-
var method = delegate.iterator[context.method];
|
|
1399
|
-
if (method === undefined$1) {
|
|
1400
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
1401
|
-
// method always terminates the yield* loop.
|
|
1402
|
-
context.delegate = null;
|
|
1454
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1403
1455
|
|
|
1404
|
-
if (
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
context.arg = undefined$1;
|
|
1411
|
-
maybeInvokeDelegate(delegate, context);
|
|
1456
|
+
if (record.type === "throw") {
|
|
1457
|
+
context.method = "throw";
|
|
1458
|
+
context.arg = record.arg;
|
|
1459
|
+
context.delegate = null;
|
|
1460
|
+
return ContinueSentinel;
|
|
1461
|
+
}
|
|
1412
1462
|
|
|
1413
|
-
|
|
1414
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
1415
|
-
// "return" to "throw", let that override the TypeError below.
|
|
1416
|
-
return ContinueSentinel;
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1463
|
+
var info = record.arg;
|
|
1419
1464
|
|
|
1465
|
+
if (!info) {
|
|
1420
1466
|
context.method = "throw";
|
|
1421
|
-
context.arg = new TypeError(
|
|
1422
|
-
|
|
1467
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
1468
|
+
context.delegate = null;
|
|
1469
|
+
return ContinueSentinel;
|
|
1423
1470
|
}
|
|
1424
1471
|
|
|
1425
|
-
|
|
1426
|
-
|
|
1472
|
+
if (info.done) {
|
|
1473
|
+
// Assign the result of the finished delegate to the temporary
|
|
1474
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
1475
|
+
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
1427
1476
|
|
|
1428
|
-
|
|
1477
|
+
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
1478
|
+
// exception, let the outer generator proceed normally. If
|
|
1479
|
+
// context.method was "next", forget context.arg since it has been
|
|
1480
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
1481
|
+
// "return", allow the original .return call to continue in the
|
|
1482
|
+
// outer generator.
|
|
1429
1483
|
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1484
|
+
if (context.method !== "return") {
|
|
1485
|
+
context.method = "next";
|
|
1486
|
+
context.arg = undefined$1;
|
|
1487
|
+
}
|
|
1488
|
+
} else {
|
|
1489
|
+
// Re-yield the result returned by the delegate method.
|
|
1490
|
+
return info;
|
|
1491
|
+
} // The delegate iterator is finished, so forget it and continue with
|
|
1492
|
+
// the outer generator.
|
|
1436
1493
|
|
|
1437
|
-
var info = record.arg;
|
|
1438
1494
|
|
|
1439
|
-
if (! info) {
|
|
1440
|
-
context.method = "throw";
|
|
1441
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
1442
1495
|
context.delegate = null;
|
|
1443
1496
|
return ContinueSentinel;
|
|
1444
|
-
}
|
|
1497
|
+
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
1498
|
+
// unified ._invoke helper method.
|
|
1445
1499
|
|
|
1446
|
-
if (info.done) {
|
|
1447
|
-
// Assign the result of the finished delegate to the temporary
|
|
1448
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
1449
|
-
context[delegate.resultName] = info.value;
|
|
1450
|
-
|
|
1451
|
-
// Resume execution at the desired location (see delegateYield).
|
|
1452
|
-
context.next = delegate.nextLoc;
|
|
1453
|
-
|
|
1454
|
-
// If context.method was "throw" but the delegate handled the
|
|
1455
|
-
// exception, let the outer generator proceed normally. If
|
|
1456
|
-
// context.method was "next", forget context.arg since it has been
|
|
1457
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
1458
|
-
// "return", allow the original .return call to continue in the
|
|
1459
|
-
// outer generator.
|
|
1460
|
-
if (context.method !== "return") {
|
|
1461
|
-
context.method = "next";
|
|
1462
|
-
context.arg = undefined$1;
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
} else {
|
|
1466
|
-
// Re-yield the result returned by the delegate method.
|
|
1467
|
-
return info;
|
|
1468
|
-
}
|
|
1469
1500
|
|
|
1470
|
-
|
|
1471
|
-
// the
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
1477
|
-
// unified ._invoke helper method.
|
|
1478
|
-
defineIteratorMethods(Gp);
|
|
1501
|
+
defineIteratorMethods(Gp);
|
|
1502
|
+
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
1503
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
1504
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
1505
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
1506
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1479
1507
|
|
|
1480
|
-
|
|
1508
|
+
define(Gp, iteratorSymbol, function () {
|
|
1509
|
+
return this;
|
|
1510
|
+
});
|
|
1511
|
+
define(Gp, "toString", function () {
|
|
1512
|
+
return "[object Generator]";
|
|
1513
|
+
});
|
|
1481
1514
|
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1487
|
-
define(Gp, iteratorSymbol, function() {
|
|
1488
|
-
return this;
|
|
1489
|
-
});
|
|
1515
|
+
function pushTryEntry(locs) {
|
|
1516
|
+
var entry = {
|
|
1517
|
+
tryLoc: locs[0]
|
|
1518
|
+
};
|
|
1490
1519
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1520
|
+
if (1 in locs) {
|
|
1521
|
+
entry.catchLoc = locs[1];
|
|
1522
|
+
}
|
|
1494
1523
|
|
|
1495
|
-
|
|
1496
|
-
|
|
1524
|
+
if (2 in locs) {
|
|
1525
|
+
entry.finallyLoc = locs[2];
|
|
1526
|
+
entry.afterLoc = locs[3];
|
|
1527
|
+
}
|
|
1497
1528
|
|
|
1498
|
-
|
|
1499
|
-
entry.catchLoc = locs[1];
|
|
1529
|
+
this.tryEntries.push(entry);
|
|
1500
1530
|
}
|
|
1501
1531
|
|
|
1502
|
-
|
|
1503
|
-
entry.
|
|
1504
|
-
|
|
1532
|
+
function resetTryEntry(entry) {
|
|
1533
|
+
var record = entry.completion || {};
|
|
1534
|
+
record.type = "normal";
|
|
1535
|
+
delete record.arg;
|
|
1536
|
+
entry.completion = record;
|
|
1505
1537
|
}
|
|
1506
1538
|
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
function Context(tryLocsList) {
|
|
1518
|
-
// The root entry object (effectively a try statement without a catch
|
|
1519
|
-
// or a finally block) gives us a place to store values thrown from
|
|
1520
|
-
// locations where there is no enclosing try statement.
|
|
1521
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
1522
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
1523
|
-
this.reset(true);
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
exports.keys = function(object) {
|
|
1527
|
-
var keys = [];
|
|
1528
|
-
for (var key in object) {
|
|
1529
|
-
keys.push(key);
|
|
1539
|
+
function Context(tryLocsList) {
|
|
1540
|
+
// The root entry object (effectively a try statement without a catch
|
|
1541
|
+
// or a finally block) gives us a place to store values thrown from
|
|
1542
|
+
// locations where there is no enclosing try statement.
|
|
1543
|
+
this.tryEntries = [{
|
|
1544
|
+
tryLoc: "root"
|
|
1545
|
+
}];
|
|
1546
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
1547
|
+
this.reset(true);
|
|
1530
1548
|
}
|
|
1531
|
-
keys.reverse();
|
|
1532
|
-
|
|
1533
|
-
// Rather than returning an object with a next method, we keep
|
|
1534
|
-
// things simple and return the next function itself.
|
|
1535
|
-
return function next() {
|
|
1536
|
-
while (keys.length) {
|
|
1537
|
-
var key = keys.pop();
|
|
1538
|
-
if (key in object) {
|
|
1539
|
-
next.value = key;
|
|
1540
|
-
next.done = false;
|
|
1541
|
-
return next;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
1549
|
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
// also ensures that the minifier will not anonymize the function.
|
|
1548
|
-
next.done = true;
|
|
1549
|
-
return next;
|
|
1550
|
-
};
|
|
1551
|
-
};
|
|
1550
|
+
exports.keys = function (object) {
|
|
1551
|
+
var keys = [];
|
|
1552
1552
|
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
1556
|
-
if (iteratorMethod) {
|
|
1557
|
-
return iteratorMethod.call(iterable);
|
|
1553
|
+
for (var key in object) {
|
|
1554
|
+
keys.push(key);
|
|
1558
1555
|
}
|
|
1559
1556
|
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
}
|
|
1557
|
+
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
1558
|
+
// things simple and return the next function itself.
|
|
1563
1559
|
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
if (hasOwn.call(iterable, i)) {
|
|
1568
|
-
next.value = iterable[i];
|
|
1569
|
-
next.done = false;
|
|
1570
|
-
return next;
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1560
|
+
return function next() {
|
|
1561
|
+
while (keys.length) {
|
|
1562
|
+
var key = keys.pop();
|
|
1573
1563
|
|
|
1574
|
-
|
|
1575
|
-
|
|
1564
|
+
if (key in object) {
|
|
1565
|
+
next.value = key;
|
|
1566
|
+
next.done = false;
|
|
1567
|
+
return next;
|
|
1568
|
+
}
|
|
1569
|
+
} // To avoid creating an additional object, we just hang the .value
|
|
1570
|
+
// and .done properties off the next function object itself. This
|
|
1571
|
+
// also ensures that the minifier will not anonymize the function.
|
|
1576
1572
|
|
|
1577
|
-
return next;
|
|
1578
|
-
};
|
|
1579
1573
|
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1574
|
+
next.done = true;
|
|
1575
|
+
return next;
|
|
1576
|
+
};
|
|
1577
|
+
};
|
|
1583
1578
|
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
exports.values = values;
|
|
1579
|
+
function values(iterable) {
|
|
1580
|
+
if (iterable) {
|
|
1581
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1588
1582
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1583
|
+
if (iteratorMethod) {
|
|
1584
|
+
return iteratorMethod.call(iterable);
|
|
1585
|
+
}
|
|
1592
1586
|
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
reset: function(skipTempReset) {
|
|
1597
|
-
this.prev = 0;
|
|
1598
|
-
this.next = 0;
|
|
1599
|
-
// Resetting context._sent for legacy support of Babel's
|
|
1600
|
-
// function.sent implementation.
|
|
1601
|
-
this.sent = this._sent = undefined$1;
|
|
1602
|
-
this.done = false;
|
|
1603
|
-
this.delegate = null;
|
|
1604
|
-
|
|
1605
|
-
this.method = "next";
|
|
1606
|
-
this.arg = undefined$1;
|
|
1607
|
-
|
|
1608
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
1609
|
-
|
|
1610
|
-
if (!skipTempReset) {
|
|
1611
|
-
for (var name in this) {
|
|
1612
|
-
// Not sure about the optimal order of these conditions:
|
|
1613
|
-
if (name.charAt(0) === "t" &&
|
|
1614
|
-
hasOwn.call(this, name) &&
|
|
1615
|
-
!isNaN(+name.slice(1))) {
|
|
1616
|
-
this[name] = undefined$1;
|
|
1617
|
-
}
|
|
1587
|
+
if (typeof iterable.next === "function") {
|
|
1588
|
+
return iterable;
|
|
1618
1589
|
}
|
|
1619
|
-
}
|
|
1620
|
-
},
|
|
1621
1590
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1591
|
+
if (!isNaN(iterable.length)) {
|
|
1592
|
+
var i = -1,
|
|
1593
|
+
next = function next() {
|
|
1594
|
+
while (++i < iterable.length) {
|
|
1595
|
+
if (hasOwn.call(iterable, i)) {
|
|
1596
|
+
next.value = iterable[i];
|
|
1597
|
+
next.done = false;
|
|
1598
|
+
return next;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1624
1601
|
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
}
|
|
1602
|
+
next.value = undefined$1;
|
|
1603
|
+
next.done = true;
|
|
1604
|
+
return next;
|
|
1605
|
+
};
|
|
1630
1606
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1607
|
+
return next.next = next;
|
|
1608
|
+
}
|
|
1609
|
+
} // Return an iterator with no values.
|
|
1633
1610
|
|
|
1634
|
-
dispatchException: function(exception) {
|
|
1635
|
-
if (this.done) {
|
|
1636
|
-
throw exception;
|
|
1637
|
-
}
|
|
1638
1611
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1612
|
+
return {
|
|
1613
|
+
next: doneResult
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
exports.values = values;
|
|
1644
1618
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1619
|
+
function doneResult() {
|
|
1620
|
+
return {
|
|
1621
|
+
value: undefined$1,
|
|
1622
|
+
done: true
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1651
1625
|
|
|
1652
|
-
|
|
1653
|
-
|
|
1626
|
+
Context.prototype = {
|
|
1627
|
+
constructor: Context,
|
|
1628
|
+
reset: function reset(skipTempReset) {
|
|
1629
|
+
this.prev = 0;
|
|
1630
|
+
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
1631
|
+
// function.sent implementation.
|
|
1654
1632
|
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1633
|
+
this.sent = this._sent = undefined$1;
|
|
1634
|
+
this.done = false;
|
|
1635
|
+
this.delegate = null;
|
|
1636
|
+
this.method = "next";
|
|
1637
|
+
this.arg = undefined$1;
|
|
1638
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
1658
1639
|
|
|
1659
|
-
if (
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1640
|
+
if (!skipTempReset) {
|
|
1641
|
+
for (var name in this) {
|
|
1642
|
+
// Not sure about the optimal order of these conditions:
|
|
1643
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
1644
|
+
this[name] = undefined$1;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1664
1647
|
}
|
|
1648
|
+
},
|
|
1649
|
+
stop: function stop() {
|
|
1650
|
+
this.done = true;
|
|
1651
|
+
var rootEntry = this.tryEntries[0];
|
|
1652
|
+
var rootRecord = rootEntry.completion;
|
|
1665
1653
|
|
|
1666
|
-
if (
|
|
1667
|
-
|
|
1668
|
-
|
|
1654
|
+
if (rootRecord.type === "throw") {
|
|
1655
|
+
throw rootRecord.arg;
|
|
1656
|
+
}
|
|
1669
1657
|
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1658
|
+
return this.rval;
|
|
1659
|
+
},
|
|
1660
|
+
dispatchException: function dispatchException(exception) {
|
|
1661
|
+
if (this.done) {
|
|
1662
|
+
throw exception;
|
|
1663
|
+
}
|
|
1676
1664
|
|
|
1677
|
-
|
|
1678
|
-
if (this.prev < entry.catchLoc) {
|
|
1679
|
-
return handle(entry.catchLoc, true);
|
|
1680
|
-
}
|
|
1665
|
+
var context = this;
|
|
1681
1666
|
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1667
|
+
function handle(loc, caught) {
|
|
1668
|
+
record.type = "throw";
|
|
1669
|
+
record.arg = exception;
|
|
1670
|
+
context.next = loc;
|
|
1686
1671
|
|
|
1687
|
-
|
|
1688
|
-
|
|
1672
|
+
if (caught) {
|
|
1673
|
+
// If the dispatched exception was caught by a catch block,
|
|
1674
|
+
// then let that catch block handle the exception normally.
|
|
1675
|
+
context.method = "next";
|
|
1676
|
+
context.arg = undefined$1;
|
|
1689
1677
|
}
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
},
|
|
1693
1678
|
|
|
1694
|
-
|
|
1695
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1696
|
-
var entry = this.tryEntries[i];
|
|
1697
|
-
if (entry.tryLoc <= this.prev &&
|
|
1698
|
-
hasOwn.call(entry, "finallyLoc") &&
|
|
1699
|
-
this.prev < entry.finallyLoc) {
|
|
1700
|
-
var finallyEntry = entry;
|
|
1701
|
-
break;
|
|
1679
|
+
return !!caught;
|
|
1702
1680
|
}
|
|
1703
|
-
}
|
|
1704
1681
|
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
finallyEntry.tryLoc <= arg &&
|
|
1709
|
-
arg <= finallyEntry.finallyLoc) {
|
|
1710
|
-
// Ignore the finally entry if control is not jumping to a
|
|
1711
|
-
// location outside the try/catch block.
|
|
1712
|
-
finallyEntry = null;
|
|
1713
|
-
}
|
|
1682
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1683
|
+
var entry = this.tryEntries[i];
|
|
1684
|
+
var record = entry.completion;
|
|
1714
1685
|
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1686
|
+
if (entry.tryLoc === "root") {
|
|
1687
|
+
// Exception thrown outside of any try block that could handle
|
|
1688
|
+
// it, so set the completion value of the entire function to
|
|
1689
|
+
// throw the exception.
|
|
1690
|
+
return handle("end");
|
|
1691
|
+
}
|
|
1718
1692
|
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
return ContinueSentinel;
|
|
1723
|
-
}
|
|
1693
|
+
if (entry.tryLoc <= this.prev) {
|
|
1694
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1695
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1724
1696
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1697
|
+
if (hasCatch && hasFinally) {
|
|
1698
|
+
if (this.prev < entry.catchLoc) {
|
|
1699
|
+
return handle(entry.catchLoc, true);
|
|
1700
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
1701
|
+
return handle(entry.finallyLoc);
|
|
1702
|
+
}
|
|
1703
|
+
} else if (hasCatch) {
|
|
1704
|
+
if (this.prev < entry.catchLoc) {
|
|
1705
|
+
return handle(entry.catchLoc, true);
|
|
1706
|
+
}
|
|
1707
|
+
} else if (hasFinally) {
|
|
1708
|
+
if (this.prev < entry.finallyLoc) {
|
|
1709
|
+
return handle(entry.finallyLoc);
|
|
1710
|
+
}
|
|
1711
|
+
} else {
|
|
1712
|
+
throw new Error("try statement without catch or finally");
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
abrupt: function abrupt(type, arg) {
|
|
1718
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1719
|
+
var entry = this.tryEntries[i];
|
|
1727
1720
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1721
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1722
|
+
var finallyEntry = entry;
|
|
1723
|
+
break;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1732
1726
|
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
this.method = "return";
|
|
1739
|
-
this.next = "end";
|
|
1740
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
1741
|
-
this.next = afterLoc;
|
|
1742
|
-
}
|
|
1727
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
1728
|
+
// Ignore the finally entry if control is not jumping to a
|
|
1729
|
+
// location outside the try/catch block.
|
|
1730
|
+
finallyEntry = null;
|
|
1731
|
+
}
|
|
1743
1732
|
|
|
1744
|
-
|
|
1745
|
-
|
|
1733
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1734
|
+
record.type = type;
|
|
1735
|
+
record.arg = arg;
|
|
1746
1736
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
1751
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
1752
|
-
resetTryEntry(entry);
|
|
1737
|
+
if (finallyEntry) {
|
|
1738
|
+
this.method = "next";
|
|
1739
|
+
this.next = finallyEntry.finallyLoc;
|
|
1753
1740
|
return ContinueSentinel;
|
|
1754
1741
|
}
|
|
1755
|
-
}
|
|
1756
|
-
},
|
|
1757
1742
|
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
if (
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1743
|
+
return this.complete(record);
|
|
1744
|
+
},
|
|
1745
|
+
complete: function complete(record, afterLoc) {
|
|
1746
|
+
if (record.type === "throw") {
|
|
1747
|
+
throw record.arg;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
if (record.type === "break" || record.type === "continue") {
|
|
1751
|
+
this.next = record.arg;
|
|
1752
|
+
} else if (record.type === "return") {
|
|
1753
|
+
this.rval = this.arg = record.arg;
|
|
1754
|
+
this.method = "return";
|
|
1755
|
+
this.next = "end";
|
|
1756
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
1757
|
+
this.next = afterLoc;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
return ContinueSentinel;
|
|
1761
|
+
},
|
|
1762
|
+
finish: function finish(finallyLoc) {
|
|
1763
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1764
|
+
var entry = this.tryEntries[i];
|
|
1765
|
+
|
|
1766
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
1767
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
1765
1768
|
resetTryEntry(entry);
|
|
1769
|
+
return ContinueSentinel;
|
|
1766
1770
|
}
|
|
1767
|
-
return thrown;
|
|
1768
1771
|
}
|
|
1769
|
-
}
|
|
1772
|
+
},
|
|
1773
|
+
"catch": function _catch(tryLoc) {
|
|
1774
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1775
|
+
var entry = this.tryEntries[i];
|
|
1770
1776
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
throw new Error("illegal catch attempt");
|
|
1774
|
-
},
|
|
1777
|
+
if (entry.tryLoc === tryLoc) {
|
|
1778
|
+
var record = entry.completion;
|
|
1775
1779
|
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
nextLoc: nextLoc
|
|
1781
|
-
};
|
|
1780
|
+
if (record.type === "throw") {
|
|
1781
|
+
var thrown = record.arg;
|
|
1782
|
+
resetTryEntry(entry);
|
|
1783
|
+
}
|
|
1782
1784
|
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
//
|
|
1786
|
-
|
|
1787
|
-
}
|
|
1785
|
+
return thrown;
|
|
1786
|
+
}
|
|
1787
|
+
} // The context.catch method must only be called with a location
|
|
1788
|
+
// argument that corresponds to a known catch block.
|
|
1788
1789
|
|
|
1789
|
-
return ContinueSentinel;
|
|
1790
|
-
}
|
|
1791
|
-
};
|
|
1792
1790
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1791
|
+
throw new Error("illegal catch attempt");
|
|
1792
|
+
},
|
|
1793
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1794
|
+
this.delegate = {
|
|
1795
|
+
iterator: values(iterable),
|
|
1796
|
+
resultName: resultName,
|
|
1797
|
+
nextLoc: nextLoc
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
if (this.method === "next") {
|
|
1801
|
+
// Deliberately forget the last sent value so that we don't
|
|
1802
|
+
// accidentally pass it on to the delegate.
|
|
1803
|
+
this.arg = undefined$1;
|
|
1804
|
+
}
|
|
1798
1805
|
|
|
1799
|
-
|
|
1800
|
-
|
|
1806
|
+
return ContinueSentinel;
|
|
1807
|
+
}
|
|
1808
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1809
|
+
// or not, return the runtime object so that we can declare the variable
|
|
1810
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1811
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1812
|
+
|
|
1813
|
+
return exports;
|
|
1814
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1801
1815
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1802
1816
|
// object. Either way, the resulting object will be used to initialize
|
|
1803
1817
|
// the regeneratorRuntime variable at the top of this file.
|
|
1804
|
-
module.exports
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1818
|
+
module.exports );
|
|
1819
|
+
|
|
1820
|
+
try {
|
|
1821
|
+
regeneratorRuntime = runtime;
|
|
1822
|
+
} catch (accidentalStrictMode) {
|
|
1823
|
+
// This module should not be running in strict mode, so the above
|
|
1824
|
+
// assignment should always work unless something is misconfigured. Just
|
|
1825
|
+
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
1826
|
+
// we can explicitly access globalThis. In older engines we can escape
|
|
1827
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
1828
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
1829
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
1830
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
1831
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1832
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
1833
|
+
if (typeof globalThis === "object") {
|
|
1834
|
+
globalThis.regeneratorRuntime = runtime;
|
|
1835
|
+
} else {
|
|
1836
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1837
|
+
}
|
|
1824
1838
|
}
|
|
1825
|
-
}
|
|
1826
1839
|
});
|
|
1827
1840
|
|
|
1828
1841
|
/* eslint-disable you-dont-need-lodash-underscore/find */
|
|
@@ -1936,11 +1949,12 @@ function _selectEntityAndInsert() {
|
|
|
1936
1949
|
case 12:
|
|
1937
1950
|
Transforms.select(editor, selection);
|
|
1938
1951
|
insertBlock(editor, nodeType, entity);
|
|
1952
|
+
ensureFollowingParagraph(editor);
|
|
1939
1953
|
logAction('insert', {
|
|
1940
1954
|
nodeType: nodeType
|
|
1941
1955
|
});
|
|
1942
1956
|
|
|
1943
|
-
case
|
|
1957
|
+
case 16:
|
|
1944
1958
|
case "end":
|
|
1945
1959
|
return _context.stop();
|
|
1946
1960
|
}
|
|
@@ -1950,6 +1964,43 @@ function _selectEntityAndInsert() {
|
|
|
1950
1964
|
return _selectEntityAndInsert.apply(this, arguments);
|
|
1951
1965
|
}
|
|
1952
1966
|
|
|
1967
|
+
function ensureFollowingParagraph(editor) {
|
|
1968
|
+
/*
|
|
1969
|
+
If the new block isn't followed by a sibling paragraph we insert a new empty one
|
|
1970
|
+
*/
|
|
1971
|
+
var next = Editor.next(editor);
|
|
1972
|
+
|
|
1973
|
+
if (!next) {
|
|
1974
|
+
return insertEmptyParagraph(editor);
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
var parent = Editor.above(editor, {
|
|
1978
|
+
voids: false,
|
|
1979
|
+
match: function match(e) {
|
|
1980
|
+
return !Element.isElement(e) || ![BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY].includes(e.type);
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
|
|
1984
|
+
if (Editor.isEditor(parent)) {
|
|
1985
|
+
// at level 0, a following paragraph is handled by the tralingParagraph plugin
|
|
1986
|
+
moveToTheNextChar(editor);
|
|
1987
|
+
return;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
var paragraph = Editor.above(editor, {
|
|
1991
|
+
at: next[1],
|
|
1992
|
+
match: function match(e) {
|
|
1993
|
+
return Element.isElement(e) && TEXT_CONTAINERS.includes(e.type);
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
|
|
1997
|
+
if (!paragraph || !parent || !Path.isChild(paragraph[1], parent[1])) {
|
|
1998
|
+
return insertEmptyParagraph(editor);
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
moveToTheNextChar(editor);
|
|
2002
|
+
}
|
|
2003
|
+
|
|
1953
2004
|
var createNode = function createNode(nodeType, entity) {
|
|
1954
2005
|
return {
|
|
1955
2006
|
type: nodeType,
|
|
@@ -1997,11 +2048,29 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
1997
2048
|
var editor = useContentfulEditor();
|
|
1998
2049
|
var sdk = useSdkContext();
|
|
1999
2050
|
|
|
2000
|
-
var handleClick = function
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2051
|
+
var handleClick = /*#__PURE__*/function () {
|
|
2052
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(event) {
|
|
2053
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2054
|
+
while (1) {
|
|
2055
|
+
switch (_context.prev = _context.next) {
|
|
2056
|
+
case 0:
|
|
2057
|
+
event.preventDefault();
|
|
2058
|
+
onClose();
|
|
2059
|
+
_context.next = 4;
|
|
2060
|
+
return selectEntityAndInsert(nodeType, sdk, editor, editor.tracking.onToolbarAction);
|
|
2061
|
+
|
|
2062
|
+
case 4:
|
|
2063
|
+
case "end":
|
|
2064
|
+
return _context.stop();
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}, _callee);
|
|
2068
|
+
}));
|
|
2069
|
+
|
|
2070
|
+
return function handleClick(_x) {
|
|
2071
|
+
return _ref2.apply(this, arguments);
|
|
2072
|
+
};
|
|
2073
|
+
}();
|
|
2005
2074
|
|
|
2006
2075
|
var type = getEntityTypeFromNodeType(nodeType);
|
|
2007
2076
|
var baseClass = "rich-text__" + nodeType;
|
|
@@ -2334,15 +2403,18 @@ function _selectEntityAndInsert$1() {
|
|
|
2334
2403
|
return _context2.abrupt("return");
|
|
2335
2404
|
|
|
2336
2405
|
case 10:
|
|
2337
|
-
inlineEntryNode = createInlineEntryNode(entry.sys.id);
|
|
2338
|
-
|
|
2339
|
-
setTimeout(function () {
|
|
2340
|
-
Transforms.setSelection(editor, selection);
|
|
2341
|
-
Transforms.insertNodes(editor, inlineEntryNode);
|
|
2342
|
-
}, 0);
|
|
2406
|
+
inlineEntryNode = createInlineEntryNode(entry.sys.id);
|
|
2343
2407
|
logAction('insert', {
|
|
2344
2408
|
nodeType: INLINES.EMBEDDED_ENTRY
|
|
2345
|
-
});
|
|
2409
|
+
}); // Got to wait until focus is really back on the editor or setSelection() won't work.
|
|
2410
|
+
|
|
2411
|
+
return _context2.abrupt("return", new Promise(function (resolve) {
|
|
2412
|
+
setTimeout(function () {
|
|
2413
|
+
Transforms.setSelection(editor, selection);
|
|
2414
|
+
Transforms.insertNodes(editor, inlineEntryNode);
|
|
2415
|
+
resolve();
|
|
2416
|
+
}, 0);
|
|
2417
|
+
}));
|
|
2346
2418
|
|
|
2347
2419
|
case 13:
|
|
2348
2420
|
case "end":
|
|
@@ -2383,6 +2455,9 @@ function ToolbarEmbeddedEntityInlineButton(props) {
|
|
|
2383
2455
|
return selectEntityAndInsert$1(editor, sdk, editor.tracking.onToolbarAction);
|
|
2384
2456
|
|
|
2385
2457
|
case 6:
|
|
2458
|
+
moveToTheNextChar(editor);
|
|
2459
|
+
|
|
2460
|
+
case 7:
|
|
2386
2461
|
case "end":
|
|
2387
2462
|
return _context.stop();
|
|
2388
2463
|
}
|
|
@@ -4047,6 +4122,101 @@ var insertListFragment = function insertListFragment(editor) {
|
|
|
4047
4122
|
};
|
|
4048
4123
|
};
|
|
4049
4124
|
|
|
4125
|
+
/**
|
|
4126
|
+
* Credit: Modified version of Plate's list plugin
|
|
4127
|
+
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4128
|
+
*/
|
|
4129
|
+
var listTypes = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4130
|
+
var unwrapList = function unwrapList(editor, _temp) {
|
|
4131
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
4132
|
+
at = _ref.at;
|
|
4133
|
+
|
|
4134
|
+
Editor.withoutNormalizing(editor, function () {
|
|
4135
|
+
do {
|
|
4136
|
+
unwrapNodes(editor, {
|
|
4137
|
+
at: at,
|
|
4138
|
+
match: {
|
|
4139
|
+
type: BLOCKS.LIST_ITEM
|
|
4140
|
+
},
|
|
4141
|
+
split: true
|
|
4142
|
+
});
|
|
4143
|
+
unwrapNodes(editor, {
|
|
4144
|
+
at: at,
|
|
4145
|
+
match: {
|
|
4146
|
+
type: listTypes
|
|
4147
|
+
},
|
|
4148
|
+
split: true
|
|
4149
|
+
});
|
|
4150
|
+
} while (getAbove(editor, {
|
|
4151
|
+
match: {
|
|
4152
|
+
type: listTypes,
|
|
4153
|
+
at: at
|
|
4154
|
+
}
|
|
4155
|
+
}));
|
|
4156
|
+
});
|
|
4157
|
+
};
|
|
4158
|
+
|
|
4159
|
+
/**
|
|
4160
|
+
* Credit: Modified version of Plate's list plugin
|
|
4161
|
+
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4162
|
+
*/
|
|
4163
|
+
var deleteBackwardList = function deleteBackwardList(editor, unit) {
|
|
4164
|
+
var res = getListItemEntry(editor, {});
|
|
4165
|
+
var moved = false;
|
|
4166
|
+
|
|
4167
|
+
if (res) {
|
|
4168
|
+
var list = res.list,
|
|
4169
|
+
listItem = res.listItem;
|
|
4170
|
+
|
|
4171
|
+
if (isSelectionAtBlockStart(editor, {
|
|
4172
|
+
match: function match(node) {
|
|
4173
|
+
return node.type === BLOCKS.LIST_ITEM;
|
|
4174
|
+
}
|
|
4175
|
+
})) {
|
|
4176
|
+
Editor.withoutNormalizing(editor, function () {
|
|
4177
|
+
moved = removeFirstListItem(editor, {
|
|
4178
|
+
list: list,
|
|
4179
|
+
listItem: listItem
|
|
4180
|
+
});
|
|
4181
|
+
if (moved) return;
|
|
4182
|
+
moved = removeListItem(editor, {
|
|
4183
|
+
list: list,
|
|
4184
|
+
listItem: listItem
|
|
4185
|
+
});
|
|
4186
|
+
if (moved) return;
|
|
4187
|
+
|
|
4188
|
+
if (isFirstChild(listItem[1]) && !isListNested(editor, list[1])) {
|
|
4189
|
+
onKeyDownResetNode(editor, mockPlugin({
|
|
4190
|
+
options: {
|
|
4191
|
+
rules: [{
|
|
4192
|
+
types: [BLOCKS.LIST_ITEM],
|
|
4193
|
+
defaultType: BLOCKS.PARAGRAPH,
|
|
4194
|
+
hotkey: 'backspace',
|
|
4195
|
+
predicate: function predicate() {
|
|
4196
|
+
return isSelectionAtBlockStart(editor);
|
|
4197
|
+
},
|
|
4198
|
+
onReset: function onReset(e) {
|
|
4199
|
+
return unwrapList(e);
|
|
4200
|
+
}
|
|
4201
|
+
}]
|
|
4202
|
+
}
|
|
4203
|
+
}))(SIMULATE_BACKSPACE);
|
|
4204
|
+
moved = true;
|
|
4205
|
+
return;
|
|
4206
|
+
}
|
|
4207
|
+
|
|
4208
|
+
deleteFragment(editor, {
|
|
4209
|
+
unit: unit,
|
|
4210
|
+
reverse: true
|
|
4211
|
+
});
|
|
4212
|
+
moved = true;
|
|
4213
|
+
});
|
|
4214
|
+
}
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4217
|
+
return moved;
|
|
4218
|
+
};
|
|
4219
|
+
|
|
4050
4220
|
/**
|
|
4051
4221
|
* Credit: Modified version of Plate's list plugin
|
|
4052
4222
|
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
@@ -4124,39 +4294,9 @@ var createListPlugin = function createListPlugin() {
|
|
|
4124
4294
|
});
|
|
4125
4295
|
};
|
|
4126
4296
|
|
|
4127
|
-
var listTypes = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4128
|
-
|
|
4129
|
-
var
|
|
4130
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
4131
|
-
at = _ref.at;
|
|
4132
|
-
|
|
4133
|
-
Editor.withoutNormalizing(editor, function () {
|
|
4134
|
-
do {
|
|
4135
|
-
unwrapNodes(editor, {
|
|
4136
|
-
at: at,
|
|
4137
|
-
match: {
|
|
4138
|
-
type: BLOCKS.LIST_ITEM
|
|
4139
|
-
},
|
|
4140
|
-
split: true
|
|
4141
|
-
});
|
|
4142
|
-
unwrapNodes(editor, {
|
|
4143
|
-
at: at,
|
|
4144
|
-
match: {
|
|
4145
|
-
type: listTypes
|
|
4146
|
-
},
|
|
4147
|
-
split: true
|
|
4148
|
-
});
|
|
4149
|
-
} while (getAbove(editor, {
|
|
4150
|
-
match: {
|
|
4151
|
-
type: listTypes,
|
|
4152
|
-
at: at
|
|
4153
|
-
}
|
|
4154
|
-
}));
|
|
4155
|
-
});
|
|
4156
|
-
};
|
|
4157
|
-
|
|
4158
|
-
var toggleList = function toggleList(editor, _ref2) {
|
|
4159
|
-
var type = _ref2.type;
|
|
4297
|
+
var listTypes$1 = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4298
|
+
var toggleList = function toggleList(editor, _ref) {
|
|
4299
|
+
var type = _ref.type;
|
|
4160
4300
|
return Editor.withoutNormalizing(editor, function () {
|
|
4161
4301
|
if (!editor.selection) {
|
|
4162
4302
|
return;
|
|
@@ -4175,7 +4315,7 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4175
4315
|
}, {
|
|
4176
4316
|
at: editor.selection,
|
|
4177
4317
|
match: function match(n) {
|
|
4178
|
-
return listTypes.includes(n.type);
|
|
4318
|
+
return listTypes$1.includes(n.type);
|
|
4179
4319
|
},
|
|
4180
4320
|
mode: 'lowest'
|
|
4181
4321
|
});
|
|
@@ -4216,19 +4356,19 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4216
4356
|
|
|
4217
4357
|
var commonEntry = Node.common(editor, startPoint.path, endPoint.path);
|
|
4218
4358
|
|
|
4219
|
-
if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === BLOCKS.LIST_ITEM) {
|
|
4359
|
+
if (listTypes$1.includes(commonEntry[0].type) || commonEntry[0].type === BLOCKS.LIST_ITEM) {
|
|
4220
4360
|
if (commonEntry[0].type !== type) {
|
|
4221
4361
|
var startList = findNode(editor, {
|
|
4222
4362
|
at: Range.start(editor.selection),
|
|
4223
4363
|
match: {
|
|
4224
|
-
type: listTypes
|
|
4364
|
+
type: listTypes$1
|
|
4225
4365
|
},
|
|
4226
4366
|
mode: 'lowest'
|
|
4227
4367
|
});
|
|
4228
4368
|
var endList = findNode(editor, {
|
|
4229
4369
|
at: Range.end(editor.selection),
|
|
4230
4370
|
match: {
|
|
4231
|
-
type: listTypes
|
|
4371
|
+
type: listTypes$1
|
|
4232
4372
|
},
|
|
4233
4373
|
mode: 'lowest'
|
|
4234
4374
|
});
|
|
@@ -4243,7 +4383,7 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4243
4383
|
}, {
|
|
4244
4384
|
at: editor.selection,
|
|
4245
4385
|
match: function match(n, path) {
|
|
4246
|
-
return listTypes.includes(n.type) && path.length >= rangeLength;
|
|
4386
|
+
return listTypes$1.includes(n.type) && path.length >= rangeLength;
|
|
4247
4387
|
},
|
|
4248
4388
|
mode: 'all'
|
|
4249
4389
|
});
|
|
@@ -4255,13 +4395,13 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4255
4395
|
|
|
4256
4396
|
var _nodes = Array.from(getNodes(editor, {
|
|
4257
4397
|
mode: 'all'
|
|
4258
|
-
})).filter(function (
|
|
4259
|
-
var path =
|
|
4398
|
+
})).filter(function (_ref2) {
|
|
4399
|
+
var path = _ref2[1];
|
|
4260
4400
|
return path.length === rootPathLength + 1;
|
|
4261
4401
|
}).reverse();
|
|
4262
4402
|
|
|
4263
4403
|
_nodes.forEach(function (n) {
|
|
4264
|
-
if (listTypes.includes(n[0].type)) {
|
|
4404
|
+
if (listTypes$1.includes(n[0].type)) {
|
|
4265
4405
|
setNodes(editor, {
|
|
4266
4406
|
type: type
|
|
4267
4407
|
}, {
|
|
@@ -4977,10 +5117,51 @@ function Quote(props) {
|
|
|
4977
5117
|
}), props.children);
|
|
4978
5118
|
}
|
|
4979
5119
|
|
|
5120
|
+
/**
|
|
5121
|
+
* Returns true if we are:
|
|
5122
|
+
* 1) Inside a blockquote
|
|
5123
|
+
* 2) With no only one child paragraph/heading and
|
|
5124
|
+
* 3) that child is empty
|
|
5125
|
+
*/
|
|
5126
|
+
|
|
5127
|
+
var shouldResetQuoteOnBackspace = function shouldResetQuoteOnBackspace(editor) {
|
|
5128
|
+
var container = getAbove(editor, {
|
|
5129
|
+
match: {
|
|
5130
|
+
type: TEXT_CONTAINERS
|
|
5131
|
+
},
|
|
5132
|
+
mode: 'lowest'
|
|
5133
|
+
});
|
|
5134
|
+
|
|
5135
|
+
if (!container) {
|
|
5136
|
+
return false;
|
|
5137
|
+
}
|
|
5138
|
+
|
|
5139
|
+
if (!isAncestorEmpty(editor, container[0])) {
|
|
5140
|
+
return false;
|
|
5141
|
+
}
|
|
5142
|
+
|
|
5143
|
+
var quote = getBlockAbove(editor, {
|
|
5144
|
+
match: {
|
|
5145
|
+
type: BLOCKS.QUOTE
|
|
5146
|
+
},
|
|
5147
|
+
mode: 'lowest'
|
|
5148
|
+
});
|
|
5149
|
+
|
|
5150
|
+
if (!quote) {
|
|
5151
|
+
return false;
|
|
5152
|
+
}
|
|
5153
|
+
|
|
5154
|
+
if (hasSingleChild(quote[0]) && isLastChild(quote, container[1])) {
|
|
5155
|
+
return true;
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
return false;
|
|
5159
|
+
};
|
|
5160
|
+
|
|
4980
5161
|
function toggleQuote(editor, logAction) {
|
|
4981
5162
|
if (!editor.selection) return;
|
|
4982
5163
|
var isActive = isBlockSelected(editor, BLOCKS.QUOTE);
|
|
4983
|
-
logAction(isActive ? 'remove' : 'insert', {
|
|
5164
|
+
logAction == null ? void 0 : logAction(isActive ? 'remove' : 'insert', {
|
|
4984
5165
|
nodeType: BLOCKS.QUOTE
|
|
4985
5166
|
});
|
|
4986
5167
|
Editor.withoutNormalizing(editor, function () {
|
|
@@ -4991,10 +5172,6 @@ function toggleQuote(editor, logAction) {
|
|
|
4991
5172
|
},
|
|
4992
5173
|
split: true
|
|
4993
5174
|
});
|
|
4994
|
-
var _editor$selection = editor.selection,
|
|
4995
|
-
anchor = _editor$selection.anchor,
|
|
4996
|
-
focus = _editor$selection.focus;
|
|
4997
|
-
var isTripleSelection = anchor.path[0] !== focus.path[0] && anchor.offset === 0 && focus.offset === 0;
|
|
4998
5175
|
|
|
4999
5176
|
if (!isActive) {
|
|
5000
5177
|
var quote = {
|
|
@@ -5002,9 +5179,7 @@ function toggleQuote(editor, logAction) {
|
|
|
5002
5179
|
data: {},
|
|
5003
5180
|
children: []
|
|
5004
5181
|
};
|
|
5005
|
-
Transforms.wrapNodes(editor, quote
|
|
5006
|
-
at: isTripleSelection ? editor.selection.anchor : undefined
|
|
5007
|
-
});
|
|
5182
|
+
Transforms.wrapNodes(editor, quote);
|
|
5008
5183
|
}
|
|
5009
5184
|
});
|
|
5010
5185
|
}
|
|
@@ -5019,6 +5194,54 @@ var onKeyDownToggleQuote = function onKeyDownToggleQuote(editor, plugin) {
|
|
|
5019
5194
|
};
|
|
5020
5195
|
};
|
|
5021
5196
|
|
|
5197
|
+
var withQuote = function withQuote(editor) {
|
|
5198
|
+
var insertFragment = editor.insertFragment;
|
|
5199
|
+
|
|
5200
|
+
editor.insertFragment = function (fragment) {
|
|
5201
|
+
var startingNode = fragment.length && fragment[0];
|
|
5202
|
+
var startsWithBlockquote = Element.isElement(startingNode) && startingNode.type === BLOCKS.QUOTE;
|
|
5203
|
+
var containerEntry = getAbove(editor, {
|
|
5204
|
+
match: {
|
|
5205
|
+
type: TEXT_CONTAINERS
|
|
5206
|
+
}
|
|
5207
|
+
});
|
|
5208
|
+
var containerIsNotEmpty = containerEntry && Node.string(containerEntry[0]) !== '';
|
|
5209
|
+
|
|
5210
|
+
if (startsWithBlockquote && containerIsNotEmpty) {
|
|
5211
|
+
var selection = editor.selection;
|
|
5212
|
+
|
|
5213
|
+
var isContentSelected = function isContentSelected(selection) {
|
|
5214
|
+
return !!selection && Point.compare(selection.anchor, selection.focus) !== 0;
|
|
5215
|
+
}; // if something is selected (highlighted) we replace the selection
|
|
5216
|
+
|
|
5217
|
+
|
|
5218
|
+
if (isContentSelected(selection)) {
|
|
5219
|
+
Transforms["delete"](editor, {
|
|
5220
|
+
at: selection
|
|
5221
|
+
});
|
|
5222
|
+
} // get the cursor entry again, it may be different after deletion
|
|
5223
|
+
|
|
5224
|
+
|
|
5225
|
+
var _containerEntry = getAbove(editor, {
|
|
5226
|
+
match: {
|
|
5227
|
+
type: TEXT_CONTAINERS
|
|
5228
|
+
}
|
|
5229
|
+
});
|
|
5230
|
+
|
|
5231
|
+
var _containerIsNotEmpty = _containerEntry && Node.string(_containerEntry[0]) !== '';
|
|
5232
|
+
|
|
5233
|
+
if (_containerIsNotEmpty) {
|
|
5234
|
+
Transforms.insertNodes(editor, fragment);
|
|
5235
|
+
return;
|
|
5236
|
+
}
|
|
5237
|
+
}
|
|
5238
|
+
|
|
5239
|
+
insertFragment(fragment);
|
|
5240
|
+
};
|
|
5241
|
+
|
|
5242
|
+
return editor;
|
|
5243
|
+
};
|
|
5244
|
+
|
|
5022
5245
|
function createQuotePlugin() {
|
|
5023
5246
|
var _transform;
|
|
5024
5247
|
|
|
@@ -5038,57 +5261,18 @@ function createQuotePlugin() {
|
|
|
5038
5261
|
validNodeName: 'BLOCKQUOTE'
|
|
5039
5262
|
}]
|
|
5040
5263
|
},
|
|
5264
|
+
resetNode: [{
|
|
5265
|
+
// toggle off blockquote on backspace when it's empty
|
|
5266
|
+
hotkey: 'backspace',
|
|
5267
|
+
types: [BLOCKS.QUOTE],
|
|
5268
|
+
predicate: shouldResetQuoteOnBackspace,
|
|
5269
|
+
onReset: toggleQuote
|
|
5270
|
+
}],
|
|
5041
5271
|
normalizer: [{
|
|
5042
5272
|
validChildren: CONTAINERS[BLOCKS.QUOTE],
|
|
5043
5273
|
transform: (_transform = {}, _transform[BLOCKS.QUOTE] = transformUnwrap, _transform["default"] = transformLift, _transform)
|
|
5044
5274
|
}],
|
|
5045
|
-
withOverrides:
|
|
5046
|
-
var insertFragment = editor.insertFragment;
|
|
5047
|
-
|
|
5048
|
-
editor.insertFragment = function (fragment) {
|
|
5049
|
-
var startingNode = fragment.length && fragment[0];
|
|
5050
|
-
var startsWithBlockquote = Element.isElement(startingNode) && startingNode.type === BLOCKS.QUOTE;
|
|
5051
|
-
var containerEntry = getAbove(editor, {
|
|
5052
|
-
match: {
|
|
5053
|
-
type: TEXT_CONTAINERS
|
|
5054
|
-
}
|
|
5055
|
-
});
|
|
5056
|
-
var containerIsNotEmpty = containerEntry && Node.string(containerEntry[0]) !== '';
|
|
5057
|
-
|
|
5058
|
-
if (startsWithBlockquote && containerIsNotEmpty) {
|
|
5059
|
-
var selection = editor.selection;
|
|
5060
|
-
|
|
5061
|
-
var isContentSelected = function isContentSelected(selection) {
|
|
5062
|
-
return !!selection && Point.compare(selection.anchor, selection.focus) !== 0;
|
|
5063
|
-
}; // if something is selected (highlighted) we replace the selection
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
if (isContentSelected(selection)) {
|
|
5067
|
-
Transforms["delete"](editor, {
|
|
5068
|
-
at: selection
|
|
5069
|
-
});
|
|
5070
|
-
} // get the cursor entry again, it may be different after deletion
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
var _containerEntry = getAbove(editor, {
|
|
5074
|
-
match: {
|
|
5075
|
-
type: TEXT_CONTAINERS
|
|
5076
|
-
}
|
|
5077
|
-
});
|
|
5078
|
-
|
|
5079
|
-
var _containerIsNotEmpty = _containerEntry && Node.string(_containerEntry[0]) !== '';
|
|
5080
|
-
|
|
5081
|
-
if (_containerIsNotEmpty) {
|
|
5082
|
-
Transforms.insertNodes(editor, fragment);
|
|
5083
|
-
return;
|
|
5084
|
-
}
|
|
5085
|
-
}
|
|
5086
|
-
|
|
5087
|
-
insertFragment(fragment);
|
|
5088
|
-
};
|
|
5089
|
-
|
|
5090
|
-
return editor;
|
|
5091
|
-
}
|
|
5275
|
+
withOverrides: withQuote
|
|
5092
5276
|
};
|
|
5093
5277
|
}
|
|
5094
5278
|
|
|
@@ -5581,15 +5765,7 @@ var createTablePlugin = function createTablePlugin() {
|
|
|
5581
5765
|
});
|
|
5582
5766
|
|
|
5583
5767
|
if (fragmentHasTable) {
|
|
5584
|
-
|
|
5585
|
-
type: BLOCKS.PARAGRAPH,
|
|
5586
|
-
children: [{
|
|
5587
|
-
text: ''
|
|
5588
|
-
}],
|
|
5589
|
-
data: {},
|
|
5590
|
-
isVoid: false
|
|
5591
|
-
};
|
|
5592
|
-
Transforms.insertNodes(editor, emptyParagraph);
|
|
5768
|
+
insertEmptyParagraph(editor);
|
|
5593
5769
|
}
|
|
5594
5770
|
|
|
5595
5771
|
insertFragment(fragments);
|
|
@@ -5718,6 +5894,20 @@ function ToolbarTableButton(props) {
|
|
|
5718
5894
|
function createTextPlugin() {
|
|
5719
5895
|
return {
|
|
5720
5896
|
key: 'TextPlugin',
|
|
5897
|
+
handlers: {
|
|
5898
|
+
// Triple selection in a non-Firefox browser undesirably selects
|
|
5899
|
+
// the start of the next block. Editor.unhangRange helps removing
|
|
5900
|
+
// the extra block at the end.
|
|
5901
|
+
onMouseUp: function onMouseUp(editor) {
|
|
5902
|
+
return function () {
|
|
5903
|
+
if (!editor.selection) {
|
|
5904
|
+
return;
|
|
5905
|
+
}
|
|
5906
|
+
|
|
5907
|
+
Transforms.setSelection(editor, Editor.unhangRange(editor, editor.selection));
|
|
5908
|
+
};
|
|
5909
|
+
}
|
|
5910
|
+
},
|
|
5721
5911
|
withOverrides: function withOverrides(editor) {
|
|
5722
5912
|
// Reverts the change made upstream that caused the cursor
|
|
5723
5913
|
// to be trapped inside inline elements.
|
|
@@ -5757,11 +5947,11 @@ function createTextPlugin() {
|
|
|
5757
5947
|
deleteBackward = editor.deleteBackward;
|
|
5758
5948
|
|
|
5759
5949
|
editor.deleteBackward = function (unit) {
|
|
5760
|
-
|
|
5950
|
+
deleteFirstEmptyParagraph(unit, editor, deleteBackward);
|
|
5761
5951
|
};
|
|
5762
5952
|
|
|
5763
5953
|
editor.deleteForward = function (unit) {
|
|
5764
|
-
|
|
5954
|
+
deleteFirstEmptyParagraph(unit, editor, deleteForward);
|
|
5765
5955
|
};
|
|
5766
5956
|
|
|
5767
5957
|
return editor;
|
|
@@ -5769,7 +5959,7 @@ function createTextPlugin() {
|
|
|
5769
5959
|
};
|
|
5770
5960
|
}
|
|
5771
5961
|
|
|
5772
|
-
function
|
|
5962
|
+
function deleteFirstEmptyParagraph(unit, editor, deleteFunction) {
|
|
5773
5963
|
var entry = getAbove(editor, {
|
|
5774
5964
|
match: {
|
|
5775
5965
|
type: TEXT_CONTAINERS
|
|
@@ -5782,8 +5972,9 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
5782
5972
|
var isTextEmpty = isAncestorEmpty(editor, paragraphOrHeading); // We ignore paragraphs/headings that are children of ul, ol, blockquote, tables, etc
|
|
5783
5973
|
|
|
5784
5974
|
var isRootLevel = path.length === 1;
|
|
5975
|
+
var hasSiblings = editor.children.length > 1; // prevent editor from losing focus
|
|
5785
5976
|
|
|
5786
|
-
if (isTextEmpty && isRootLevel) {
|
|
5977
|
+
if (isTextEmpty && isRootLevel && isFirstChild(path) && hasSiblings) {
|
|
5787
5978
|
Transforms.removeNodes(editor, {
|
|
5788
5979
|
at: path
|
|
5789
5980
|
});
|
|
@@ -6034,7 +6225,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
6034
6225
|
createTrailingParagraphPlugin(), createTextPlugin(), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
6035
6226
|
createPasteHTMLPlugin(), // These plugins drive their configurations from the list of plugins
|
|
6036
6227
|
// above. They MUST come last.
|
|
6037
|
-
createSoftBreakPlugin(), createExitBreakPlugin(), createNormalizerPlugin()];
|
|
6228
|
+
createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()];
|
|
6038
6229
|
};
|
|
6039
6230
|
var disableCorePlugins = {
|
|
6040
6231
|
// Temporarily until the upstream issue is fixed.
|
|
@@ -6329,7 +6520,10 @@ var useNormalizedSlateValue = function useNormalizedSlateValue(_ref) {
|
|
|
6329
6520
|
schema: schema
|
|
6330
6521
|
}); // Sets editor value & kicks normalization
|
|
6331
6522
|
|
|
6332
|
-
|
|
6523
|
+
editor.children = doc;
|
|
6524
|
+
Editor.normalize(editor, {
|
|
6525
|
+
force: true
|
|
6526
|
+
}); // TODO: return the editor itself to avoid recompiling & initializing all
|
|
6333
6527
|
// of the plugins again. It's currently not possible due to a bug in Plate
|
|
6334
6528
|
// with initialValues
|
|
6335
6529
|
// See: https://slate-js.slack.com/archives/C013QHXSCG1/p1645112799942819
|