@contentful/field-editor-rich-text 2.0.0-next.17 → 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/README.md +4 -0
- package/dist/ContentfulEditorProvider.d.ts +3 -3
- package/dist/field-editor-rich-text.cjs.development.js +852 -614
- 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 +855 -617
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +2 -0
- package/dist/plugins/List/transforms/toggleList.d.ts +4 -0
- package/dist/test-utils/assertOutput.d.ts +0 -1
- package/package.json +1 -1
|
@@ -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
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,
|
|
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
|
}
|
|
@@ -600,6 +604,13 @@ var focus = function focus(editor) {
|
|
|
600
604
|
}, 0);
|
|
601
605
|
}
|
|
602
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
|
+
}
|
|
603
614
|
|
|
604
615
|
function withLinkTracking(Component) {
|
|
605
616
|
return function ComponentWithTracking(props) {
|
|
@@ -1058,197 +1069,201 @@ function createCommonjsModule(fn, module) {
|
|
|
1058
1069
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
1059
1070
|
}
|
|
1060
1071
|
|
|
1061
|
-
var runtime_1 =
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
var runtime = function (exports) {
|
|
1069
|
-
|
|
1070
|
-
var Op = Object.prototype;
|
|
1071
|
-
var hasOwn = Op.hasOwnProperty;
|
|
1072
|
-
var undefined$1; // More compressible than void 0.
|
|
1073
|
-
|
|
1074
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
1075
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
1076
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
1077
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1078
|
-
|
|
1079
|
-
function define(obj, key, value) {
|
|
1080
|
-
Object.defineProperty(obj, key, {
|
|
1081
|
-
value: value,
|
|
1082
|
-
enumerable: true,
|
|
1083
|
-
configurable: true,
|
|
1084
|
-
writable: true
|
|
1085
|
-
});
|
|
1086
|
-
return obj[key];
|
|
1087
|
-
}
|
|
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
|
+
*/
|
|
1088
1079
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
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
|
+
}
|
|
1097
1107
|
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
// .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 || []);
|
|
1104
1113
|
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1114
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
1115
|
+
// .throw, and .return methods.
|
|
1116
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
1108
1117
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
type: "throw",
|
|
1129
|
-
arg: err
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
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 };
|
|
1132
1137
|
}
|
|
1138
|
+
}
|
|
1133
1139
|
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
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
|
+
});
|
|
1151
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
|
+
}
|
|
1152
1173
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
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
|
+
});
|
|
1156
1192
|
});
|
|
1157
|
-
|
|
1158
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1193
|
+
}
|
|
1159
1194
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
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
|
+
};
|
|
1165
1204
|
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
function defineIteratorMethods(prototype) {
|
|
1174
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
1175
|
-
define(prototype, method, function (arg) {
|
|
1176
|
-
return this._invoke(method, arg);
|
|
1177
|
-
});
|
|
1178
|
-
});
|
|
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");
|
|
1179
1211
|
}
|
|
1212
|
+
genFun.prototype = Object.create(Gp);
|
|
1213
|
+
return genFun;
|
|
1214
|
+
};
|
|
1180
1215
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
};
|
|
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
|
+
};
|
|
1187
1223
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
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);
|
|
1191
1229
|
} else {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
// meant to be awaited.
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
exports.awrap = function (arg) {
|
|
1205
|
-
return {
|
|
1206
|
-
__await: arg
|
|
1207
|
-
};
|
|
1208
|
-
};
|
|
1209
|
-
|
|
1210
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
1211
|
-
function invoke(method, arg, resolve, reject) {
|
|
1212
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
1213
|
-
|
|
1214
|
-
if (record.type === "throw") {
|
|
1215
|
-
reject(record.arg);
|
|
1216
|
-
} else {
|
|
1217
|
-
var result = record.arg;
|
|
1218
|
-
var value = result.value;
|
|
1219
|
-
|
|
1220
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
1221
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1222
|
-
invoke("next", value, resolve, reject);
|
|
1223
|
-
}, function (err) {
|
|
1224
|
-
invoke("throw", err, resolve, reject);
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1229
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
1230
|
-
// the .value of the Promise<{value,done}> result for the
|
|
1231
|
-
// current iteration.
|
|
1232
|
-
result.value = unwrapped;
|
|
1233
|
-
resolve(result);
|
|
1234
|
-
}, function (error) {
|
|
1235
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
1236
|
-
// into the async generator function so it can be handled there.
|
|
1237
|
-
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);
|
|
1238
1239
|
});
|
|
1239
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
|
+
});
|
|
1240
1253
|
}
|
|
1254
|
+
}
|
|
1241
1255
|
|
|
1242
|
-
|
|
1256
|
+
var previousPromise;
|
|
1243
1257
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1258
|
+
function enqueue(method, arg) {
|
|
1259
|
+
function callInvokeWithMethodAndArg() {
|
|
1260
|
+
return new PromiseImpl(function(resolve, reject) {
|
|
1261
|
+
invoke(method, arg, resolve, reject);
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1250
1264
|
|
|
1251
|
-
|
|
1265
|
+
return previousPromise =
|
|
1266
|
+
// If enqueue has been called before, then we want to wait until
|
|
1252
1267
|
// all previous Promises have been resolved before calling invoke,
|
|
1253
1268
|
// so that results are always delivered in the correct order. If
|
|
1254
1269
|
// enqueue has not been called before, then it is important to
|
|
@@ -1260,527 +1275,554 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1260
1275
|
// execute code before the first await. Since we implement simple
|
|
1261
1276
|
// async functions in terms of async generators, it is especially
|
|
1262
1277
|
// important to get this right, even though it requires care.
|
|
1263
|
-
previousPromise ? previousPromise.then(
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
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();
|
|
1271
1284
|
}
|
|
1272
1285
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
1278
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
1279
|
-
// the final result produced by the iterator.
|
|
1280
|
-
|
|
1281
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1282
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
1283
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1284
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
1285
|
-
: iter.next().then(function (result) {
|
|
1286
|
-
return result.done ? result.value : iter.next();
|
|
1287
|
-
});
|
|
1288
|
-
};
|
|
1286
|
+
// Define the unified helper method that is used to implement .next,
|
|
1287
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
1288
|
+
this._invoke = enqueue;
|
|
1289
|
+
}
|
|
1289
1290
|
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
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
|
+
};
|
|
1296
1314
|
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
throw arg;
|
|
1300
|
-
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
1301
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
1315
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
1316
|
+
var state = GenStateSuspendedStart;
|
|
1302
1317
|
|
|
1318
|
+
return function invoke(method, arg) {
|
|
1319
|
+
if (state === GenStateExecuting) {
|
|
1320
|
+
throw new Error("Generator is already running");
|
|
1321
|
+
}
|
|
1303
1322
|
|
|
1304
|
-
|
|
1323
|
+
if (state === GenStateCompleted) {
|
|
1324
|
+
if (method === "throw") {
|
|
1325
|
+
throw arg;
|
|
1305
1326
|
}
|
|
1306
1327
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
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
|
+
}
|
|
1312
1332
|
|
|
1313
|
-
|
|
1314
|
-
|
|
1333
|
+
context.method = method;
|
|
1334
|
+
context.arg = arg;
|
|
1315
1335
|
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
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;
|
|
1320
1343
|
}
|
|
1344
|
+
}
|
|
1321
1345
|
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
} else if (context.method === "throw") {
|
|
1327
|
-
if (state === GenStateSuspendedStart) {
|
|
1328
|
-
state = GenStateCompleted;
|
|
1329
|
-
throw context.arg;
|
|
1330
|
-
}
|
|
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;
|
|
1331
1350
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1351
|
+
} else if (context.method === "throw") {
|
|
1352
|
+
if (state === GenStateSuspendedStart) {
|
|
1353
|
+
state = GenStateCompleted;
|
|
1354
|
+
throw context.arg;
|
|
1335
1355
|
}
|
|
1336
1356
|
|
|
1337
|
-
|
|
1338
|
-
var record = tryCatch(innerFn, self, context);
|
|
1357
|
+
context.dispatchException(context.arg);
|
|
1339
1358
|
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
1359
|
+
} else if (context.method === "return") {
|
|
1360
|
+
context.abrupt("return", context.arg);
|
|
1361
|
+
}
|
|
1344
1362
|
|
|
1345
|
-
|
|
1346
|
-
continue;
|
|
1347
|
-
}
|
|
1363
|
+
state = GenStateExecuting;
|
|
1348
1364
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
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;
|
|
1356
1372
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
1363
|
-
// result, either by returning a { value, done } result from the
|
|
1364
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
1365
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
1369
|
-
var method = delegate.iterator[context.method];
|
|
1370
|
-
|
|
1371
|
-
if (method === undefined$1) {
|
|
1372
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
1373
|
-
// method always terminates the yield* loop.
|
|
1374
|
-
context.delegate = null;
|
|
1375
|
-
|
|
1376
|
-
if (context.method === "throw") {
|
|
1377
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
1378
|
-
if (delegate.iterator["return"]) {
|
|
1379
|
-
// If the delegate iterator has a return method, give it a
|
|
1380
|
-
// chance to clean up.
|
|
1381
|
-
context.method = "return";
|
|
1382
|
-
context.arg = undefined$1;
|
|
1383
|
-
maybeInvokeDelegate(delegate, context);
|
|
1384
|
-
|
|
1385
|
-
if (context.method === "throw") {
|
|
1386
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
1387
|
-
// "return" to "throw", let that override the TypeError below.
|
|
1388
|
-
return ContinueSentinel;
|
|
1389
|
-
}
|
|
1373
|
+
if (record.arg === ContinueSentinel) {
|
|
1374
|
+
continue;
|
|
1390
1375
|
}
|
|
1391
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.
|
|
1392
1386
|
context.method = "throw";
|
|
1393
|
-
context.arg =
|
|
1387
|
+
context.arg = record.arg;
|
|
1394
1388
|
}
|
|
1395
|
-
|
|
1396
|
-
return ContinueSentinel;
|
|
1397
1389
|
}
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1398
1392
|
|
|
1399
|
-
|
|
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;
|
|
1400
1403
|
|
|
1401
|
-
if (
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
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);
|
|
1407
1412
|
|
|
1408
|
-
|
|
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
|
+
}
|
|
1409
1419
|
|
|
1410
|
-
if (!info) {
|
|
1411
1420
|
context.method = "throw";
|
|
1412
|
-
context.arg = new TypeError(
|
|
1413
|
-
|
|
1414
|
-
return ContinueSentinel;
|
|
1421
|
+
context.arg = new TypeError(
|
|
1422
|
+
"The iterator does not provide a 'throw' method");
|
|
1415
1423
|
}
|
|
1416
1424
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
1420
|
-
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
1421
|
-
|
|
1422
|
-
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
1423
|
-
// exception, let the outer generator proceed normally. If
|
|
1424
|
-
// context.method was "next", forget context.arg since it has been
|
|
1425
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
1426
|
-
// "return", allow the original .return call to continue in the
|
|
1427
|
-
// outer generator.
|
|
1428
|
-
|
|
1429
|
-
if (context.method !== "return") {
|
|
1430
|
-
context.method = "next";
|
|
1431
|
-
context.arg = undefined$1;
|
|
1432
|
-
}
|
|
1433
|
-
} else {
|
|
1434
|
-
// Re-yield the result returned by the delegate method.
|
|
1435
|
-
return info;
|
|
1436
|
-
} // The delegate iterator is finished, so forget it and continue with
|
|
1437
|
-
// the outer generator.
|
|
1425
|
+
return ContinueSentinel;
|
|
1426
|
+
}
|
|
1438
1427
|
|
|
1428
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1439
1429
|
|
|
1430
|
+
if (record.type === "throw") {
|
|
1431
|
+
context.method = "throw";
|
|
1432
|
+
context.arg = record.arg;
|
|
1440
1433
|
context.delegate = null;
|
|
1441
1434
|
return ContinueSentinel;
|
|
1442
|
-
}
|
|
1443
|
-
// unified ._invoke helper method.
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
defineIteratorMethods(Gp);
|
|
1447
|
-
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
1448
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
1449
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
1450
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
1451
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1452
|
-
|
|
1453
|
-
define(Gp, iteratorSymbol, function () {
|
|
1454
|
-
return this;
|
|
1455
|
-
});
|
|
1456
|
-
define(Gp, "toString", function () {
|
|
1457
|
-
return "[object Generator]";
|
|
1458
|
-
});
|
|
1435
|
+
}
|
|
1459
1436
|
|
|
1460
|
-
|
|
1461
|
-
var entry = {
|
|
1462
|
-
tryLoc: locs[0]
|
|
1463
|
-
};
|
|
1437
|
+
var info = record.arg;
|
|
1464
1438
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
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
|
+
}
|
|
1468
1445
|
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
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;
|
|
1472
1463
|
}
|
|
1473
1464
|
|
|
1474
|
-
|
|
1465
|
+
} else {
|
|
1466
|
+
// Re-yield the result returned by the delegate method.
|
|
1467
|
+
return info;
|
|
1475
1468
|
}
|
|
1476
1469
|
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1470
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
1471
|
+
// the outer generator.
|
|
1472
|
+
context.delegate = null;
|
|
1473
|
+
return ContinueSentinel;
|
|
1474
|
+
}
|
|
1483
1475
|
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
// locations where there is no enclosing try statement.
|
|
1488
|
-
this.tryEntries = [{
|
|
1489
|
-
tryLoc: "root"
|
|
1490
|
-
}];
|
|
1491
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
1492
|
-
this.reset(true);
|
|
1493
|
-
}
|
|
1476
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
1477
|
+
// unified ._invoke helper method.
|
|
1478
|
+
defineIteratorMethods(Gp);
|
|
1494
1479
|
|
|
1495
|
-
|
|
1496
|
-
var keys = [];
|
|
1480
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
1497
1481
|
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
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
|
+
});
|
|
1501
1490
|
|
|
1502
|
-
|
|
1503
|
-
|
|
1491
|
+
define(Gp, "toString", function() {
|
|
1492
|
+
return "[object Generator]";
|
|
1493
|
+
});
|
|
1504
1494
|
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
var key = keys.pop();
|
|
1495
|
+
function pushTryEntry(locs) {
|
|
1496
|
+
var entry = { tryLoc: locs[0] };
|
|
1508
1497
|
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
return next;
|
|
1513
|
-
}
|
|
1514
|
-
} // To avoid creating an additional object, we just hang the .value
|
|
1515
|
-
// and .done properties off the next function object itself. This
|
|
1516
|
-
// also ensures that the minifier will not anonymize the function.
|
|
1498
|
+
if (1 in locs) {
|
|
1499
|
+
entry.catchLoc = locs[1];
|
|
1500
|
+
}
|
|
1517
1501
|
|
|
1502
|
+
if (2 in locs) {
|
|
1503
|
+
entry.finallyLoc = locs[2];
|
|
1504
|
+
entry.afterLoc = locs[3];
|
|
1505
|
+
}
|
|
1518
1506
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
};
|
|
1522
|
-
};
|
|
1507
|
+
this.tryEntries.push(entry);
|
|
1508
|
+
}
|
|
1523
1509
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1510
|
+
function resetTryEntry(entry) {
|
|
1511
|
+
var record = entry.completion || {};
|
|
1512
|
+
record.type = "normal";
|
|
1513
|
+
delete record.arg;
|
|
1514
|
+
entry.completion = record;
|
|
1515
|
+
}
|
|
1527
1516
|
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
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
|
+
}
|
|
1531
1525
|
|
|
1532
|
-
|
|
1533
|
-
|
|
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;
|
|
1534
1542
|
}
|
|
1543
|
+
}
|
|
1535
1544
|
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
return next;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
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
|
+
};
|
|
1546
1552
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1553
|
+
function values(iterable) {
|
|
1554
|
+
if (iterable) {
|
|
1555
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1556
|
+
if (iteratorMethod) {
|
|
1557
|
+
return iteratorMethod.call(iterable);
|
|
1558
|
+
}
|
|
1551
1559
|
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
}
|
|
1560
|
+
if (typeof iterable.next === "function") {
|
|
1561
|
+
return iterable;
|
|
1562
|
+
}
|
|
1555
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
|
+
}
|
|
1556
1573
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
};
|
|
1560
|
-
}
|
|
1574
|
+
next.value = undefined$1;
|
|
1575
|
+
next.done = true;
|
|
1561
1576
|
|
|
1562
|
-
|
|
1577
|
+
return next;
|
|
1578
|
+
};
|
|
1563
1579
|
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
value: undefined$1,
|
|
1567
|
-
done: true
|
|
1568
|
-
};
|
|
1580
|
+
return next.next = next;
|
|
1581
|
+
}
|
|
1569
1582
|
}
|
|
1570
1583
|
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
1576
|
-
// function.sent implementation.
|
|
1584
|
+
// Return an iterator with no values.
|
|
1585
|
+
return { next: doneResult };
|
|
1586
|
+
}
|
|
1587
|
+
exports.values = values;
|
|
1577
1588
|
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
this.method = "next";
|
|
1582
|
-
this.arg = undefined$1;
|
|
1583
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
1589
|
+
function doneResult() {
|
|
1590
|
+
return { value: undefined$1, done: true };
|
|
1591
|
+
}
|
|
1584
1592
|
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
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;
|
|
1591
1617
|
}
|
|
1592
1618
|
}
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
this.done = true;
|
|
1596
|
-
var rootEntry = this.tryEntries[0];
|
|
1597
|
-
var rootRecord = rootEntry.completion;
|
|
1619
|
+
}
|
|
1620
|
+
},
|
|
1598
1621
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
}
|
|
1622
|
+
stop: function() {
|
|
1623
|
+
this.done = true;
|
|
1602
1624
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
}
|
|
1625
|
+
var rootEntry = this.tryEntries[0];
|
|
1626
|
+
var rootRecord = rootEntry.completion;
|
|
1627
|
+
if (rootRecord.type === "throw") {
|
|
1628
|
+
throw rootRecord.arg;
|
|
1629
|
+
}
|
|
1609
1630
|
|
|
1610
|
-
|
|
1631
|
+
return this.rval;
|
|
1632
|
+
},
|
|
1611
1633
|
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1634
|
+
dispatchException: function(exception) {
|
|
1635
|
+
if (this.done) {
|
|
1636
|
+
throw exception;
|
|
1637
|
+
}
|
|
1616
1638
|
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
}
|
|
1639
|
+
var context = this;
|
|
1640
|
+
function handle(loc, caught) {
|
|
1641
|
+
record.type = "throw";
|
|
1642
|
+
record.arg = exception;
|
|
1643
|
+
context.next = loc;
|
|
1623
1644
|
|
|
1624
|
-
|
|
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;
|
|
1625
1650
|
}
|
|
1626
1651
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
var record = entry.completion;
|
|
1652
|
+
return !! caught;
|
|
1653
|
+
}
|
|
1630
1654
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
// throw the exception.
|
|
1635
|
-
return handle("end");
|
|
1636
|
-
}
|
|
1655
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1656
|
+
var entry = this.tryEntries[i];
|
|
1657
|
+
var record = entry.completion;
|
|
1637
1658
|
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
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
|
+
}
|
|
1641
1665
|
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
} else {
|
|
1657
|
-
throw new Error("try statement without catch or finally");
|
|
1666
|
+
if (entry.tryLoc <= this.prev) {
|
|
1667
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1668
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1669
|
+
|
|
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);
|
|
1658
1680
|
}
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
},
|
|
1662
|
-
abrupt: function abrupt(type, arg) {
|
|
1663
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1664
|
-
var entry = this.tryEntries[i];
|
|
1665
1681
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1682
|
+
} else if (hasFinally) {
|
|
1683
|
+
if (this.prev < entry.finallyLoc) {
|
|
1684
|
+
return handle(entry.finallyLoc);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
} else {
|
|
1688
|
+
throw new Error("try statement without catch or finally");
|
|
1669
1689
|
}
|
|
1670
1690
|
}
|
|
1691
|
+
}
|
|
1692
|
+
},
|
|
1671
1693
|
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
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;
|
|
1676
1702
|
}
|
|
1703
|
+
}
|
|
1677
1704
|
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
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
|
+
}
|
|
1681
1714
|
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
return ContinueSentinel;
|
|
1686
|
-
}
|
|
1715
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1716
|
+
record.type = type;
|
|
1717
|
+
record.arg = arg;
|
|
1687
1718
|
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
}
|
|
1719
|
+
if (finallyEntry) {
|
|
1720
|
+
this.method = "next";
|
|
1721
|
+
this.next = finallyEntry.finallyLoc;
|
|
1722
|
+
return ContinueSentinel;
|
|
1723
|
+
}
|
|
1694
1724
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
} else if (record.type === "return") {
|
|
1698
|
-
this.rval = this.arg = record.arg;
|
|
1699
|
-
this.method = "return";
|
|
1700
|
-
this.next = "end";
|
|
1701
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
1702
|
-
this.next = afterLoc;
|
|
1703
|
-
}
|
|
1725
|
+
return this.complete(record);
|
|
1726
|
+
},
|
|
1704
1727
|
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
var entry = this.tryEntries[i];
|
|
1728
|
+
complete: function(record, afterLoc) {
|
|
1729
|
+
if (record.type === "throw") {
|
|
1730
|
+
throw record.arg;
|
|
1731
|
+
}
|
|
1710
1732
|
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
"
|
|
1719
|
-
|
|
1720
|
-
|
|
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
|
+
}
|
|
1721
1743
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1744
|
+
return ContinueSentinel;
|
|
1745
|
+
},
|
|
1724
1746
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
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
|
+
},
|
|
1729
1757
|
|
|
1730
|
-
|
|
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);
|
|
1731
1766
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1767
|
+
return thrown;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1735
1770
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
iterator: values(iterable),
|
|
1741
|
-
resultName: resultName,
|
|
1742
|
-
nextLoc: nextLoc
|
|
1743
|
-
};
|
|
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
|
+
},
|
|
1744
1775
|
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1776
|
+
delegateYield: function(iterable, resultName, nextLoc) {
|
|
1777
|
+
this.delegate = {
|
|
1778
|
+
iterator: values(iterable),
|
|
1779
|
+
resultName: resultName,
|
|
1780
|
+
nextLoc: nextLoc
|
|
1781
|
+
};
|
|
1750
1782
|
|
|
1751
|
-
|
|
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;
|
|
1752
1787
|
}
|
|
1753
|
-
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1754
|
-
// or not, return the runtime object so that we can declare the variable
|
|
1755
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1756
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1757
1788
|
|
|
1758
|
-
|
|
1759
|
-
|
|
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
|
|
1760
1801
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1761
1802
|
// object. Either way, the resulting object will be used to initialize
|
|
1762
1803
|
// the regeneratorRuntime variable at the top of this file.
|
|
1763
|
-
module.exports
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
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);
|
|
1783
1824
|
}
|
|
1825
|
+
}
|
|
1784
1826
|
});
|
|
1785
1827
|
|
|
1786
1828
|
/* eslint-disable you-dont-need-lodash-underscore/find */
|
|
@@ -2491,7 +2533,7 @@ function ToolbarHeadingButton(props) {
|
|
|
2491
2533
|
var prevOnChange = editor.onChange;
|
|
2492
2534
|
/*
|
|
2493
2535
|
The focus might happen at point in time when
|
|
2494
|
-
`
|
|
2536
|
+
`toggleElement` (helper for toggleNodeType) changes aren't rendered yet, causing the browser
|
|
2495
2537
|
to place the cursor at the start of the text.
|
|
2496
2538
|
We wait for the change event before focusing
|
|
2497
2539
|
the editor again. This ensures the cursor is back at the previous
|
|
@@ -2507,7 +2549,7 @@ function ToolbarHeadingButton(props) {
|
|
|
2507
2549
|
editor.tracking.onToolbarAction(isActive ? 'remove' : 'insert', {
|
|
2508
2550
|
nodeType: type
|
|
2509
2551
|
});
|
|
2510
|
-
|
|
2552
|
+
toggleElement(editor, {
|
|
2511
2553
|
activeType: type,
|
|
2512
2554
|
inactiveType: type
|
|
2513
2555
|
});
|
|
@@ -2637,7 +2679,7 @@ var buildHeadingEventHandler = function buildHeadingEventHandler(type) {
|
|
|
2637
2679
|
editor.tracking.onShortcutAction(isActive ? 'remove' : 'insert', {
|
|
2638
2680
|
nodeType: type
|
|
2639
2681
|
});
|
|
2640
|
-
|
|
2682
|
+
toggleElement(editor, {
|
|
2641
2683
|
activeType: type,
|
|
2642
2684
|
inactiveType: BLOCKS.PARAGRAPH
|
|
2643
2685
|
});
|
|
@@ -3861,7 +3903,7 @@ var listBreak = function listBreak(editor) {
|
|
|
3861
3903
|
return !moved && isBlockAboveEmpty(editor);
|
|
3862
3904
|
},
|
|
3863
3905
|
onReset: function onReset(_editor) {
|
|
3864
|
-
return unwrapList(_editor);
|
|
3906
|
+
return unwrapList$1(_editor);
|
|
3865
3907
|
}
|
|
3866
3908
|
}]
|
|
3867
3909
|
}
|
|
@@ -4082,6 +4124,178 @@ var createListPlugin = function createListPlugin() {
|
|
|
4082
4124
|
});
|
|
4083
4125
|
};
|
|
4084
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
|
+
|
|
4085
4299
|
function ToolbarListButton(props) {
|
|
4086
4300
|
var sdk = useSdkContext();
|
|
4087
4301
|
var editor = useContentfulEditor();
|
|
@@ -4550,6 +4764,18 @@ function isEmptyElement(element) {
|
|
|
4550
4764
|
return element.textContent === '';
|
|
4551
4765
|
}
|
|
4552
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
|
+
|
|
4553
4779
|
var createParagraphPlugin = function createParagraphPlugin() {
|
|
4554
4780
|
var _transform;
|
|
4555
4781
|
|
|
@@ -4559,6 +4785,9 @@ var createParagraphPlugin = function createParagraphPlugin() {
|
|
|
4559
4785
|
options: {
|
|
4560
4786
|
hotkey: ['mod+opt+0']
|
|
4561
4787
|
},
|
|
4788
|
+
handlers: {
|
|
4789
|
+
onKeyDown: buildParagraphKeyDownHandler
|
|
4790
|
+
},
|
|
4562
4791
|
softBreak: [// create a new line with SHIFT+Enter inside a paragraph
|
|
4563
4792
|
{
|
|
4564
4793
|
hotkey: 'shift+enter',
|
|
@@ -4575,8 +4804,8 @@ var createParagraphPlugin = function createParagraphPlugin() {
|
|
|
4575
4804
|
}
|
|
4576
4805
|
},
|
|
4577
4806
|
normalizer: [{
|
|
4578
|
-
validChildren: function validChildren(_,
|
|
4579
|
-
var node =
|
|
4807
|
+
validChildren: function validChildren(_, _ref2) {
|
|
4808
|
+
var node = _ref2[0];
|
|
4580
4809
|
return isInlineOrText(node);
|
|
4581
4810
|
},
|
|
4582
4811
|
transform: (_transform = {}, _transform[BLOCKS.PARAGRAPH] = transformUnwrap, _transform["default"] = transformLift, _transform)
|
|
@@ -6143,8 +6372,9 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
6143
6372
|
|
|
6144
6373
|
var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
6145
6374
|
var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
6146
|
-
var id =
|
|
6147
|
-
|
|
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);
|
|
6148
6378
|
var plugins = React__default.useMemo(function () {
|
|
6149
6379
|
var _props$onAction;
|
|
6150
6380
|
|
|
@@ -6162,7 +6392,20 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6162
6392
|
var classNames = cx(styles$j.editor, props.minHeight !== undefined ? css({
|
|
6163
6393
|
minHeight: props.minHeight
|
|
6164
6394
|
}) : undefined, props.isDisabled ? styles$j.disabled : styles$j.enabled, props.isToolbarHidden && styles$j.hiddenToolbar);
|
|
6165
|
-
|
|
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", {
|
|
6166
6409
|
className: styles$j.root,
|
|
6167
6410
|
"data-test-id": "rich-text-editor"
|
|
6168
6411
|
}, /*#__PURE__*/React__default.createElement(Plate, {
|
|
@@ -6179,7 +6422,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6179
6422
|
isDisabled: props.isDisabled
|
|
6180
6423
|
}, /*#__PURE__*/React__default.createElement(Toolbar, {
|
|
6181
6424
|
isDisabled: props.isDisabled
|
|
6182
|
-
}))));
|
|
6425
|
+
}))))));
|
|
6183
6426
|
};
|
|
6184
6427
|
|
|
6185
6428
|
var RichTextEditor = function RichTextEditor(props) {
|
|
@@ -6191,11 +6434,8 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
6191
6434
|
var isEmptyValue = useCallback(function (value) {
|
|
6192
6435
|
return !value || deepEquals(value, EMPTY_DOCUMENT);
|
|
6193
6436
|
}, []);
|
|
6194
|
-
var editorId = getContentfulEditorId(sdk);
|
|
6195
6437
|
return /*#__PURE__*/React__default.createElement(EntityProvider, {
|
|
6196
6438
|
sdk: sdk
|
|
6197
|
-
}, /*#__PURE__*/React__default.createElement(SdkProvider, {
|
|
6198
|
-
sdk: sdk
|
|
6199
6439
|
}, /*#__PURE__*/React__default.createElement(FieldConnector, {
|
|
6200
6440
|
throttle: 0,
|
|
6201
6441
|
field: sdk.field,
|
|
@@ -6207,17 +6447,15 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
6207
6447
|
disabled = _ref.disabled,
|
|
6208
6448
|
setValue = _ref.setValue,
|
|
6209
6449
|
externalReset = _ref.externalReset;
|
|
6210
|
-
return /*#__PURE__*/React__default.createElement(
|
|
6211
|
-
value: editorId
|
|
6212
|
-
}, /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
|
|
6450
|
+
return /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
|
|
6213
6451
|
key: "rich-text-editor-" + externalReset,
|
|
6214
6452
|
value: lastRemoteValue,
|
|
6215
6453
|
sdk: sdk,
|
|
6216
6454
|
onAction: onAction,
|
|
6217
6455
|
isDisabled: disabled,
|
|
6218
6456
|
onChange: setValue
|
|
6219
|
-
}))
|
|
6220
|
-
}))
|
|
6457
|
+
}));
|
|
6458
|
+
}));
|
|
6221
6459
|
};
|
|
6222
6460
|
|
|
6223
6461
|
var LINK_TYPES$1 = {
|