@contentful/field-editor-rich-text 2.0.0-next.15 → 2.0.0-next.18
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/CHANGELOG.md +410 -0
- package/README.md +4 -0
- package/dist/ContentfulEditorProvider.d.ts +3 -3
- package/dist/field-editor-rich-text.cjs.development.js +866 -642
- 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 +870 -646
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +2 -2
- package/dist/plugins/List/transforms/toggleList.d.ts +4 -0
- package/dist/plugins/List/utils.d.ts +2 -0
- package/dist/test-utils/assertOutput.d.ts +0 -1
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React__default, {
|
|
1
|
+
import React__default, { createContext, useContext, useMemo, createElement, useEffect, useState, memo, Fragment, useCallback } from 'react';
|
|
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
|
-
import { BLOCKS, INLINES, TABLE_BLOCKS,
|
|
5
|
-
import { usePlateEditorState, usePlateEditorRef, getNodes,
|
|
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, unwrapNodes, isMarkActive, toggleMark, someHtmlElement, match, KEY_DESERIALIZE_HTML, 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';
|
|
@@ -19,7 +19,7 @@ import { ClockIcon, AssetIcon, EmbeddedEntryBlockIcon, EmbeddedEntryInlineIcon,
|
|
|
19
19
|
import tokens from '@contentful/f36-tokens';
|
|
20
20
|
import find from 'lodash-es/find';
|
|
21
21
|
import flow from 'lodash-es/flow';
|
|
22
|
-
import { getListItemEntry, moveListItemUp, ELEMENT_LI, unwrapList, deleteBackwardList, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL, ELEMENT_LIC
|
|
22
|
+
import { getListItemEntry, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, deleteBackwardList, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL, ELEMENT_LIC } from '@udecode/plate-list';
|
|
23
23
|
import { onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
|
|
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';
|
|
@@ -247,25 +247,29 @@ function getContentfulEditorId(sdk) {
|
|
|
247
247
|
}
|
|
248
248
|
var editorContext = /*#__PURE__*/createContext('');
|
|
249
249
|
var ContentfulEditorIdProvider = editorContext.Provider;
|
|
250
|
-
function useContentfulEditorId() {
|
|
251
|
-
var
|
|
250
|
+
function useContentfulEditorId(id) {
|
|
251
|
+
var contextId = useContext(editorContext);
|
|
252
252
|
|
|
253
|
-
if (
|
|
253
|
+
if (id) {
|
|
254
|
+
return id;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (!contextId) {
|
|
254
258
|
throw new Error('could not find editor id. Please ensure the component is wrapped in <ContentfulEditorIdProvider> ');
|
|
255
259
|
}
|
|
256
260
|
|
|
257
|
-
return
|
|
261
|
+
return contextId;
|
|
258
262
|
} // This hook re-renders when the value changes
|
|
259
263
|
// Use case: Toolbar icons, for example
|
|
260
264
|
|
|
261
|
-
function useContentfulEditor() {
|
|
262
|
-
var editorId = useContentfulEditorId();
|
|
265
|
+
function useContentfulEditor(id) {
|
|
266
|
+
var editorId = useContentfulEditorId(id);
|
|
263
267
|
var editor = usePlateEditorState(editorId);
|
|
264
268
|
return editor;
|
|
265
269
|
} // This doesn't re-render when the value changes
|
|
266
270
|
|
|
267
|
-
function useContentfulEditorRef() {
|
|
268
|
-
var editorId = useContentfulEditorId();
|
|
271
|
+
function useContentfulEditorRef(id) {
|
|
272
|
+
var editorId = useContentfulEditorId(id);
|
|
269
273
|
var editor = usePlateEditorRef(editorId);
|
|
270
274
|
return editor;
|
|
271
275
|
}
|
|
@@ -532,17 +536,6 @@ function getAncestorPathFromSelection(editor) {
|
|
|
532
536
|
return level.length === 1;
|
|
533
537
|
});
|
|
534
538
|
}
|
|
535
|
-
function shouldUnwrapBlockquote(editor, type) {
|
|
536
|
-
var isQuoteSelected = isBlockSelected(editor, BLOCKS.QUOTE);
|
|
537
|
-
var isValidType = [].concat(HEADINGS, [BLOCKS.OL_LIST, BLOCKS.UL_LIST, BLOCKS.HR]).includes(type);
|
|
538
|
-
return isQuoteSelected && isValidType;
|
|
539
|
-
}
|
|
540
|
-
function unwrapFromRoot(editor) {
|
|
541
|
-
var ancestorPath = getAncestorPathFromSelection(editor);
|
|
542
|
-
Transforms.unwrapNodes(editor, {
|
|
543
|
-
at: ancestorPath
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
539
|
var isAtEndOfTextSelection = function isAtEndOfTextSelection(editor) {
|
|
547
540
|
var _editor$selection, _editor$selection2;
|
|
548
541
|
|
|
@@ -611,6 +604,13 @@ var focus = function focus(editor) {
|
|
|
611
604
|
}, 0);
|
|
612
605
|
}
|
|
613
606
|
};
|
|
607
|
+
function toggleElement(editor, options, editorOptions) {
|
|
608
|
+
toggleNodeType(editor, options, editorOptions); // We must reset `data` from one element to another
|
|
609
|
+
|
|
610
|
+
Transforms.setNodes(editor, {
|
|
611
|
+
data: {}
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
614
|
|
|
615
615
|
function withLinkTracking(Component) {
|
|
616
616
|
return function ComponentWithTracking(props) {
|
|
@@ -1069,197 +1069,201 @@ function createCommonjsModule(fn, module) {
|
|
|
1069
1069
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
1070
1070
|
}
|
|
1071
1071
|
|
|
1072
|
-
var runtime_1 =
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
var runtime = function (exports) {
|
|
1080
|
-
|
|
1081
|
-
var Op = Object.prototype;
|
|
1082
|
-
var hasOwn = Op.hasOwnProperty;
|
|
1083
|
-
var undefined$1; // More compressible than void 0.
|
|
1084
|
-
|
|
1085
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
1086
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
1087
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
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
|
-
}
|
|
1072
|
+
var runtime_1 = createCommonjsModule(function (module) {
|
|
1073
|
+
/**
|
|
1074
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
1075
|
+
*
|
|
1076
|
+
* This source code is licensed under the MIT license found in the
|
|
1077
|
+
* LICENSE file in the root directory of this source tree.
|
|
1078
|
+
*/
|
|
1099
1079
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1080
|
+
var runtime = (function (exports) {
|
|
1081
|
+
|
|
1082
|
+
var Op = Object.prototype;
|
|
1083
|
+
var hasOwn = Op.hasOwnProperty;
|
|
1084
|
+
var undefined$1; // More compressible than void 0.
|
|
1085
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
1086
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
1087
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
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
|
+
}
|
|
1108
1107
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
// .throw, and .return methods.
|
|
1108
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1109
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
1110
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
1111
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
1112
|
+
var context = new Context(tryLocsList || []);
|
|
1115
1113
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1114
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
1115
|
+
// .throw, and .return methods.
|
|
1116
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
1119
1117
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
type: "throw",
|
|
1140
|
-
arg: err
|
|
1141
|
-
};
|
|
1142
|
-
}
|
|
1118
|
+
return generator;
|
|
1119
|
+
}
|
|
1120
|
+
exports.wrap = wrap;
|
|
1121
|
+
|
|
1122
|
+
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
1123
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
1124
|
+
// have been (and was previously) designed to take a closure to be
|
|
1125
|
+
// invoked without arguments, but in all the cases we care about we
|
|
1126
|
+
// already have an existing method we want to call, so there's no need
|
|
1127
|
+
// to create a new function object. We can even get away with assuming
|
|
1128
|
+
// the method takes exactly one argument, since that happens to be true
|
|
1129
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
1130
|
+
// only additional allocation required is the completion record, which
|
|
1131
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
1132
|
+
function tryCatch(fn, obj, arg) {
|
|
1133
|
+
try {
|
|
1134
|
+
return { type: "normal", arg: fn.call(obj, arg) };
|
|
1135
|
+
} catch (err) {
|
|
1136
|
+
return { type: "throw", arg: err };
|
|
1143
1137
|
}
|
|
1138
|
+
}
|
|
1144
1139
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1140
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
1141
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
1142
|
+
var GenStateExecuting = "executing";
|
|
1143
|
+
var GenStateCompleted = "completed";
|
|
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
|
+
});
|
|
1162
1163
|
|
|
1164
|
+
var getProto = Object.getPrototypeOf;
|
|
1165
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1166
|
+
if (NativeIteratorPrototype &&
|
|
1167
|
+
NativeIteratorPrototype !== Op &&
|
|
1168
|
+
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
1169
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
1170
|
+
// of the polyfill.
|
|
1171
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
1172
|
+
}
|
|
1163
1173
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1174
|
+
var Gp = GeneratorFunctionPrototype.prototype =
|
|
1175
|
+
Generator.prototype = Object.create(IteratorPrototype);
|
|
1176
|
+
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
1177
|
+
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
1178
|
+
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
1179
|
+
GeneratorFunction.displayName = define(
|
|
1180
|
+
GeneratorFunctionPrototype,
|
|
1181
|
+
toStringTagSymbol,
|
|
1182
|
+
"GeneratorFunction"
|
|
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
|
+
});
|
|
1167
1192
|
});
|
|
1168
|
-
|
|
1169
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1193
|
+
}
|
|
1170
1194
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1195
|
+
exports.isGeneratorFunction = function(genFun) {
|
|
1196
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
1197
|
+
return ctor
|
|
1198
|
+
? ctor === GeneratorFunction ||
|
|
1199
|
+
// For the native GeneratorFunction constructor, the best we can
|
|
1200
|
+
// do is to check its .name property.
|
|
1201
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
1202
|
+
: false;
|
|
1203
|
+
};
|
|
1176
1204
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
function defineIteratorMethods(prototype) {
|
|
1185
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
1186
|
-
define(prototype, method, function (arg) {
|
|
1187
|
-
return this._invoke(method, arg);
|
|
1188
|
-
});
|
|
1189
|
-
});
|
|
1205
|
+
exports.mark = function(genFun) {
|
|
1206
|
+
if (Object.setPrototypeOf) {
|
|
1207
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
1208
|
+
} else {
|
|
1209
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
1210
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
1190
1211
|
}
|
|
1212
|
+
genFun.prototype = Object.create(Gp);
|
|
1213
|
+
return genFun;
|
|
1214
|
+
};
|
|
1191
1215
|
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
};
|
|
1216
|
+
// Within the body of any async function, `await x` is transformed to
|
|
1217
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
1218
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
1219
|
+
// meant to be awaited.
|
|
1220
|
+
exports.awrap = function(arg) {
|
|
1221
|
+
return { __await: arg };
|
|
1222
|
+
};
|
|
1198
1223
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1224
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
1225
|
+
function invoke(method, arg, resolve, reject) {
|
|
1226
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
1227
|
+
if (record.type === "throw") {
|
|
1228
|
+
reject(record.arg);
|
|
1202
1229
|
} else {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
// meant to be awaited.
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
exports.awrap = function (arg) {
|
|
1216
|
-
return {
|
|
1217
|
-
__await: arg
|
|
1218
|
-
};
|
|
1219
|
-
};
|
|
1220
|
-
|
|
1221
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
1222
|
-
function invoke(method, arg, resolve, reject) {
|
|
1223
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
1224
|
-
|
|
1225
|
-
if (record.type === "throw") {
|
|
1226
|
-
reject(record.arg);
|
|
1227
|
-
} else {
|
|
1228
|
-
var result = record.arg;
|
|
1229
|
-
var value = result.value;
|
|
1230
|
-
|
|
1231
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
1232
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1233
|
-
invoke("next", value, resolve, reject);
|
|
1234
|
-
}, function (err) {
|
|
1235
|
-
invoke("throw", err, resolve, reject);
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1240
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
1241
|
-
// the .value of the Promise<{value,done}> result for the
|
|
1242
|
-
// current iteration.
|
|
1243
|
-
result.value = unwrapped;
|
|
1244
|
-
resolve(result);
|
|
1245
|
-
}, function (error) {
|
|
1246
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
1247
|
-
// into the async generator function so it can be handled there.
|
|
1248
|
-
return invoke("throw", error, resolve, reject);
|
|
1230
|
+
var result = record.arg;
|
|
1231
|
+
var value = result.value;
|
|
1232
|
+
if (value &&
|
|
1233
|
+
typeof value === "object" &&
|
|
1234
|
+
hasOwn.call(value, "__await")) {
|
|
1235
|
+
return PromiseImpl.resolve(value.__await).then(function(value) {
|
|
1236
|
+
invoke("next", value, resolve, reject);
|
|
1237
|
+
}, function(err) {
|
|
1238
|
+
invoke("throw", err, resolve, reject);
|
|
1249
1239
|
});
|
|
1250
1240
|
}
|
|
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
|
+
});
|
|
1251
1253
|
}
|
|
1254
|
+
}
|
|
1252
1255
|
|
|
1253
|
-
|
|
1256
|
+
var previousPromise;
|
|
1254
1257
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1258
|
+
function enqueue(method, arg) {
|
|
1259
|
+
function callInvokeWithMethodAndArg() {
|
|
1260
|
+
return new PromiseImpl(function(resolve, reject) {
|
|
1261
|
+
invoke(method, arg, resolve, reject);
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1261
1264
|
|
|
1262
|
-
|
|
1265
|
+
return previousPromise =
|
|
1266
|
+
// If enqueue has been called before, then we want to wait until
|
|
1263
1267
|
// all previous Promises have been resolved before calling invoke,
|
|
1264
1268
|
// so that results are always delivered in the correct order. If
|
|
1265
1269
|
// enqueue has not been called before, then it is important to
|
|
@@ -1271,527 +1275,554 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1271
1275
|
// execute code before the first await. Since we implement simple
|
|
1272
1276
|
// async functions in terms of async generators, it is especially
|
|
1273
1277
|
// important to get this right, even though it requires care.
|
|
1274
|
-
previousPromise ? previousPromise.then(
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
this._invoke = enqueue;
|
|
1278
|
+
previousPromise ? previousPromise.then(
|
|
1279
|
+
callInvokeWithMethodAndArg,
|
|
1280
|
+
// Avoid propagating failures to Promises returned by later
|
|
1281
|
+
// invocations of the iterator.
|
|
1282
|
+
callInvokeWithMethodAndArg
|
|
1283
|
+
) : callInvokeWithMethodAndArg();
|
|
1282
1284
|
}
|
|
1283
1285
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
1289
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
1290
|
-
// the final result produced by the iterator.
|
|
1291
|
-
|
|
1292
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1293
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
1294
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1295
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
1296
|
-
: iter.next().then(function (result) {
|
|
1297
|
-
return result.done ? result.value : iter.next();
|
|
1298
|
-
});
|
|
1299
|
-
};
|
|
1286
|
+
// Define the unified helper method that is used to implement .next,
|
|
1287
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
1288
|
+
this._invoke = enqueue;
|
|
1289
|
+
}
|
|
1300
1290
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1291
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
1292
|
+
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1293
|
+
return this;
|
|
1294
|
+
});
|
|
1295
|
+
exports.AsyncIterator = AsyncIterator;
|
|
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
|
+
};
|
|
1307
1314
|
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
throw arg;
|
|
1311
|
-
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
1312
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
1315
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
1316
|
+
var state = GenStateSuspendedStart;
|
|
1313
1317
|
|
|
1318
|
+
return function invoke(method, arg) {
|
|
1319
|
+
if (state === GenStateExecuting) {
|
|
1320
|
+
throw new Error("Generator is already running");
|
|
1321
|
+
}
|
|
1314
1322
|
|
|
1315
|
-
|
|
1323
|
+
if (state === GenStateCompleted) {
|
|
1324
|
+
if (method === "throw") {
|
|
1325
|
+
throw arg;
|
|
1316
1326
|
}
|
|
1317
1327
|
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
var delegate = context.delegate;
|
|
1328
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
1329
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
1330
|
+
return doneResult();
|
|
1331
|
+
}
|
|
1323
1332
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1333
|
+
context.method = method;
|
|
1334
|
+
context.arg = arg;
|
|
1326
1335
|
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1336
|
+
while (true) {
|
|
1337
|
+
var delegate = context.delegate;
|
|
1338
|
+
if (delegate) {
|
|
1339
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1340
|
+
if (delegateResult) {
|
|
1341
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
1342
|
+
return delegateResult;
|
|
1331
1343
|
}
|
|
1344
|
+
}
|
|
1332
1345
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
} else if (context.method === "throw") {
|
|
1338
|
-
if (state === GenStateSuspendedStart) {
|
|
1339
|
-
state = GenStateCompleted;
|
|
1340
|
-
throw context.arg;
|
|
1341
|
-
}
|
|
1346
|
+
if (context.method === "next") {
|
|
1347
|
+
// Setting context._sent for legacy support of Babel's
|
|
1348
|
+
// function.sent implementation.
|
|
1349
|
+
context.sent = context._sent = context.arg;
|
|
1342
1350
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1351
|
+
} else if (context.method === "throw") {
|
|
1352
|
+
if (state === GenStateSuspendedStart) {
|
|
1353
|
+
state = GenStateCompleted;
|
|
1354
|
+
throw context.arg;
|
|
1346
1355
|
}
|
|
1347
1356
|
|
|
1348
|
-
|
|
1349
|
-
var record = tryCatch(innerFn, self, context);
|
|
1357
|
+
context.dispatchException(context.arg);
|
|
1350
1358
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
1359
|
+
} else if (context.method === "return") {
|
|
1360
|
+
context.abrupt("return", context.arg);
|
|
1361
|
+
}
|
|
1355
1362
|
|
|
1356
|
-
|
|
1357
|
-
continue;
|
|
1358
|
-
}
|
|
1363
|
+
state = GenStateExecuting;
|
|
1359
1364
|
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1365
|
+
var record = tryCatch(innerFn, self, context);
|
|
1366
|
+
if (record.type === "normal") {
|
|
1367
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
1368
|
+
// GenStateExecuting and loop back for another invocation.
|
|
1369
|
+
state = context.done
|
|
1370
|
+
? GenStateCompleted
|
|
1371
|
+
: GenStateSuspendedYield;
|
|
1367
1372
|
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
|
-
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
1374
|
-
// result, either by returning a { value, done } result from the
|
|
1375
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
1376
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
1380
|
-
var method = delegate.iterator[context.method];
|
|
1381
|
-
|
|
1382
|
-
if (method === undefined$1) {
|
|
1383
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
1384
|
-
// method always terminates the yield* loop.
|
|
1385
|
-
context.delegate = null;
|
|
1386
|
-
|
|
1387
|
-
if (context.method === "throw") {
|
|
1388
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
1389
|
-
if (delegate.iterator["return"]) {
|
|
1390
|
-
// If the delegate iterator has a return method, give it a
|
|
1391
|
-
// chance to clean up.
|
|
1392
|
-
context.method = "return";
|
|
1393
|
-
context.arg = undefined$1;
|
|
1394
|
-
maybeInvokeDelegate(delegate, context);
|
|
1395
|
-
|
|
1396
|
-
if (context.method === "throw") {
|
|
1397
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
1398
|
-
// "return" to "throw", let that override the TypeError below.
|
|
1399
|
-
return ContinueSentinel;
|
|
1400
|
-
}
|
|
1373
|
+
if (record.arg === ContinueSentinel) {
|
|
1374
|
+
continue;
|
|
1401
1375
|
}
|
|
1402
1376
|
|
|
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.
|
|
1403
1386
|
context.method = "throw";
|
|
1404
|
-
context.arg =
|
|
1387
|
+
context.arg = record.arg;
|
|
1405
1388
|
}
|
|
1406
|
-
|
|
1407
|
-
return ContinueSentinel;
|
|
1408
1389
|
}
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1409
1392
|
|
|
1410
|
-
|
|
1393
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
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;
|
|
1411
1403
|
|
|
1412
|
-
if (
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1404
|
+
if (context.method === "throw") {
|
|
1405
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
1406
|
+
if (delegate.iterator["return"]) {
|
|
1407
|
+
// If the delegate iterator has a return method, give it a
|
|
1408
|
+
// chance to clean up.
|
|
1409
|
+
context.method = "return";
|
|
1410
|
+
context.arg = undefined$1;
|
|
1411
|
+
maybeInvokeDelegate(delegate, context);
|
|
1418
1412
|
|
|
1419
|
-
|
|
1413
|
+
if (context.method === "throw") {
|
|
1414
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
1415
|
+
// "return" to "throw", let that override the TypeError below.
|
|
1416
|
+
return ContinueSentinel;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1420
1419
|
|
|
1421
|
-
if (!info) {
|
|
1422
1420
|
context.method = "throw";
|
|
1423
|
-
context.arg = new TypeError(
|
|
1424
|
-
|
|
1425
|
-
return ContinueSentinel;
|
|
1421
|
+
context.arg = new TypeError(
|
|
1422
|
+
"The iterator does not provide a 'throw' method");
|
|
1426
1423
|
}
|
|
1427
1424
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
1431
|
-
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
1432
|
-
|
|
1433
|
-
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
1434
|
-
// exception, let the outer generator proceed normally. If
|
|
1435
|
-
// context.method was "next", forget context.arg since it has been
|
|
1436
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
1437
|
-
// "return", allow the original .return call to continue in the
|
|
1438
|
-
// outer generator.
|
|
1439
|
-
|
|
1440
|
-
if (context.method !== "return") {
|
|
1441
|
-
context.method = "next";
|
|
1442
|
-
context.arg = undefined$1;
|
|
1443
|
-
}
|
|
1444
|
-
} else {
|
|
1445
|
-
// Re-yield the result returned by the delegate method.
|
|
1446
|
-
return info;
|
|
1447
|
-
} // The delegate iterator is finished, so forget it and continue with
|
|
1448
|
-
// the outer generator.
|
|
1425
|
+
return ContinueSentinel;
|
|
1426
|
+
}
|
|
1449
1427
|
|
|
1428
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1450
1429
|
|
|
1430
|
+
if (record.type === "throw") {
|
|
1431
|
+
context.method = "throw";
|
|
1432
|
+
context.arg = record.arg;
|
|
1451
1433
|
context.delegate = null;
|
|
1452
1434
|
return ContinueSentinel;
|
|
1453
|
-
}
|
|
1454
|
-
// unified ._invoke helper method.
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
defineIteratorMethods(Gp);
|
|
1458
|
-
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
1459
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
1460
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
1461
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
1462
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1463
|
-
|
|
1464
|
-
define(Gp, iteratorSymbol, function () {
|
|
1465
|
-
return this;
|
|
1466
|
-
});
|
|
1467
|
-
define(Gp, "toString", function () {
|
|
1468
|
-
return "[object Generator]";
|
|
1469
|
-
});
|
|
1435
|
+
}
|
|
1470
1436
|
|
|
1471
|
-
|
|
1472
|
-
var entry = {
|
|
1473
|
-
tryLoc: locs[0]
|
|
1474
|
-
};
|
|
1437
|
+
var info = record.arg;
|
|
1475
1438
|
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1439
|
+
if (! info) {
|
|
1440
|
+
context.method = "throw";
|
|
1441
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
1442
|
+
context.delegate = null;
|
|
1443
|
+
return ContinueSentinel;
|
|
1444
|
+
}
|
|
1479
1445
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
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;
|
|
1483
1463
|
}
|
|
1484
1464
|
|
|
1485
|
-
|
|
1465
|
+
} else {
|
|
1466
|
+
// Re-yield the result returned by the delegate method.
|
|
1467
|
+
return info;
|
|
1486
1468
|
}
|
|
1487
1469
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
}
|
|
1470
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
1471
|
+
// the outer generator.
|
|
1472
|
+
context.delegate = null;
|
|
1473
|
+
return ContinueSentinel;
|
|
1474
|
+
}
|
|
1494
1475
|
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
// locations where there is no enclosing try statement.
|
|
1499
|
-
this.tryEntries = [{
|
|
1500
|
-
tryLoc: "root"
|
|
1501
|
-
}];
|
|
1502
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
1503
|
-
this.reset(true);
|
|
1504
|
-
}
|
|
1476
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
1477
|
+
// unified ._invoke helper method.
|
|
1478
|
+
defineIteratorMethods(Gp);
|
|
1505
1479
|
|
|
1506
|
-
|
|
1507
|
-
var keys = [];
|
|
1480
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
1508
1481
|
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1482
|
+
// A Generator should always return itself as the iterator object when the
|
|
1483
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
1484
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
1485
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
1486
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1487
|
+
define(Gp, iteratorSymbol, function() {
|
|
1488
|
+
return this;
|
|
1489
|
+
});
|
|
1512
1490
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1491
|
+
define(Gp, "toString", function() {
|
|
1492
|
+
return "[object Generator]";
|
|
1493
|
+
});
|
|
1515
1494
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
var key = keys.pop();
|
|
1495
|
+
function pushTryEntry(locs) {
|
|
1496
|
+
var entry = { tryLoc: locs[0] };
|
|
1519
1497
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
return next;
|
|
1524
|
-
}
|
|
1525
|
-
} // To avoid creating an additional object, we just hang the .value
|
|
1526
|
-
// and .done properties off the next function object itself. This
|
|
1527
|
-
// also ensures that the minifier will not anonymize the function.
|
|
1498
|
+
if (1 in locs) {
|
|
1499
|
+
entry.catchLoc = locs[1];
|
|
1500
|
+
}
|
|
1528
1501
|
|
|
1502
|
+
if (2 in locs) {
|
|
1503
|
+
entry.finallyLoc = locs[2];
|
|
1504
|
+
entry.afterLoc = locs[3];
|
|
1505
|
+
}
|
|
1529
1506
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
};
|
|
1533
|
-
};
|
|
1507
|
+
this.tryEntries.push(entry);
|
|
1508
|
+
}
|
|
1534
1509
|
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1510
|
+
function resetTryEntry(entry) {
|
|
1511
|
+
var record = entry.completion || {};
|
|
1512
|
+
record.type = "normal";
|
|
1513
|
+
delete record.arg;
|
|
1514
|
+
entry.completion = record;
|
|
1515
|
+
}
|
|
1538
1516
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
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
|
+
}
|
|
1542
1525
|
|
|
1543
|
-
|
|
1544
|
-
|
|
1526
|
+
exports.keys = function(object) {
|
|
1527
|
+
var keys = [];
|
|
1528
|
+
for (var key in object) {
|
|
1529
|
+
keys.push(key);
|
|
1530
|
+
}
|
|
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;
|
|
1545
1542
|
}
|
|
1543
|
+
}
|
|
1546
1544
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
return next;
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1545
|
+
// To avoid creating an additional object, we just hang the .value
|
|
1546
|
+
// and .done properties off the next function object itself. This
|
|
1547
|
+
// also ensures that the minifier will not anonymize the function.
|
|
1548
|
+
next.done = true;
|
|
1549
|
+
return next;
|
|
1550
|
+
};
|
|
1551
|
+
};
|
|
1557
1552
|
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1553
|
+
function values(iterable) {
|
|
1554
|
+
if (iterable) {
|
|
1555
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1556
|
+
if (iteratorMethod) {
|
|
1557
|
+
return iteratorMethod.call(iterable);
|
|
1558
|
+
}
|
|
1562
1559
|
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
}
|
|
1560
|
+
if (typeof iterable.next === "function") {
|
|
1561
|
+
return iterable;
|
|
1562
|
+
}
|
|
1566
1563
|
|
|
1564
|
+
if (!isNaN(iterable.length)) {
|
|
1565
|
+
var i = -1, next = function next() {
|
|
1566
|
+
while (++i < iterable.length) {
|
|
1567
|
+
if (hasOwn.call(iterable, i)) {
|
|
1568
|
+
next.value = iterable[i];
|
|
1569
|
+
next.done = false;
|
|
1570
|
+
return next;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1567
1573
|
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1574
|
+
next.value = undefined$1;
|
|
1575
|
+
next.done = true;
|
|
1572
1576
|
|
|
1573
|
-
|
|
1577
|
+
return next;
|
|
1578
|
+
};
|
|
1574
1579
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
value: undefined$1,
|
|
1578
|
-
done: true
|
|
1579
|
-
};
|
|
1580
|
+
return next.next = next;
|
|
1581
|
+
}
|
|
1580
1582
|
}
|
|
1581
1583
|
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
1587
|
-
// function.sent implementation.
|
|
1584
|
+
// Return an iterator with no values.
|
|
1585
|
+
return { next: doneResult };
|
|
1586
|
+
}
|
|
1587
|
+
exports.values = values;
|
|
1588
1588
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
this.method = "next";
|
|
1593
|
-
this.arg = undefined$1;
|
|
1594
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
1589
|
+
function doneResult() {
|
|
1590
|
+
return { value: undefined$1, done: true };
|
|
1591
|
+
}
|
|
1595
1592
|
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1593
|
+
Context.prototype = {
|
|
1594
|
+
constructor: Context,
|
|
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;
|
|
1602
1617
|
}
|
|
1603
1618
|
}
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
this.done = true;
|
|
1607
|
-
var rootEntry = this.tryEntries[0];
|
|
1608
|
-
var rootRecord = rootEntry.completion;
|
|
1619
|
+
}
|
|
1620
|
+
},
|
|
1609
1621
|
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
}
|
|
1622
|
+
stop: function() {
|
|
1623
|
+
this.done = true;
|
|
1613
1624
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
}
|
|
1625
|
+
var rootEntry = this.tryEntries[0];
|
|
1626
|
+
var rootRecord = rootEntry.completion;
|
|
1627
|
+
if (rootRecord.type === "throw") {
|
|
1628
|
+
throw rootRecord.arg;
|
|
1629
|
+
}
|
|
1620
1630
|
|
|
1621
|
-
|
|
1631
|
+
return this.rval;
|
|
1632
|
+
},
|
|
1622
1633
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1634
|
+
dispatchException: function(exception) {
|
|
1635
|
+
if (this.done) {
|
|
1636
|
+
throw exception;
|
|
1637
|
+
}
|
|
1627
1638
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
}
|
|
1639
|
+
var context = this;
|
|
1640
|
+
function handle(loc, caught) {
|
|
1641
|
+
record.type = "throw";
|
|
1642
|
+
record.arg = exception;
|
|
1643
|
+
context.next = loc;
|
|
1634
1644
|
|
|
1635
|
-
|
|
1645
|
+
if (caught) {
|
|
1646
|
+
// If the dispatched exception was caught by a catch block,
|
|
1647
|
+
// then let that catch block handle the exception normally.
|
|
1648
|
+
context.method = "next";
|
|
1649
|
+
context.arg = undefined$1;
|
|
1636
1650
|
}
|
|
1637
1651
|
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
var record = entry.completion;
|
|
1652
|
+
return !! caught;
|
|
1653
|
+
}
|
|
1641
1654
|
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1655
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1656
|
+
var entry = this.tryEntries[i];
|
|
1657
|
+
var record = entry.completion;
|
|
1658
|
+
|
|
1659
|
+
if (entry.tryLoc === "root") {
|
|
1660
|
+
// Exception thrown outside of any try block that could handle
|
|
1661
|
+
// it, so set the completion value of the entire function to
|
|
1662
|
+
// throw the exception.
|
|
1663
|
+
return handle("end");
|
|
1664
|
+
}
|
|
1648
1665
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1666
|
+
if (entry.tryLoc <= this.prev) {
|
|
1667
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1668
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1652
1669
|
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
throw new Error("try statement without catch or finally");
|
|
1670
|
+
if (hasCatch && hasFinally) {
|
|
1671
|
+
if (this.prev < entry.catchLoc) {
|
|
1672
|
+
return handle(entry.catchLoc, true);
|
|
1673
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
1674
|
+
return handle(entry.finallyLoc);
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
} else if (hasCatch) {
|
|
1678
|
+
if (this.prev < entry.catchLoc) {
|
|
1679
|
+
return handle(entry.catchLoc, true);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
} else if (hasFinally) {
|
|
1683
|
+
if (this.prev < entry.finallyLoc) {
|
|
1684
|
+
return handle(entry.finallyLoc);
|
|
1669
1685
|
}
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
},
|
|
1673
|
-
abrupt: function abrupt(type, arg) {
|
|
1674
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1675
|
-
var entry = this.tryEntries[i];
|
|
1676
1686
|
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
break;
|
|
1687
|
+
} else {
|
|
1688
|
+
throw new Error("try statement without catch or finally");
|
|
1680
1689
|
}
|
|
1681
1690
|
}
|
|
1691
|
+
}
|
|
1692
|
+
},
|
|
1682
1693
|
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1694
|
+
abrupt: function(type, arg) {
|
|
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;
|
|
1687
1702
|
}
|
|
1703
|
+
}
|
|
1688
1704
|
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1705
|
+
if (finallyEntry &&
|
|
1706
|
+
(type === "break" ||
|
|
1707
|
+
type === "continue") &&
|
|
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
|
+
}
|
|
1692
1714
|
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
return ContinueSentinel;
|
|
1697
|
-
}
|
|
1715
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1716
|
+
record.type = type;
|
|
1717
|
+
record.arg = arg;
|
|
1698
1718
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
}
|
|
1719
|
+
if (finallyEntry) {
|
|
1720
|
+
this.method = "next";
|
|
1721
|
+
this.next = finallyEntry.finallyLoc;
|
|
1722
|
+
return ContinueSentinel;
|
|
1723
|
+
}
|
|
1705
1724
|
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
} else if (record.type === "return") {
|
|
1709
|
-
this.rval = this.arg = record.arg;
|
|
1710
|
-
this.method = "return";
|
|
1711
|
-
this.next = "end";
|
|
1712
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
1713
|
-
this.next = afterLoc;
|
|
1714
|
-
}
|
|
1725
|
+
return this.complete(record);
|
|
1726
|
+
},
|
|
1715
1727
|
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
var entry = this.tryEntries[i];
|
|
1728
|
+
complete: function(record, afterLoc) {
|
|
1729
|
+
if (record.type === "throw") {
|
|
1730
|
+
throw record.arg;
|
|
1731
|
+
}
|
|
1721
1732
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
"
|
|
1730
|
-
|
|
1731
|
-
|
|
1733
|
+
if (record.type === "break" ||
|
|
1734
|
+
record.type === "continue") {
|
|
1735
|
+
this.next = record.arg;
|
|
1736
|
+
} else if (record.type === "return") {
|
|
1737
|
+
this.rval = this.arg = record.arg;
|
|
1738
|
+
this.method = "return";
|
|
1739
|
+
this.next = "end";
|
|
1740
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
1741
|
+
this.next = afterLoc;
|
|
1742
|
+
}
|
|
1732
1743
|
|
|
1733
|
-
|
|
1734
|
-
|
|
1744
|
+
return ContinueSentinel;
|
|
1745
|
+
},
|
|
1735
1746
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1747
|
+
finish: function(finallyLoc) {
|
|
1748
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1749
|
+
var entry = this.tryEntries[i];
|
|
1750
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
1751
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
1752
|
+
resetTryEntry(entry);
|
|
1753
|
+
return ContinueSentinel;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
},
|
|
1740
1757
|
|
|
1741
|
-
|
|
1758
|
+
"catch": function(tryLoc) {
|
|
1759
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1760
|
+
var entry = this.tryEntries[i];
|
|
1761
|
+
if (entry.tryLoc === tryLoc) {
|
|
1762
|
+
var record = entry.completion;
|
|
1763
|
+
if (record.type === "throw") {
|
|
1764
|
+
var thrown = record.arg;
|
|
1765
|
+
resetTryEntry(entry);
|
|
1742
1766
|
}
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1767
|
+
return thrown;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1746
1770
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
iterator: values(iterable),
|
|
1752
|
-
resultName: resultName,
|
|
1753
|
-
nextLoc: nextLoc
|
|
1754
|
-
};
|
|
1771
|
+
// The context.catch method must only be called with a location
|
|
1772
|
+
// argument that corresponds to a known catch block.
|
|
1773
|
+
throw new Error("illegal catch attempt");
|
|
1774
|
+
},
|
|
1755
1775
|
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1776
|
+
delegateYield: function(iterable, resultName, nextLoc) {
|
|
1777
|
+
this.delegate = {
|
|
1778
|
+
iterator: values(iterable),
|
|
1779
|
+
resultName: resultName,
|
|
1780
|
+
nextLoc: nextLoc
|
|
1781
|
+
};
|
|
1761
1782
|
|
|
1762
|
-
|
|
1783
|
+
if (this.method === "next") {
|
|
1784
|
+
// Deliberately forget the last sent value so that we don't
|
|
1785
|
+
// accidentally pass it on to the delegate.
|
|
1786
|
+
this.arg = undefined$1;
|
|
1763
1787
|
}
|
|
1764
|
-
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1765
|
-
// or not, return the runtime object so that we can declare the variable
|
|
1766
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1767
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1768
1788
|
|
|
1769
|
-
|
|
1770
|
-
|
|
1789
|
+
return ContinueSentinel;
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
1794
|
+
// or not, return the runtime object so that we can declare the variable
|
|
1795
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1796
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1797
|
+
return exports;
|
|
1798
|
+
|
|
1799
|
+
}(
|
|
1800
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
1771
1801
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1772
1802
|
// object. Either way, the resulting object will be used to initialize
|
|
1773
1803
|
// the regeneratorRuntime variable at the top of this file.
|
|
1774
|
-
module.exports
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1804
|
+
module.exports
|
|
1805
|
+
));
|
|
1806
|
+
|
|
1807
|
+
try {
|
|
1808
|
+
regeneratorRuntime = runtime;
|
|
1809
|
+
} catch (accidentalStrictMode) {
|
|
1810
|
+
// This module should not be running in strict mode, so the above
|
|
1811
|
+
// assignment should always work unless something is misconfigured. Just
|
|
1812
|
+
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
1813
|
+
// we can explicitly access globalThis. In older engines we can escape
|
|
1814
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
1815
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
1816
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
1817
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
1818
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1819
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
1820
|
+
if (typeof globalThis === "object") {
|
|
1821
|
+
globalThis.regeneratorRuntime = runtime;
|
|
1822
|
+
} else {
|
|
1823
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1794
1824
|
}
|
|
1825
|
+
}
|
|
1795
1826
|
});
|
|
1796
1827
|
|
|
1797
1828
|
/* eslint-disable you-dont-need-lodash-underscore/find */
|
|
@@ -2499,15 +2530,10 @@ function ToolbarHeadingButton(props) {
|
|
|
2499
2530
|
if (!(editor != null && editor.selection)) return;
|
|
2500
2531
|
setSelected(type);
|
|
2501
2532
|
setOpen(false);
|
|
2502
|
-
|
|
2503
|
-
if (shouldUnwrapBlockquote(editor, type)) {
|
|
2504
|
-
unwrapFromRoot(editor);
|
|
2505
|
-
}
|
|
2506
|
-
|
|
2507
2533
|
var prevOnChange = editor.onChange;
|
|
2508
2534
|
/*
|
|
2509
2535
|
The focus might happen at point in time when
|
|
2510
|
-
`
|
|
2536
|
+
`toggleElement` (helper for toggleNodeType) changes aren't rendered yet, causing the browser
|
|
2511
2537
|
to place the cursor at the start of the text.
|
|
2512
2538
|
We wait for the change event before focusing
|
|
2513
2539
|
the editor again. This ensures the cursor is back at the previous
|
|
@@ -2523,7 +2549,7 @@ function ToolbarHeadingButton(props) {
|
|
|
2523
2549
|
editor.tracking.onToolbarAction(isActive ? 'remove' : 'insert', {
|
|
2524
2550
|
nodeType: type
|
|
2525
2551
|
});
|
|
2526
|
-
|
|
2552
|
+
toggleElement(editor, {
|
|
2527
2553
|
activeType: type,
|
|
2528
2554
|
inactiveType: type
|
|
2529
2555
|
});
|
|
@@ -2653,7 +2679,7 @@ var buildHeadingEventHandler = function buildHeadingEventHandler(type) {
|
|
|
2653
2679
|
editor.tracking.onShortcutAction(isActive ? 'remove' : 'insert', {
|
|
2654
2680
|
nodeType: type
|
|
2655
2681
|
});
|
|
2656
|
-
|
|
2682
|
+
toggleElement(editor, {
|
|
2657
2683
|
activeType: type,
|
|
2658
2684
|
inactiveType: BLOCKS.PARAGRAPH
|
|
2659
2685
|
});
|
|
@@ -3719,6 +3745,16 @@ var replaceNodeWithListItems = function replaceNodeWithListItems(editor, entry)
|
|
|
3719
3745
|
at: path
|
|
3720
3746
|
});
|
|
3721
3747
|
};
|
|
3748
|
+
var isListTypeActive = function isListTypeActive(editor, type) {
|
|
3749
|
+
// Lists can be nested. Here, we take the list type at the lowest level
|
|
3750
|
+
var listNode = getBlockAbove(editor, {
|
|
3751
|
+
match: {
|
|
3752
|
+
type: [BLOCKS.OL_LIST, BLOCKS.UL_LIST]
|
|
3753
|
+
},
|
|
3754
|
+
mode: 'lowest'
|
|
3755
|
+
});
|
|
3756
|
+
return (listNode == null ? void 0 : listNode[0].type) === type;
|
|
3757
|
+
};
|
|
3722
3758
|
|
|
3723
3759
|
/**
|
|
3724
3760
|
* Build a new list item node while preserving marks
|
|
@@ -3867,7 +3903,7 @@ var listBreak = function listBreak(editor) {
|
|
|
3867
3903
|
return !moved && isBlockAboveEmpty(editor);
|
|
3868
3904
|
},
|
|
3869
3905
|
onReset: function onReset(_editor) {
|
|
3870
|
-
return unwrapList(_editor);
|
|
3906
|
+
return unwrapList$1(_editor);
|
|
3871
3907
|
}
|
|
3872
3908
|
}]
|
|
3873
3909
|
}
|
|
@@ -4088,6 +4124,178 @@ var createListPlugin = function createListPlugin() {
|
|
|
4088
4124
|
});
|
|
4089
4125
|
};
|
|
4090
4126
|
|
|
4127
|
+
var listTypes = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4128
|
+
|
|
4129
|
+
var unwrapList = function unwrapList(editor, _temp) {
|
|
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;
|
|
4160
|
+
return Editor.withoutNormalizing(editor, function () {
|
|
4161
|
+
if (!editor.selection) {
|
|
4162
|
+
return;
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
if (isCollapsed(editor.selection) || !isRangeAcrossBlocks(editor)) {
|
|
4166
|
+
// selection is collapsed
|
|
4167
|
+
var res = getListItemEntry(editor);
|
|
4168
|
+
|
|
4169
|
+
if (res) {
|
|
4170
|
+
var list = res.list;
|
|
4171
|
+
|
|
4172
|
+
if (list[0].type !== type) {
|
|
4173
|
+
setNodes(editor, {
|
|
4174
|
+
type: type
|
|
4175
|
+
}, {
|
|
4176
|
+
at: editor.selection,
|
|
4177
|
+
match: function match(n) {
|
|
4178
|
+
return listTypes.includes(n.type);
|
|
4179
|
+
},
|
|
4180
|
+
mode: 'lowest'
|
|
4181
|
+
});
|
|
4182
|
+
} else {
|
|
4183
|
+
unwrapList(editor);
|
|
4184
|
+
}
|
|
4185
|
+
} else {
|
|
4186
|
+
var _list = {
|
|
4187
|
+
type: type,
|
|
4188
|
+
children: [],
|
|
4189
|
+
data: {}
|
|
4190
|
+
};
|
|
4191
|
+
wrapNodes(editor, _list);
|
|
4192
|
+
var nodes = [].concat(getNodes(editor, {
|
|
4193
|
+
match: {
|
|
4194
|
+
type: getPluginType(editor, ELEMENT_DEFAULT)
|
|
4195
|
+
}
|
|
4196
|
+
}));
|
|
4197
|
+
var listItem = {
|
|
4198
|
+
type: BLOCKS.LIST_ITEM,
|
|
4199
|
+
children: [],
|
|
4200
|
+
data: {}
|
|
4201
|
+
};
|
|
4202
|
+
|
|
4203
|
+
for (var _iterator = _createForOfIteratorHelperLoose(nodes), _step; !(_step = _iterator()).done;) {
|
|
4204
|
+
var _step$value = _step.value,
|
|
4205
|
+
path = _step$value[1];
|
|
4206
|
+
wrapNodes(editor, listItem, {
|
|
4207
|
+
at: path
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
} else {
|
|
4212
|
+
// selection is a range
|
|
4213
|
+
var _Range$edges = Range.edges(editor.selection),
|
|
4214
|
+
startPoint = _Range$edges[0],
|
|
4215
|
+
endPoint = _Range$edges[1];
|
|
4216
|
+
|
|
4217
|
+
var commonEntry = Node.common(editor, startPoint.path, endPoint.path);
|
|
4218
|
+
|
|
4219
|
+
if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === BLOCKS.LIST_ITEM) {
|
|
4220
|
+
if (commonEntry[0].type !== type) {
|
|
4221
|
+
var startList = findNode(editor, {
|
|
4222
|
+
at: Range.start(editor.selection),
|
|
4223
|
+
match: {
|
|
4224
|
+
type: listTypes
|
|
4225
|
+
},
|
|
4226
|
+
mode: 'lowest'
|
|
4227
|
+
});
|
|
4228
|
+
var endList = findNode(editor, {
|
|
4229
|
+
at: Range.end(editor.selection),
|
|
4230
|
+
match: {
|
|
4231
|
+
type: listTypes
|
|
4232
|
+
},
|
|
4233
|
+
mode: 'lowest'
|
|
4234
|
+
});
|
|
4235
|
+
|
|
4236
|
+
if (!startList || !endList) {
|
|
4237
|
+
return;
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4240
|
+
var rangeLength = Math.min(startList[1].length, endList[1].length);
|
|
4241
|
+
setNodes(editor, {
|
|
4242
|
+
type: type
|
|
4243
|
+
}, {
|
|
4244
|
+
at: editor.selection,
|
|
4245
|
+
match: function match(n, path) {
|
|
4246
|
+
return listTypes.includes(n.type) && path.length >= rangeLength;
|
|
4247
|
+
},
|
|
4248
|
+
mode: 'all'
|
|
4249
|
+
});
|
|
4250
|
+
} else {
|
|
4251
|
+
unwrapList(editor);
|
|
4252
|
+
}
|
|
4253
|
+
} else {
|
|
4254
|
+
var rootPathLength = commonEntry[1].length;
|
|
4255
|
+
|
|
4256
|
+
var _nodes = Array.from(getNodes(editor, {
|
|
4257
|
+
mode: 'all'
|
|
4258
|
+
})).filter(function (_ref3) {
|
|
4259
|
+
var path = _ref3[1];
|
|
4260
|
+
return path.length === rootPathLength + 1;
|
|
4261
|
+
}).reverse();
|
|
4262
|
+
|
|
4263
|
+
_nodes.forEach(function (n) {
|
|
4264
|
+
if (listTypes.includes(n[0].type)) {
|
|
4265
|
+
setNodes(editor, {
|
|
4266
|
+
type: type
|
|
4267
|
+
}, {
|
|
4268
|
+
at: n[1]
|
|
4269
|
+
});
|
|
4270
|
+
} else {
|
|
4271
|
+
setNodes(editor, {
|
|
4272
|
+
type: getPluginType(editor, ELEMENT_LIC)
|
|
4273
|
+
}, {
|
|
4274
|
+
at: n[1]
|
|
4275
|
+
});
|
|
4276
|
+
var _listItem = {
|
|
4277
|
+
type: BLOCKS.LIST_ITEM,
|
|
4278
|
+
children: [],
|
|
4279
|
+
data: {}
|
|
4280
|
+
};
|
|
4281
|
+
wrapNodes(editor, _listItem, {
|
|
4282
|
+
at: n[1]
|
|
4283
|
+
});
|
|
4284
|
+
var _list2 = {
|
|
4285
|
+
type: type,
|
|
4286
|
+
children: [],
|
|
4287
|
+
data: {}
|
|
4288
|
+
};
|
|
4289
|
+
wrapNodes(editor, _list2, {
|
|
4290
|
+
at: n[1]
|
|
4291
|
+
});
|
|
4292
|
+
}
|
|
4293
|
+
});
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
});
|
|
4297
|
+
};
|
|
4298
|
+
|
|
4091
4299
|
function ToolbarListButton(props) {
|
|
4092
4300
|
var sdk = useSdkContext();
|
|
4093
4301
|
var editor = useContentfulEditor();
|
|
@@ -4095,11 +4303,6 @@ function ToolbarListButton(props) {
|
|
|
4095
4303
|
function handleClick(type) {
|
|
4096
4304
|
return function () {
|
|
4097
4305
|
if (!(editor != null && editor.selection)) return;
|
|
4098
|
-
|
|
4099
|
-
if (shouldUnwrapBlockquote(editor, type)) {
|
|
4100
|
-
unwrapFromRoot(editor);
|
|
4101
|
-
}
|
|
4102
|
-
|
|
4103
4306
|
toggleList(editor, {
|
|
4104
4307
|
type: type
|
|
4105
4308
|
});
|
|
@@ -4112,13 +4315,13 @@ function ToolbarListButton(props) {
|
|
|
4112
4315
|
title: "UL",
|
|
4113
4316
|
testId: "ul-toolbar-button",
|
|
4114
4317
|
onClick: handleClick(BLOCKS.UL_LIST),
|
|
4115
|
-
isActive:
|
|
4318
|
+
isActive: isListTypeActive(editor, BLOCKS.UL_LIST),
|
|
4116
4319
|
isDisabled: props.isDisabled
|
|
4117
4320
|
}, /*#__PURE__*/createElement(ListBulletedIcon, null)), isNodeTypeEnabled(sdk.field, BLOCKS.OL_LIST) && /*#__PURE__*/createElement(ToolbarButton, {
|
|
4118
4321
|
title: "OL",
|
|
4119
4322
|
testId: "ol-toolbar-button",
|
|
4120
4323
|
onClick: handleClick(BLOCKS.OL_LIST),
|
|
4121
|
-
isActive:
|
|
4324
|
+
isActive: isListTypeActive(editor, BLOCKS.OL_LIST),
|
|
4122
4325
|
isDisabled: props.isDisabled
|
|
4123
4326
|
}, /*#__PURE__*/createElement(ListNumberedIcon, null)));
|
|
4124
4327
|
}
|
|
@@ -4561,6 +4764,18 @@ function isEmptyElement(element) {
|
|
|
4561
4764
|
return element.textContent === '';
|
|
4562
4765
|
}
|
|
4563
4766
|
|
|
4767
|
+
var buildParagraphKeyDownHandler = function buildParagraphKeyDownHandler(editor, _ref) {
|
|
4768
|
+
var hotkey = _ref.options.hotkey;
|
|
4769
|
+
return function (event) {
|
|
4770
|
+
if (editor.selection && hotkey && isHotkey(hotkey, event)) {
|
|
4771
|
+
toggleElement(editor, {
|
|
4772
|
+
activeType: BLOCKS.PARAGRAPH,
|
|
4773
|
+
inactiveType: BLOCKS.PARAGRAPH
|
|
4774
|
+
});
|
|
4775
|
+
}
|
|
4776
|
+
};
|
|
4777
|
+
};
|
|
4778
|
+
|
|
4564
4779
|
var createParagraphPlugin = function createParagraphPlugin() {
|
|
4565
4780
|
var _transform;
|
|
4566
4781
|
|
|
@@ -4570,6 +4785,9 @@ var createParagraphPlugin = function createParagraphPlugin() {
|
|
|
4570
4785
|
options: {
|
|
4571
4786
|
hotkey: ['mod+opt+0']
|
|
4572
4787
|
},
|
|
4788
|
+
handlers: {
|
|
4789
|
+
onKeyDown: buildParagraphKeyDownHandler
|
|
4790
|
+
},
|
|
4573
4791
|
softBreak: [// create a new line with SHIFT+Enter inside a paragraph
|
|
4574
4792
|
{
|
|
4575
4793
|
hotkey: 'shift+enter',
|
|
@@ -4586,8 +4804,8 @@ var createParagraphPlugin = function createParagraphPlugin() {
|
|
|
4586
4804
|
}
|
|
4587
4805
|
},
|
|
4588
4806
|
normalizer: [{
|
|
4589
|
-
validChildren: function validChildren(_,
|
|
4590
|
-
var node =
|
|
4807
|
+
validChildren: function validChildren(_, _ref2) {
|
|
4808
|
+
var node = _ref2[0];
|
|
4591
4809
|
return isInlineOrText(node);
|
|
4592
4810
|
},
|
|
4593
4811
|
transform: (_transform = {}, _transform[BLOCKS.PARAGRAPH] = transformUnwrap, _transform["default"] = transformLift, _transform)
|
|
@@ -4751,10 +4969,7 @@ var style$1 = /*#__PURE__*/css({
|
|
|
4751
4969
|
margin: '0 0 1.3125rem',
|
|
4752
4970
|
borderLeft: "6px solid " + tokens.gray200,
|
|
4753
4971
|
paddingLeft: '0.875rem',
|
|
4754
|
-
fontStyle: 'normal'
|
|
4755
|
-
'& a': {
|
|
4756
|
-
color: 'inherit'
|
|
4757
|
-
}
|
|
4972
|
+
fontStyle: 'normal'
|
|
4758
4973
|
});
|
|
4759
4974
|
function Quote(props) {
|
|
4760
4975
|
return /*#__PURE__*/createElement("blockquote", Object.assign({}, props.attributes, {
|
|
@@ -4825,7 +5040,7 @@ function createQuotePlugin() {
|
|
|
4825
5040
|
},
|
|
4826
5041
|
normalizer: [{
|
|
4827
5042
|
validChildren: CONTAINERS[BLOCKS.QUOTE],
|
|
4828
|
-
transform: (_transform = {}, _transform[BLOCKS.QUOTE] = transformUnwrap, _transform[
|
|
5043
|
+
transform: (_transform = {}, _transform[BLOCKS.QUOTE] = transformUnwrap, _transform["default"] = transformLift, _transform)
|
|
4829
5044
|
}],
|
|
4830
5045
|
withOverrides: function withOverrides(editor) {
|
|
4831
5046
|
var insertFragment = editor.insertFragment;
|
|
@@ -6157,8 +6372,9 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
6157
6372
|
|
|
6158
6373
|
var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
6159
6374
|
var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
6160
|
-
var id =
|
|
6161
|
-
|
|
6375
|
+
var id = getContentfulEditorId(props.sdk); // TODO: remove in favor of getting the editor from useNormalizedSlateValue after upgrading to Plate v10
|
|
6376
|
+
|
|
6377
|
+
var editor = useContentfulEditor(id);
|
|
6162
6378
|
var plugins = React__default.useMemo(function () {
|
|
6163
6379
|
var _props$onAction;
|
|
6164
6380
|
|
|
@@ -6176,7 +6392,20 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6176
6392
|
var classNames = cx(styles$j.editor, props.minHeight !== undefined ? css({
|
|
6177
6393
|
minHeight: props.minHeight
|
|
6178
6394
|
}) : undefined, props.isDisabled ? styles$j.disabled : styles$j.enabled, props.isToolbarHidden && styles$j.hiddenToolbar);
|
|
6179
|
-
|
|
6395
|
+
useEffect(function () {
|
|
6396
|
+
// Ensure the plate state is cleared after the component unmounts
|
|
6397
|
+
// This prevent new editors for the same field to display old outdated values
|
|
6398
|
+
// Typical scenario: coming back to the entry editor after restoring a previous entry version
|
|
6399
|
+
getPlateActions(id).enabled(true);
|
|
6400
|
+
return function () {
|
|
6401
|
+
return getPlateActions(id).enabled(false);
|
|
6402
|
+
};
|
|
6403
|
+
}, [id]);
|
|
6404
|
+
return /*#__PURE__*/React__default.createElement(SdkProvider, {
|
|
6405
|
+
sdk: props.sdk
|
|
6406
|
+
}, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
|
|
6407
|
+
value: id
|
|
6408
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6180
6409
|
className: styles$j.root,
|
|
6181
6410
|
"data-test-id": "rich-text-editor"
|
|
6182
6411
|
}, /*#__PURE__*/React__default.createElement(Plate, {
|
|
@@ -6193,7 +6422,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6193
6422
|
isDisabled: props.isDisabled
|
|
6194
6423
|
}, /*#__PURE__*/React__default.createElement(Toolbar, {
|
|
6195
6424
|
isDisabled: props.isDisabled
|
|
6196
|
-
}))));
|
|
6425
|
+
}))))));
|
|
6197
6426
|
};
|
|
6198
6427
|
|
|
6199
6428
|
var RichTextEditor = function RichTextEditor(props) {
|
|
@@ -6205,11 +6434,8 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
6205
6434
|
var isEmptyValue = useCallback(function (value) {
|
|
6206
6435
|
return !value || deepEquals(value, EMPTY_DOCUMENT);
|
|
6207
6436
|
}, []);
|
|
6208
|
-
var editorId = getContentfulEditorId(sdk);
|
|
6209
6437
|
return /*#__PURE__*/React__default.createElement(EntityProvider, {
|
|
6210
6438
|
sdk: sdk
|
|
6211
|
-
}, /*#__PURE__*/React__default.createElement(SdkProvider, {
|
|
6212
|
-
sdk: sdk
|
|
6213
6439
|
}, /*#__PURE__*/React__default.createElement(FieldConnector, {
|
|
6214
6440
|
throttle: 0,
|
|
6215
6441
|
field: sdk.field,
|
|
@@ -6221,17 +6447,15 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
6221
6447
|
disabled = _ref.disabled,
|
|
6222
6448
|
setValue = _ref.setValue,
|
|
6223
6449
|
externalReset = _ref.externalReset;
|
|
6224
|
-
return /*#__PURE__*/React__default.createElement(
|
|
6225
|
-
value: editorId
|
|
6226
|
-
}, /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
|
|
6450
|
+
return /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
|
|
6227
6451
|
key: "rich-text-editor-" + externalReset,
|
|
6228
6452
|
value: lastRemoteValue,
|
|
6229
6453
|
sdk: sdk,
|
|
6230
6454
|
onAction: onAction,
|
|
6231
6455
|
isDisabled: disabled,
|
|
6232
6456
|
onChange: setValue
|
|
6233
|
-
}))
|
|
6234
|
-
}))
|
|
6457
|
+
}));
|
|
6458
|
+
}));
|
|
6235
6459
|
};
|
|
6236
6460
|
|
|
6237
6461
|
var LINK_TYPES$1 = {
|