@contentful/field-editor-rich-text 2.0.0-next.19 → 2.0.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/field-editor-rich-text.cjs.development.js +1058 -971
- 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 +1060 -973
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +2 -2
- package/dist/plugins/Break/createResetNodePlugin.d.ts +2 -0
- package/dist/plugins/Break/index.d.ts +2 -0
- package/dist/plugins/Hyperlink/components/EntityHyperlink.d.ts +9 -0
- package/dist/plugins/Hyperlink/components/ToolbarHyperlinkButton.d.ts +5 -0
- package/dist/plugins/Hyperlink/components/UrlHyperlink.d.ts +9 -0
- package/dist/plugins/Hyperlink/components/styles.d.ts +4 -0
- package/dist/plugins/Hyperlink/createHyperlinkPlugin.d.ts +3 -0
- package/dist/plugins/Hyperlink/index.d.ts +2 -8
- package/dist/plugins/Hyperlink/useEntityInfo.d.ts +16 -0
- package/dist/plugins/Hyperlink/utils.d.ts +2 -0
- package/dist/plugins/List/transforms/deleteBackwardList.d.ts +2 -0
- package/dist/plugins/List/transforms/unwrapList.d.ts +5 -0
- package/dist/plugins/Quote/shouldResetQuote.d.ts +8 -0
- package/dist/plugins/Quote/toggleQuote.d.ts +2 -2
- package/dist/plugins/Quote/withQuote.d.ts +3 -0
- package/dist/types.d.ts +5 -1
- package/package.json +2 -1
- package/dist/plugins/Hyperlink/EntryAssetTooltip.d.ts +0 -9
- package/dist/plugins/Hyperlink/truncate.d.ts +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React__default, { createContext, useContext, useMemo, createElement, useEffect, useState, memo, Fragment, useCallback } from 'react';
|
|
2
|
-
import { useEntities, ScheduledIconWithTooltip, MissingEntityCard, AssetThumbnail,
|
|
2
|
+
import { useEntities, ScheduledIconWithTooltip, MissingEntityCard, AssetThumbnail, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
|
|
3
3
|
import { entityHelpers, shortenStorageUnit, isValidImage, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
|
|
4
4
|
import { BLOCKS, INLINES, TABLE_BLOCKS, TEXT_CONTAINERS, HEADINGS, LIST_ITEM_BLOCKS, MARKS, CONTAINERS, TOP_LEVEL_BLOCKS, VOID_BLOCKS, EMPTY_DOCUMENT } from '@contentful/rich-text-types';
|
|
5
|
-
import { usePlateEditorState, usePlateEditorRef, getNodes, toggleNodeType, getText, getAbove, setNodes, isAncestorEmpty, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, getPluginType, ELEMENT_DEFAULT, findNode, isCollapsed, isRangeAcrossBlocks, wrapNodes,
|
|
5
|
+
import { usePlateEditorState, usePlateEditorRef, getNodes, toggleNodeType, getText, getAbove, setNodes, isAncestorEmpty, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, getPluginType, ELEMENT_DEFAULT, findNode, unwrapNodes, deleteFragment, isCollapsed, isRangeAcrossBlocks, wrapNodes, isMarkActive, toggleMark, someHtmlElement, match, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, getLastChildPath, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateActions, Plate } from '@udecode/plate-core';
|
|
6
6
|
import { css, cx } from 'emotion';
|
|
7
7
|
import deepEquals from 'fast-deep-equal';
|
|
8
8
|
import noop from 'lodash-es/noop';
|
|
9
9
|
import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
|
|
10
10
|
import { createSoftBreakPlugin as createSoftBreakPlugin$1, createExitBreakPlugin as createExitBreakPlugin$1 } from '@udecode/plate-break';
|
|
11
|
+
import { createResetNodePlugin as createResetNodePlugin$1, onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
|
|
11
12
|
import isHotkey from 'is-hotkey';
|
|
12
13
|
import { Text, Element, Editor, Transforms, Range, Node, Path, Point } from 'slate';
|
|
13
14
|
import { ReactEditor, useSelected, useReadOnly, useFocused } from 'slate-react';
|
|
@@ -19,8 +20,7 @@ import { ClockIcon, AssetIcon, EmbeddedEntryBlockIcon, EmbeddedEntryInlineIcon,
|
|
|
19
20
|
import tokens from '@contentful/f36-tokens';
|
|
20
21
|
import find from 'lodash-es/find';
|
|
21
22
|
import flow from 'lodash-es/flow';
|
|
22
|
-
import { getListItemEntry, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1,
|
|
23
|
-
import { onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
|
|
23
|
+
import { getListItemEntry, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, removeFirstListItem, removeListItem, isListNested, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL, ELEMENT_LIC } from '@udecode/plate-list';
|
|
24
24
|
import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1 } from '@udecode/plate-basic-marks';
|
|
25
25
|
import isPlainObject from 'is-plain-obj';
|
|
26
26
|
import { createParagraphPlugin as createParagraphPlugin$1 } from '@udecode/plate-paragraph';
|
|
@@ -307,6 +307,33 @@ var createExitBreakPlugin = function createExitBreakPlugin() {
|
|
|
307
307
|
});
|
|
308
308
|
};
|
|
309
309
|
|
|
310
|
+
var createResetNodePlugin = function createResetNodePlugin() {
|
|
311
|
+
return createResetNodePlugin$1({
|
|
312
|
+
options: {
|
|
313
|
+
rules: []
|
|
314
|
+
},
|
|
315
|
+
then: function then(editor) {
|
|
316
|
+
var rules = editor.plugins.flatMap(function (p) {
|
|
317
|
+
return p.resetNode || [];
|
|
318
|
+
}); // set defaultType to Paragraph if not set
|
|
319
|
+
|
|
320
|
+
for (var _iterator = _createForOfIteratorHelperLoose(rules), _step; !(_step = _iterator()).done;) {
|
|
321
|
+
var rule = _step.value;
|
|
322
|
+
|
|
323
|
+
if (!rule.defaultType) {
|
|
324
|
+
rule.defaultType = BLOCKS.PARAGRAPH;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
options: {
|
|
330
|
+
rules: rules
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
|
|
310
337
|
function createDragAndDropPlugin() {
|
|
311
338
|
var DRAGGABLE_TYPES = [BLOCKS.EMBEDDED_ENTRY, BLOCKS.EMBEDDED_ASSET, BLOCKS.HR, INLINES.EMBEDDED_ENTRY];
|
|
312
339
|
/**
|
|
@@ -1086,201 +1113,197 @@ function createCommonjsModule(fn, module) {
|
|
|
1086
1113
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
1087
1114
|
}
|
|
1088
1115
|
|
|
1089
|
-
var runtime_1 = createCommonjsModule(function (module) {
|
|
1090
|
-
/**
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1116
|
+
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
1117
|
+
/**
|
|
1118
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
1119
|
+
*
|
|
1120
|
+
* This source code is licensed under the MIT license found in the
|
|
1121
|
+
* LICENSE file in the root directory of this source tree.
|
|
1122
|
+
*/
|
|
1123
|
+
var runtime = function (exports) {
|
|
1124
|
+
|
|
1125
|
+
var Op = Object.prototype;
|
|
1126
|
+
var hasOwn = Op.hasOwnProperty;
|
|
1127
|
+
var undefined$1; // More compressible than void 0.
|
|
1128
|
+
|
|
1129
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
1130
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
1131
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
1132
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1133
|
+
|
|
1134
|
+
function define(obj, key, value) {
|
|
1135
|
+
Object.defineProperty(obj, key, {
|
|
1136
|
+
value: value,
|
|
1137
|
+
enumerable: true,
|
|
1138
|
+
configurable: true,
|
|
1139
|
+
writable: true
|
|
1140
|
+
});
|
|
1141
|
+
return obj[key];
|
|
1142
|
+
}
|
|
1096
1143
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1106
|
-
|
|
1107
|
-
function define(obj, key, value) {
|
|
1108
|
-
Object.defineProperty(obj, key, {
|
|
1109
|
-
value: value,
|
|
1110
|
-
enumerable: true,
|
|
1111
|
-
configurable: true,
|
|
1112
|
-
writable: true
|
|
1113
|
-
});
|
|
1114
|
-
return obj[key];
|
|
1115
|
-
}
|
|
1116
|
-
try {
|
|
1117
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
1118
|
-
define({}, "");
|
|
1119
|
-
} catch (err) {
|
|
1120
|
-
define = function(obj, key, value) {
|
|
1121
|
-
return obj[key] = value;
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1144
|
+
try {
|
|
1145
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
1146
|
+
define({}, "");
|
|
1147
|
+
} catch (err) {
|
|
1148
|
+
define = function define(obj, key, value) {
|
|
1149
|
+
return obj[key] = value;
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1124
1152
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1153
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1154
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
1155
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
1156
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
1157
|
+
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
1158
|
+
// .throw, and .return methods.
|
|
1130
1159
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1160
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
1161
|
+
return generator;
|
|
1162
|
+
}
|
|
1134
1163
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1164
|
+
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
1165
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
1166
|
+
// have been (and was previously) designed to take a closure to be
|
|
1167
|
+
// invoked without arguments, but in all the cases we care about we
|
|
1168
|
+
// already have an existing method we want to call, so there's no need
|
|
1169
|
+
// to create a new function object. We can even get away with assuming
|
|
1170
|
+
// the method takes exactly one argument, since that happens to be true
|
|
1171
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
1172
|
+
// only additional allocation required is the completion record, which
|
|
1173
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
1174
|
+
|
|
1175
|
+
function tryCatch(fn, obj, arg) {
|
|
1176
|
+
try {
|
|
1177
|
+
return {
|
|
1178
|
+
type: "normal",
|
|
1179
|
+
arg: fn.call(obj, arg)
|
|
1180
|
+
};
|
|
1181
|
+
} catch (err) {
|
|
1182
|
+
return {
|
|
1183
|
+
type: "throw",
|
|
1184
|
+
arg: err
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1154
1187
|
}
|
|
1155
|
-
}
|
|
1156
1188
|
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
// Returning this object from the innerFn has the same effect as
|
|
1163
|
-
// breaking out of the dispatch switch statement.
|
|
1164
|
-
var ContinueSentinel = {};
|
|
1165
|
-
|
|
1166
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
1167
|
-
// .constructor.prototype properties for functions that return Generator
|
|
1168
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
1169
|
-
// minifier not to mangle the names of these two functions.
|
|
1170
|
-
function Generator() {}
|
|
1171
|
-
function GeneratorFunction() {}
|
|
1172
|
-
function GeneratorFunctionPrototype() {}
|
|
1173
|
-
|
|
1174
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
1175
|
-
// don't natively support it.
|
|
1176
|
-
var IteratorPrototype = {};
|
|
1177
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1178
|
-
return this;
|
|
1179
|
-
});
|
|
1189
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
1190
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
1191
|
+
var GenStateExecuting = "executing";
|
|
1192
|
+
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
1193
|
+
// breaking out of the dispatch switch statement.
|
|
1180
1194
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
1186
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
1187
|
-
// of the polyfill.
|
|
1188
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
1189
|
-
}
|
|
1195
|
+
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
1196
|
+
// .constructor.prototype properties for functions that return Generator
|
|
1197
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
1198
|
+
// minifier not to mangle the names of these two functions.
|
|
1190
1199
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
1203
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
1204
|
-
function defineIteratorMethods(prototype) {
|
|
1205
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
1206
|
-
define(prototype, method, function(arg) {
|
|
1207
|
-
return this._invoke(method, arg);
|
|
1208
|
-
});
|
|
1200
|
+
function Generator() {}
|
|
1201
|
+
|
|
1202
|
+
function GeneratorFunction() {}
|
|
1203
|
+
|
|
1204
|
+
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
1205
|
+
// don't natively support it.
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
var IteratorPrototype = {};
|
|
1209
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1210
|
+
return this;
|
|
1209
1211
|
});
|
|
1210
|
-
|
|
1212
|
+
var getProto = Object.getPrototypeOf;
|
|
1213
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1211
1214
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
// do is to check its .name property.
|
|
1218
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
1219
|
-
: false;
|
|
1220
|
-
};
|
|
1215
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
1216
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
1217
|
+
// of the polyfill.
|
|
1218
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
1219
|
+
}
|
|
1221
1220
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1221
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1222
|
+
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
1223
|
+
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
1224
|
+
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
1225
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
1226
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
1227
|
+
|
|
1228
|
+
function defineIteratorMethods(prototype) {
|
|
1229
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
1230
|
+
define(prototype, method, function (arg) {
|
|
1231
|
+
return this._invoke(method, arg);
|
|
1232
|
+
});
|
|
1233
|
+
});
|
|
1228
1234
|
}
|
|
1229
|
-
genFun.prototype = Object.create(Gp);
|
|
1230
|
-
return genFun;
|
|
1231
|
-
};
|
|
1232
1235
|
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
};
|
|
1236
|
+
exports.isGeneratorFunction = function (genFun) {
|
|
1237
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
1238
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
1239
|
+
// do is to check its .name property.
|
|
1240
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
1241
|
+
};
|
|
1240
1242
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
if (record.type === "throw") {
|
|
1245
|
-
reject(record.arg);
|
|
1243
|
+
exports.mark = function (genFun) {
|
|
1244
|
+
if (Object.setPrototypeOf) {
|
|
1245
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
1246
1246
|
} else {
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1247
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
1248
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
genFun.prototype = Object.create(Gp);
|
|
1252
|
+
return genFun;
|
|
1253
|
+
}; // Within the body of any async function, `await x` is transformed to
|
|
1254
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
1255
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
1256
|
+
// meant to be awaited.
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
exports.awrap = function (arg) {
|
|
1260
|
+
return {
|
|
1261
|
+
__await: arg
|
|
1262
|
+
};
|
|
1263
|
+
};
|
|
1264
|
+
|
|
1265
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
1266
|
+
function invoke(method, arg, resolve, reject) {
|
|
1267
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
1268
|
+
|
|
1269
|
+
if (record.type === "throw") {
|
|
1270
|
+
reject(record.arg);
|
|
1271
|
+
} else {
|
|
1272
|
+
var result = record.arg;
|
|
1273
|
+
var value = result.value;
|
|
1274
|
+
|
|
1275
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
1276
|
+
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1277
|
+
invoke("next", value, resolve, reject);
|
|
1278
|
+
}, function (err) {
|
|
1279
|
+
invoke("throw", err, resolve, reject);
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1284
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
1285
|
+
// the .value of the Promise<{value,done}> result for the
|
|
1286
|
+
// current iteration.
|
|
1287
|
+
result.value = unwrapped;
|
|
1288
|
+
resolve(result);
|
|
1289
|
+
}, function (error) {
|
|
1290
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
1291
|
+
// into the async generator function so it can be handled there.
|
|
1292
|
+
return invoke("throw", error, resolve, reject);
|
|
1256
1293
|
});
|
|
1257
1294
|
}
|
|
1258
|
-
|
|
1259
|
-
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
1260
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
1261
|
-
// the .value of the Promise<{value,done}> result for the
|
|
1262
|
-
// current iteration.
|
|
1263
|
-
result.value = unwrapped;
|
|
1264
|
-
resolve(result);
|
|
1265
|
-
}, function(error) {
|
|
1266
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
1267
|
-
// into the async generator function so it can be handled there.
|
|
1268
|
-
return invoke("throw", error, resolve, reject);
|
|
1269
|
-
});
|
|
1270
1295
|
}
|
|
1271
|
-
}
|
|
1272
1296
|
|
|
1273
|
-
|
|
1297
|
+
var previousPromise;
|
|
1274
1298
|
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1299
|
+
function enqueue(method, arg) {
|
|
1300
|
+
function callInvokeWithMethodAndArg() {
|
|
1301
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
1302
|
+
invoke(method, arg, resolve, reject);
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1281
1305
|
|
|
1282
|
-
|
|
1283
|
-
// If enqueue has been called before, then we want to wait until
|
|
1306
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
1284
1307
|
// all previous Promises have been resolved before calling invoke,
|
|
1285
1308
|
// so that results are always delivered in the correct order. If
|
|
1286
1309
|
// enqueue has not been called before, then it is important to
|
|
@@ -1292,554 +1315,527 @@ var runtime = (function (exports) {
|
|
|
1292
1315
|
// execute code before the first await. Since we implement simple
|
|
1293
1316
|
// async functions in terms of async generators, it is especially
|
|
1294
1317
|
// important to get this right, even though it requires care.
|
|
1295
|
-
previousPromise ? previousPromise.then(
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1318
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
1319
|
+
// invocations of the iterator.
|
|
1320
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
1321
|
+
} // Define the unified helper method that is used to implement .next,
|
|
1322
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
this._invoke = enqueue;
|
|
1301
1326
|
}
|
|
1302
1327
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1328
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
1329
|
+
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1330
|
+
return this;
|
|
1331
|
+
});
|
|
1332
|
+
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
1333
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
1334
|
+
// the final result produced by the iterator.
|
|
1335
|
+
|
|
1336
|
+
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1337
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
1338
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1339
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
1340
|
+
: iter.next().then(function (result) {
|
|
1341
|
+
return result.done ? result.value : iter.next();
|
|
1342
|
+
});
|
|
1343
|
+
};
|
|
1307
1344
|
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
// Note that simple async functions are implemented on top of
|
|
1315
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
1316
|
-
// the final result produced by the iterator.
|
|
1317
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1318
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
1319
|
-
|
|
1320
|
-
var iter = new AsyncIterator(
|
|
1321
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
1322
|
-
PromiseImpl
|
|
1323
|
-
);
|
|
1324
|
-
|
|
1325
|
-
return exports.isGeneratorFunction(outerFn)
|
|
1326
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
1327
|
-
: iter.next().then(function(result) {
|
|
1328
|
-
return result.done ? result.value : iter.next();
|
|
1329
|
-
});
|
|
1330
|
-
};
|
|
1345
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
1346
|
+
var state = GenStateSuspendedStart;
|
|
1347
|
+
return function invoke(method, arg) {
|
|
1348
|
+
if (state === GenStateExecuting) {
|
|
1349
|
+
throw new Error("Generator is already running");
|
|
1350
|
+
}
|
|
1331
1351
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1352
|
+
if (state === GenStateCompleted) {
|
|
1353
|
+
if (method === "throw") {
|
|
1354
|
+
throw arg;
|
|
1355
|
+
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
1356
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
1334
1357
|
|
|
1335
|
-
return function invoke(method, arg) {
|
|
1336
|
-
if (state === GenStateExecuting) {
|
|
1337
|
-
throw new Error("Generator is already running");
|
|
1338
|
-
}
|
|
1339
1358
|
|
|
1340
|
-
|
|
1341
|
-
if (method === "throw") {
|
|
1342
|
-
throw arg;
|
|
1359
|
+
return doneResult();
|
|
1343
1360
|
}
|
|
1344
1361
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1362
|
+
context.method = method;
|
|
1363
|
+
context.arg = arg;
|
|
1364
|
+
|
|
1365
|
+
while (true) {
|
|
1366
|
+
var delegate = context.delegate;
|
|
1349
1367
|
|
|
1350
|
-
|
|
1351
|
-
|
|
1368
|
+
if (delegate) {
|
|
1369
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1352
1370
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
if (delegateResult) {
|
|
1358
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
1359
|
-
return delegateResult;
|
|
1371
|
+
if (delegateResult) {
|
|
1372
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
1373
|
+
return delegateResult;
|
|
1374
|
+
}
|
|
1360
1375
|
}
|
|
1361
|
-
}
|
|
1362
1376
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1377
|
+
if (context.method === "next") {
|
|
1378
|
+
// Setting context._sent for legacy support of Babel's
|
|
1379
|
+
// function.sent implementation.
|
|
1380
|
+
context.sent = context._sent = context.arg;
|
|
1381
|
+
} else if (context.method === "throw") {
|
|
1382
|
+
if (state === GenStateSuspendedStart) {
|
|
1383
|
+
state = GenStateCompleted;
|
|
1384
|
+
throw context.arg;
|
|
1385
|
+
}
|
|
1367
1386
|
|
|
1368
|
-
|
|
1369
|
-
if (
|
|
1370
|
-
|
|
1371
|
-
throw context.arg;
|
|
1387
|
+
context.dispatchException(context.arg);
|
|
1388
|
+
} else if (context.method === "return") {
|
|
1389
|
+
context.abrupt("return", context.arg);
|
|
1372
1390
|
}
|
|
1373
1391
|
|
|
1374
|
-
|
|
1392
|
+
state = GenStateExecuting;
|
|
1393
|
+
var record = tryCatch(innerFn, self, context);
|
|
1375
1394
|
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1395
|
+
if (record.type === "normal") {
|
|
1396
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
1397
|
+
// GenStateExecuting and loop back for another invocation.
|
|
1398
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
1379
1399
|
|
|
1380
|
-
|
|
1400
|
+
if (record.arg === ContinueSentinel) {
|
|
1401
|
+
continue;
|
|
1402
|
+
}
|
|
1381
1403
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1404
|
+
return {
|
|
1405
|
+
value: record.arg,
|
|
1406
|
+
done: context.done
|
|
1407
|
+
};
|
|
1408
|
+
} else if (record.type === "throw") {
|
|
1409
|
+
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
1410
|
+
// context.dispatchException(context.arg) call above.
|
|
1389
1411
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1412
|
+
context.method = "throw";
|
|
1413
|
+
context.arg = record.arg;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
1418
|
+
// result, either by returning a { value, done } result from the
|
|
1419
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
1420
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
1424
|
+
var method = delegate.iterator[context.method];
|
|
1425
|
+
|
|
1426
|
+
if (method === undefined$1) {
|
|
1427
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
1428
|
+
// method always terminates the yield* loop.
|
|
1429
|
+
context.delegate = null;
|
|
1430
|
+
|
|
1431
|
+
if (context.method === "throw") {
|
|
1432
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
1433
|
+
if (delegate.iterator["return"]) {
|
|
1434
|
+
// If the delegate iterator has a return method, give it a
|
|
1435
|
+
// chance to clean up.
|
|
1436
|
+
context.method = "return";
|
|
1437
|
+
context.arg = undefined$1;
|
|
1438
|
+
maybeInvokeDelegate(delegate, context);
|
|
1439
|
+
|
|
1440
|
+
if (context.method === "throw") {
|
|
1441
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
1442
|
+
// "return" to "throw", let that override the TypeError below.
|
|
1443
|
+
return ContinueSentinel;
|
|
1444
|
+
}
|
|
1392
1445
|
}
|
|
1393
1446
|
|
|
1394
|
-
return {
|
|
1395
|
-
value: record.arg,
|
|
1396
|
-
done: context.done
|
|
1397
|
-
};
|
|
1398
|
-
|
|
1399
|
-
} else if (record.type === "throw") {
|
|
1400
|
-
state = GenStateCompleted;
|
|
1401
|
-
// Dispatch the exception by looping back around to the
|
|
1402
|
-
// context.dispatchException(context.arg) call above.
|
|
1403
1447
|
context.method = "throw";
|
|
1404
|
-
context.arg =
|
|
1448
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1405
1449
|
}
|
|
1450
|
+
|
|
1451
|
+
return ContinueSentinel;
|
|
1406
1452
|
}
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
1453
|
|
|
1410
|
-
|
|
1411
|
-
// result, either by returning a { value, done } result from the
|
|
1412
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
1413
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
1414
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
1415
|
-
var method = delegate.iterator[context.method];
|
|
1416
|
-
if (method === undefined$1) {
|
|
1417
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
1418
|
-
// method always terminates the yield* loop.
|
|
1419
|
-
context.delegate = null;
|
|
1454
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1420
1455
|
|
|
1421
|
-
if (
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
context.arg = undefined$1;
|
|
1428
|
-
maybeInvokeDelegate(delegate, context);
|
|
1456
|
+
if (record.type === "throw") {
|
|
1457
|
+
context.method = "throw";
|
|
1458
|
+
context.arg = record.arg;
|
|
1459
|
+
context.delegate = null;
|
|
1460
|
+
return ContinueSentinel;
|
|
1461
|
+
}
|
|
1429
1462
|
|
|
1430
|
-
|
|
1431
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
1432
|
-
// "return" to "throw", let that override the TypeError below.
|
|
1433
|
-
return ContinueSentinel;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1463
|
+
var info = record.arg;
|
|
1436
1464
|
|
|
1465
|
+
if (!info) {
|
|
1437
1466
|
context.method = "throw";
|
|
1438
|
-
context.arg = new TypeError(
|
|
1439
|
-
|
|
1467
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
1468
|
+
context.delegate = null;
|
|
1469
|
+
return ContinueSentinel;
|
|
1440
1470
|
}
|
|
1441
1471
|
|
|
1442
|
-
|
|
1443
|
-
|
|
1472
|
+
if (info.done) {
|
|
1473
|
+
// Assign the result of the finished delegate to the temporary
|
|
1474
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
1475
|
+
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
1444
1476
|
|
|
1445
|
-
|
|
1477
|
+
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
1478
|
+
// exception, let the outer generator proceed normally. If
|
|
1479
|
+
// context.method was "next", forget context.arg since it has been
|
|
1480
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
1481
|
+
// "return", allow the original .return call to continue in the
|
|
1482
|
+
// outer generator.
|
|
1446
1483
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1484
|
+
if (context.method !== "return") {
|
|
1485
|
+
context.method = "next";
|
|
1486
|
+
context.arg = undefined$1;
|
|
1487
|
+
}
|
|
1488
|
+
} else {
|
|
1489
|
+
// Re-yield the result returned by the delegate method.
|
|
1490
|
+
return info;
|
|
1491
|
+
} // The delegate iterator is finished, so forget it and continue with
|
|
1492
|
+
// the outer generator.
|
|
1453
1493
|
|
|
1454
|
-
var info = record.arg;
|
|
1455
1494
|
|
|
1456
|
-
if (! info) {
|
|
1457
|
-
context.method = "throw";
|
|
1458
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
1459
1495
|
context.delegate = null;
|
|
1460
1496
|
return ContinueSentinel;
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
if (info.done) {
|
|
1464
|
-
// Assign the result of the finished delegate to the temporary
|
|
1465
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
1466
|
-
context[delegate.resultName] = info.value;
|
|
1467
|
-
|
|
1468
|
-
// Resume execution at the desired location (see delegateYield).
|
|
1469
|
-
context.next = delegate.nextLoc;
|
|
1470
|
-
|
|
1471
|
-
// If context.method was "throw" but the delegate handled the
|
|
1472
|
-
// exception, let the outer generator proceed normally. If
|
|
1473
|
-
// context.method was "next", forget context.arg since it has been
|
|
1474
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
1475
|
-
// "return", allow the original .return call to continue in the
|
|
1476
|
-
// outer generator.
|
|
1477
|
-
if (context.method !== "return") {
|
|
1478
|
-
context.method = "next";
|
|
1479
|
-
context.arg = undefined$1;
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
} else {
|
|
1483
|
-
// Re-yield the result returned by the delegate method.
|
|
1484
|
-
return info;
|
|
1485
|
-
}
|
|
1497
|
+
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
1498
|
+
// unified ._invoke helper method.
|
|
1486
1499
|
|
|
1487
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
1488
|
-
// the outer generator.
|
|
1489
|
-
context.delegate = null;
|
|
1490
|
-
return ContinueSentinel;
|
|
1491
|
-
}
|
|
1492
1500
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1501
|
+
defineIteratorMethods(Gp);
|
|
1502
|
+
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
1503
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
1504
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
1505
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
1506
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1496
1507
|
|
|
1497
|
-
|
|
1508
|
+
define(Gp, iteratorSymbol, function () {
|
|
1509
|
+
return this;
|
|
1510
|
+
});
|
|
1511
|
+
define(Gp, "toString", function () {
|
|
1512
|
+
return "[object Generator]";
|
|
1513
|
+
});
|
|
1498
1514
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
1504
|
-
define(Gp, iteratorSymbol, function() {
|
|
1505
|
-
return this;
|
|
1506
|
-
});
|
|
1515
|
+
function pushTryEntry(locs) {
|
|
1516
|
+
var entry = {
|
|
1517
|
+
tryLoc: locs[0]
|
|
1518
|
+
};
|
|
1507
1519
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1520
|
+
if (1 in locs) {
|
|
1521
|
+
entry.catchLoc = locs[1];
|
|
1522
|
+
}
|
|
1511
1523
|
|
|
1512
|
-
|
|
1513
|
-
|
|
1524
|
+
if (2 in locs) {
|
|
1525
|
+
entry.finallyLoc = locs[2];
|
|
1526
|
+
entry.afterLoc = locs[3];
|
|
1527
|
+
}
|
|
1514
1528
|
|
|
1515
|
-
|
|
1516
|
-
entry.catchLoc = locs[1];
|
|
1529
|
+
this.tryEntries.push(entry);
|
|
1517
1530
|
}
|
|
1518
1531
|
|
|
1519
|
-
|
|
1520
|
-
entry.
|
|
1521
|
-
|
|
1532
|
+
function resetTryEntry(entry) {
|
|
1533
|
+
var record = entry.completion || {};
|
|
1534
|
+
record.type = "normal";
|
|
1535
|
+
delete record.arg;
|
|
1536
|
+
entry.completion = record;
|
|
1522
1537
|
}
|
|
1523
1538
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
function Context(tryLocsList) {
|
|
1535
|
-
// The root entry object (effectively a try statement without a catch
|
|
1536
|
-
// or a finally block) gives us a place to store values thrown from
|
|
1537
|
-
// locations where there is no enclosing try statement.
|
|
1538
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
1539
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
1540
|
-
this.reset(true);
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
exports.keys = function(object) {
|
|
1544
|
-
var keys = [];
|
|
1545
|
-
for (var key in object) {
|
|
1546
|
-
keys.push(key);
|
|
1539
|
+
function Context(tryLocsList) {
|
|
1540
|
+
// The root entry object (effectively a try statement without a catch
|
|
1541
|
+
// or a finally block) gives us a place to store values thrown from
|
|
1542
|
+
// locations where there is no enclosing try statement.
|
|
1543
|
+
this.tryEntries = [{
|
|
1544
|
+
tryLoc: "root"
|
|
1545
|
+
}];
|
|
1546
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
1547
|
+
this.reset(true);
|
|
1547
1548
|
}
|
|
1548
|
-
keys.reverse();
|
|
1549
|
-
|
|
1550
|
-
// Rather than returning an object with a next method, we keep
|
|
1551
|
-
// things simple and return the next function itself.
|
|
1552
|
-
return function next() {
|
|
1553
|
-
while (keys.length) {
|
|
1554
|
-
var key = keys.pop();
|
|
1555
|
-
if (key in object) {
|
|
1556
|
-
next.value = key;
|
|
1557
|
-
next.done = false;
|
|
1558
|
-
return next;
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
1549
|
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
// also ensures that the minifier will not anonymize the function.
|
|
1565
|
-
next.done = true;
|
|
1566
|
-
return next;
|
|
1567
|
-
};
|
|
1568
|
-
};
|
|
1550
|
+
exports.keys = function (object) {
|
|
1551
|
+
var keys = [];
|
|
1569
1552
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
1573
|
-
if (iteratorMethod) {
|
|
1574
|
-
return iteratorMethod.call(iterable);
|
|
1553
|
+
for (var key in object) {
|
|
1554
|
+
keys.push(key);
|
|
1575
1555
|
}
|
|
1576
1556
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
}
|
|
1557
|
+
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
1558
|
+
// things simple and return the next function itself.
|
|
1580
1559
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1560
|
+
return function next() {
|
|
1561
|
+
while (keys.length) {
|
|
1562
|
+
var key = keys.pop();
|
|
1563
|
+
|
|
1564
|
+
if (key in object) {
|
|
1565
|
+
next.value = key;
|
|
1566
|
+
next.done = false;
|
|
1567
|
+
return next;
|
|
1589
1568
|
}
|
|
1569
|
+
} // To avoid creating an additional object, we just hang the .value
|
|
1570
|
+
// and .done properties off the next function object itself. This
|
|
1571
|
+
// also ensures that the minifier will not anonymize the function.
|
|
1590
1572
|
|
|
1591
|
-
next.value = undefined$1;
|
|
1592
|
-
next.done = true;
|
|
1593
1573
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1574
|
+
next.done = true;
|
|
1575
|
+
return next;
|
|
1576
|
+
};
|
|
1577
|
+
};
|
|
1596
1578
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1579
|
+
function values(iterable) {
|
|
1580
|
+
if (iterable) {
|
|
1581
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1600
1582
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
exports.values = values;
|
|
1605
|
-
|
|
1606
|
-
function doneResult() {
|
|
1607
|
-
return { value: undefined$1, done: true };
|
|
1608
|
-
}
|
|
1583
|
+
if (iteratorMethod) {
|
|
1584
|
+
return iteratorMethod.call(iterable);
|
|
1585
|
+
}
|
|
1609
1586
|
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
reset: function(skipTempReset) {
|
|
1614
|
-
this.prev = 0;
|
|
1615
|
-
this.next = 0;
|
|
1616
|
-
// Resetting context._sent for legacy support of Babel's
|
|
1617
|
-
// function.sent implementation.
|
|
1618
|
-
this.sent = this._sent = undefined$1;
|
|
1619
|
-
this.done = false;
|
|
1620
|
-
this.delegate = null;
|
|
1621
|
-
|
|
1622
|
-
this.method = "next";
|
|
1623
|
-
this.arg = undefined$1;
|
|
1624
|
-
|
|
1625
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
1626
|
-
|
|
1627
|
-
if (!skipTempReset) {
|
|
1628
|
-
for (var name in this) {
|
|
1629
|
-
// Not sure about the optimal order of these conditions:
|
|
1630
|
-
if (name.charAt(0) === "t" &&
|
|
1631
|
-
hasOwn.call(this, name) &&
|
|
1632
|
-
!isNaN(+name.slice(1))) {
|
|
1633
|
-
this[name] = undefined$1;
|
|
1634
|
-
}
|
|
1587
|
+
if (typeof iterable.next === "function") {
|
|
1588
|
+
return iterable;
|
|
1635
1589
|
}
|
|
1636
|
-
}
|
|
1637
|
-
},
|
|
1638
1590
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1591
|
+
if (!isNaN(iterable.length)) {
|
|
1592
|
+
var i = -1,
|
|
1593
|
+
next = function next() {
|
|
1594
|
+
while (++i < iterable.length) {
|
|
1595
|
+
if (hasOwn.call(iterable, i)) {
|
|
1596
|
+
next.value = iterable[i];
|
|
1597
|
+
next.done = false;
|
|
1598
|
+
return next;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1641
1601
|
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
}
|
|
1602
|
+
next.value = undefined$1;
|
|
1603
|
+
next.done = true;
|
|
1604
|
+
return next;
|
|
1605
|
+
};
|
|
1647
1606
|
|
|
1648
|
-
|
|
1649
|
-
|
|
1607
|
+
return next.next = next;
|
|
1608
|
+
}
|
|
1609
|
+
} // Return an iterator with no values.
|
|
1650
1610
|
|
|
1651
|
-
dispatchException: function(exception) {
|
|
1652
|
-
if (this.done) {
|
|
1653
|
-
throw exception;
|
|
1654
|
-
}
|
|
1655
1611
|
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
context.next = loc;
|
|
1612
|
+
return {
|
|
1613
|
+
next: doneResult
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1661
1616
|
|
|
1662
|
-
|
|
1663
|
-
// If the dispatched exception was caught by a catch block,
|
|
1664
|
-
// then let that catch block handle the exception normally.
|
|
1665
|
-
context.method = "next";
|
|
1666
|
-
context.arg = undefined$1;
|
|
1667
|
-
}
|
|
1617
|
+
exports.values = values;
|
|
1668
1618
|
|
|
1669
|
-
|
|
1670
|
-
|
|
1619
|
+
function doneResult() {
|
|
1620
|
+
return {
|
|
1621
|
+
value: undefined$1,
|
|
1622
|
+
done: true
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1671
1625
|
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1626
|
+
Context.prototype = {
|
|
1627
|
+
constructor: Context,
|
|
1628
|
+
reset: function reset(skipTempReset) {
|
|
1629
|
+
this.prev = 0;
|
|
1630
|
+
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
1631
|
+
// function.sent implementation.
|
|
1632
|
+
|
|
1633
|
+
this.sent = this._sent = undefined$1;
|
|
1634
|
+
this.done = false;
|
|
1635
|
+
this.delegate = null;
|
|
1636
|
+
this.method = "next";
|
|
1637
|
+
this.arg = undefined$1;
|
|
1638
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
1675
1639
|
|
|
1676
|
-
if (
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1640
|
+
if (!skipTempReset) {
|
|
1641
|
+
for (var name in this) {
|
|
1642
|
+
// Not sure about the optimal order of these conditions:
|
|
1643
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
1644
|
+
this[name] = undefined$1;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1681
1647
|
}
|
|
1648
|
+
},
|
|
1649
|
+
stop: function stop() {
|
|
1650
|
+
this.done = true;
|
|
1651
|
+
var rootEntry = this.tryEntries[0];
|
|
1652
|
+
var rootRecord = rootEntry.completion;
|
|
1682
1653
|
|
|
1683
|
-
if (
|
|
1684
|
-
|
|
1685
|
-
|
|
1654
|
+
if (rootRecord.type === "throw") {
|
|
1655
|
+
throw rootRecord.arg;
|
|
1656
|
+
}
|
|
1686
1657
|
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1658
|
+
return this.rval;
|
|
1659
|
+
},
|
|
1660
|
+
dispatchException: function dispatchException(exception) {
|
|
1661
|
+
if (this.done) {
|
|
1662
|
+
throw exception;
|
|
1663
|
+
}
|
|
1693
1664
|
|
|
1694
|
-
|
|
1695
|
-
if (this.prev < entry.catchLoc) {
|
|
1696
|
-
return handle(entry.catchLoc, true);
|
|
1697
|
-
}
|
|
1665
|
+
var context = this;
|
|
1698
1666
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1667
|
+
function handle(loc, caught) {
|
|
1668
|
+
record.type = "throw";
|
|
1669
|
+
record.arg = exception;
|
|
1670
|
+
context.next = loc;
|
|
1703
1671
|
|
|
1704
|
-
|
|
1705
|
-
|
|
1672
|
+
if (caught) {
|
|
1673
|
+
// If the dispatched exception was caught by a catch block,
|
|
1674
|
+
// then let that catch block handle the exception normally.
|
|
1675
|
+
context.method = "next";
|
|
1676
|
+
context.arg = undefined$1;
|
|
1706
1677
|
}
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
},
|
|
1710
1678
|
|
|
1711
|
-
|
|
1712
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1713
|
-
var entry = this.tryEntries[i];
|
|
1714
|
-
if (entry.tryLoc <= this.prev &&
|
|
1715
|
-
hasOwn.call(entry, "finallyLoc") &&
|
|
1716
|
-
this.prev < entry.finallyLoc) {
|
|
1717
|
-
var finallyEntry = entry;
|
|
1718
|
-
break;
|
|
1679
|
+
return !!caught;
|
|
1719
1680
|
}
|
|
1720
|
-
}
|
|
1721
1681
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
finallyEntry.tryLoc <= arg &&
|
|
1726
|
-
arg <= finallyEntry.finallyLoc) {
|
|
1727
|
-
// Ignore the finally entry if control is not jumping to a
|
|
1728
|
-
// location outside the try/catch block.
|
|
1729
|
-
finallyEntry = null;
|
|
1730
|
-
}
|
|
1682
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1683
|
+
var entry = this.tryEntries[i];
|
|
1684
|
+
var record = entry.completion;
|
|
1731
1685
|
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1686
|
+
if (entry.tryLoc === "root") {
|
|
1687
|
+
// Exception thrown outside of any try block that could handle
|
|
1688
|
+
// it, so set the completion value of the entire function to
|
|
1689
|
+
// throw the exception.
|
|
1690
|
+
return handle("end");
|
|
1691
|
+
}
|
|
1735
1692
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
return ContinueSentinel;
|
|
1740
|
-
}
|
|
1693
|
+
if (entry.tryLoc <= this.prev) {
|
|
1694
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1695
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1741
1696
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1697
|
+
if (hasCatch && hasFinally) {
|
|
1698
|
+
if (this.prev < entry.catchLoc) {
|
|
1699
|
+
return handle(entry.catchLoc, true);
|
|
1700
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
1701
|
+
return handle(entry.finallyLoc);
|
|
1702
|
+
}
|
|
1703
|
+
} else if (hasCatch) {
|
|
1704
|
+
if (this.prev < entry.catchLoc) {
|
|
1705
|
+
return handle(entry.catchLoc, true);
|
|
1706
|
+
}
|
|
1707
|
+
} else if (hasFinally) {
|
|
1708
|
+
if (this.prev < entry.finallyLoc) {
|
|
1709
|
+
return handle(entry.finallyLoc);
|
|
1710
|
+
}
|
|
1711
|
+
} else {
|
|
1712
|
+
throw new Error("try statement without catch or finally");
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
},
|
|
1717
|
+
abrupt: function abrupt(type, arg) {
|
|
1718
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1719
|
+
var entry = this.tryEntries[i];
|
|
1744
1720
|
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1721
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1722
|
+
var finallyEntry = entry;
|
|
1723
|
+
break;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1749
1726
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
this.method = "return";
|
|
1756
|
-
this.next = "end";
|
|
1757
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
1758
|
-
this.next = afterLoc;
|
|
1759
|
-
}
|
|
1727
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
1728
|
+
// Ignore the finally entry if control is not jumping to a
|
|
1729
|
+
// location outside the try/catch block.
|
|
1730
|
+
finallyEntry = null;
|
|
1731
|
+
}
|
|
1760
1732
|
|
|
1761
|
-
|
|
1762
|
-
|
|
1733
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1734
|
+
record.type = type;
|
|
1735
|
+
record.arg = arg;
|
|
1763
1736
|
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
1768
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
1769
|
-
resetTryEntry(entry);
|
|
1737
|
+
if (finallyEntry) {
|
|
1738
|
+
this.method = "next";
|
|
1739
|
+
this.next = finallyEntry.finallyLoc;
|
|
1770
1740
|
return ContinueSentinel;
|
|
1771
1741
|
}
|
|
1772
|
-
}
|
|
1773
|
-
},
|
|
1774
1742
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
if (
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1743
|
+
return this.complete(record);
|
|
1744
|
+
},
|
|
1745
|
+
complete: function complete(record, afterLoc) {
|
|
1746
|
+
if (record.type === "throw") {
|
|
1747
|
+
throw record.arg;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
if (record.type === "break" || record.type === "continue") {
|
|
1751
|
+
this.next = record.arg;
|
|
1752
|
+
} else if (record.type === "return") {
|
|
1753
|
+
this.rval = this.arg = record.arg;
|
|
1754
|
+
this.method = "return";
|
|
1755
|
+
this.next = "end";
|
|
1756
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
1757
|
+
this.next = afterLoc;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
return ContinueSentinel;
|
|
1761
|
+
},
|
|
1762
|
+
finish: function finish(finallyLoc) {
|
|
1763
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1764
|
+
var entry = this.tryEntries[i];
|
|
1765
|
+
|
|
1766
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
1767
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
1782
1768
|
resetTryEntry(entry);
|
|
1769
|
+
return ContinueSentinel;
|
|
1783
1770
|
}
|
|
1784
|
-
return thrown;
|
|
1785
1771
|
}
|
|
1786
|
-
}
|
|
1772
|
+
},
|
|
1773
|
+
"catch": function _catch(tryLoc) {
|
|
1774
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1775
|
+
var entry = this.tryEntries[i];
|
|
1787
1776
|
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
throw new Error("illegal catch attempt");
|
|
1791
|
-
},
|
|
1777
|
+
if (entry.tryLoc === tryLoc) {
|
|
1778
|
+
var record = entry.completion;
|
|
1792
1779
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
nextLoc: nextLoc
|
|
1798
|
-
};
|
|
1780
|
+
if (record.type === "throw") {
|
|
1781
|
+
var thrown = record.arg;
|
|
1782
|
+
resetTryEntry(entry);
|
|
1783
|
+
}
|
|
1799
1784
|
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
//
|
|
1803
|
-
|
|
1804
|
-
}
|
|
1785
|
+
return thrown;
|
|
1786
|
+
}
|
|
1787
|
+
} // The context.catch method must only be called with a location
|
|
1788
|
+
// argument that corresponds to a known catch block.
|
|
1805
1789
|
|
|
1806
|
-
return ContinueSentinel;
|
|
1807
|
-
}
|
|
1808
|
-
};
|
|
1809
1790
|
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1791
|
+
throw new Error("illegal catch attempt");
|
|
1792
|
+
},
|
|
1793
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1794
|
+
this.delegate = {
|
|
1795
|
+
iterator: values(iterable),
|
|
1796
|
+
resultName: resultName,
|
|
1797
|
+
nextLoc: nextLoc
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
if (this.method === "next") {
|
|
1801
|
+
// Deliberately forget the last sent value so that we don't
|
|
1802
|
+
// accidentally pass it on to the delegate.
|
|
1803
|
+
this.arg = undefined$1;
|
|
1804
|
+
}
|
|
1815
1805
|
|
|
1816
|
-
|
|
1817
|
-
|
|
1806
|
+
return ContinueSentinel;
|
|
1807
|
+
}
|
|
1808
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1809
|
+
// or not, return the runtime object so that we can declare the variable
|
|
1810
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1811
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1812
|
+
|
|
1813
|
+
return exports;
|
|
1814
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1818
1815
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1819
1816
|
// object. Either way, the resulting object will be used to initialize
|
|
1820
1817
|
// the regeneratorRuntime variable at the top of this file.
|
|
1821
|
-
module.exports
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1818
|
+
module.exports );
|
|
1819
|
+
|
|
1820
|
+
try {
|
|
1821
|
+
regeneratorRuntime = runtime;
|
|
1822
|
+
} catch (accidentalStrictMode) {
|
|
1823
|
+
// This module should not be running in strict mode, so the above
|
|
1824
|
+
// assignment should always work unless something is misconfigured. Just
|
|
1825
|
+
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
1826
|
+
// we can explicitly access globalThis. In older engines we can escape
|
|
1827
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
1828
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
1829
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
1830
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
1831
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1832
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
1833
|
+
if (typeof globalThis === "object") {
|
|
1834
|
+
globalThis.regeneratorRuntime = runtime;
|
|
1835
|
+
} else {
|
|
1836
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1837
|
+
}
|
|
1841
1838
|
}
|
|
1842
|
-
}
|
|
1843
1839
|
});
|
|
1844
1840
|
|
|
1845
1841
|
/* eslint-disable you-dont-need-lodash-underscore/find */
|
|
@@ -2274,15 +2270,7 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
2274
2270
|
return /*#__PURE__*/React__default.createElement(InlineEntryCard, {
|
|
2275
2271
|
testId: INLINES.EMBEDDED_ENTRY,
|
|
2276
2272
|
isSelected: props.isSelected,
|
|
2277
|
-
title:
|
|
2278
|
-
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2279
|
-
entityType: "Entry",
|
|
2280
|
-
entityId: entry.sys.id
|
|
2281
|
-
}, /*#__PURE__*/React__default.createElement(ClockIcon, {
|
|
2282
|
-
className: styles$5.scheduledIcon,
|
|
2283
|
-
variant: "muted",
|
|
2284
|
-
testId: "scheduled-icon"
|
|
2285
|
-
}))),
|
|
2273
|
+
title: contentTypeName + ": " + title,
|
|
2286
2274
|
status: status,
|
|
2287
2275
|
actions: [/*#__PURE__*/React__default.createElement(MenuItem, {
|
|
2288
2276
|
key: "edit",
|
|
@@ -2294,7 +2282,15 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
2294
2282
|
disabled: props.isDisabled,
|
|
2295
2283
|
testId: "card-action-remove"
|
|
2296
2284
|
}, "Remove")]
|
|
2297
|
-
}
|
|
2285
|
+
}, /*#__PURE__*/React__default.createElement(ScheduledIconWithTooltip, {
|
|
2286
|
+
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2287
|
+
entityType: "Entry",
|
|
2288
|
+
entityId: entry.sys.id
|
|
2289
|
+
}, /*#__PURE__*/React__default.createElement(ClockIcon, {
|
|
2290
|
+
className: styles$5.scheduledIcon,
|
|
2291
|
+
variant: "muted",
|
|
2292
|
+
testId: "scheduled-icon"
|
|
2293
|
+
})), /*#__PURE__*/React__default.createElement(Text$1, null, title));
|
|
2298
2294
|
}
|
|
2299
2295
|
|
|
2300
2296
|
function createInlineEntryNode(id) {
|
|
@@ -2976,159 +2972,6 @@ var createHrPlugin = function createHrPlugin() {
|
|
|
2976
2972
|
};
|
|
2977
2973
|
};
|
|
2978
2974
|
|
|
2979
|
-
function truncate(str, length) {
|
|
2980
|
-
if (typeof str === 'string' && str.length > length) {
|
|
2981
|
-
return str && str.substr(0, length + 1) // +1 to look ahead and be replaced below.
|
|
2982
|
-
// Get rid of orphan letters but not one letter words (I, a, 2).
|
|
2983
|
-
// Try to not have “.” as last character to avoid awkward “....”.
|
|
2984
|
-
.replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
|
|
2985
|
-
}
|
|
2986
|
-
|
|
2987
|
-
return str;
|
|
2988
|
-
}
|
|
2989
|
-
|
|
2990
|
-
function getEntityInfo(_ref) {
|
|
2991
|
-
var entityTitle = _ref.entityTitle,
|
|
2992
|
-
entityStatus = _ref.entityStatus,
|
|
2993
|
-
contentTypeName = _ref.contentTypeName;
|
|
2994
|
-
var title = truncate(entityTitle, 60) || 'Untitled';
|
|
2995
|
-
return (contentTypeName || 'Asset') + " \"" + title + "\", " + entityStatus;
|
|
2996
|
-
}
|
|
2997
|
-
|
|
2998
|
-
function EntryAssetTooltip(_ref2) {
|
|
2999
|
-
var id = _ref2.id,
|
|
3000
|
-
type = _ref2.type,
|
|
3001
|
-
sdk = _ref2.sdk;
|
|
3002
|
-
|
|
3003
|
-
var _React$useState = useState(''),
|
|
3004
|
-
entityTitle = _React$useState[0],
|
|
3005
|
-
setEntityTitle = _React$useState[1];
|
|
3006
|
-
|
|
3007
|
-
var _React$useState2 = useState(''),
|
|
3008
|
-
entityStatus = _React$useState2[0],
|
|
3009
|
-
setEntityStatus = _React$useState2[1];
|
|
3010
|
-
|
|
3011
|
-
var _React$useState3 = useState([]),
|
|
3012
|
-
jobs = _React$useState3[0],
|
|
3013
|
-
setJobs = _React$useState3[1];
|
|
3014
|
-
|
|
3015
|
-
var _React$useState4 = useState(true),
|
|
3016
|
-
isLoading = _React$useState4[0],
|
|
3017
|
-
setIsLoading = _React$useState4[1];
|
|
3018
|
-
|
|
3019
|
-
var _React$useState5 = useState(false),
|
|
3020
|
-
hasError = _React$useState5[0],
|
|
3021
|
-
setHasError = _React$useState5[1];
|
|
3022
|
-
|
|
3023
|
-
useEffect(function () {
|
|
3024
|
-
function loadContent() {
|
|
3025
|
-
return _loadContent.apply(this, arguments);
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3028
|
-
function _loadContent() {
|
|
3029
|
-
_loadContent = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
3030
|
-
var actions, contentType, entity, contentTypeId, contentTypes, _entityTitle, _jobs, _entityStatus;
|
|
3031
|
-
|
|
3032
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
3033
|
-
while (1) {
|
|
3034
|
-
switch (_context.prev = _context.next) {
|
|
3035
|
-
case 0:
|
|
3036
|
-
_context.prev = 0;
|
|
3037
|
-
setIsLoading(true);
|
|
3038
|
-
setHasError(false);
|
|
3039
|
-
actions = {
|
|
3040
|
-
Asset: {
|
|
3041
|
-
getEntity: sdk.space.getAsset,
|
|
3042
|
-
getEntityTitle: function getEntityTitle(args) {
|
|
3043
|
-
return entityHelpers.getAssetTitle(_extends({}, args, {
|
|
3044
|
-
asset: args.entity
|
|
3045
|
-
}));
|
|
3046
|
-
}
|
|
3047
|
-
},
|
|
3048
|
-
Entry: {
|
|
3049
|
-
getEntity: sdk.space.getEntry,
|
|
3050
|
-
getEntityTitle: function getEntityTitle(args) {
|
|
3051
|
-
return entityHelpers.getEntryTitle(_extends({}, args, {
|
|
3052
|
-
entry: args.entity
|
|
3053
|
-
}));
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
};
|
|
3057
|
-
_context.next = 6;
|
|
3058
|
-
return actions[type].getEntity(id);
|
|
3059
|
-
|
|
3060
|
-
case 6:
|
|
3061
|
-
entity = _context.sent;
|
|
3062
|
-
|
|
3063
|
-
if (entity.sys.contentType) {
|
|
3064
|
-
contentTypeId = entity.sys.contentType.sys.id;
|
|
3065
|
-
contentTypes = sdk.space.getCachedContentTypes();
|
|
3066
|
-
contentType = contentTypes.find(function (ct) {
|
|
3067
|
-
return ct.sys.id === contentTypeId;
|
|
3068
|
-
});
|
|
3069
|
-
}
|
|
3070
|
-
|
|
3071
|
-
_entityTitle = actions[type].getEntityTitle({
|
|
3072
|
-
entity: entity,
|
|
3073
|
-
contentType: contentType,
|
|
3074
|
-
localeCode: sdk.field.locale,
|
|
3075
|
-
defaultLocaleCode: sdk.locales["default"],
|
|
3076
|
-
entityType: type
|
|
3077
|
-
});
|
|
3078
|
-
_context.next = 11;
|
|
3079
|
-
return sdk.space.getEntityScheduledActions(type, id);
|
|
3080
|
-
|
|
3081
|
-
case 11:
|
|
3082
|
-
_jobs = _context.sent;
|
|
3083
|
-
_entityStatus = entityHelpers.getEntryStatus(entity.sys);
|
|
3084
|
-
setEntityTitle(_entityTitle);
|
|
3085
|
-
setEntityStatus(_entityStatus);
|
|
3086
|
-
setJobs(_jobs);
|
|
3087
|
-
_context.next = 22;
|
|
3088
|
-
break;
|
|
3089
|
-
|
|
3090
|
-
case 18:
|
|
3091
|
-
_context.prev = 18;
|
|
3092
|
-
_context.t0 = _context["catch"](0);
|
|
3093
|
-
console.log(_context.t0);
|
|
3094
|
-
setHasError(true);
|
|
3095
|
-
|
|
3096
|
-
case 22:
|
|
3097
|
-
_context.prev = 22;
|
|
3098
|
-
setIsLoading(false);
|
|
3099
|
-
return _context.finish(22);
|
|
3100
|
-
|
|
3101
|
-
case 25:
|
|
3102
|
-
case "end":
|
|
3103
|
-
return _context.stop();
|
|
3104
|
-
}
|
|
3105
|
-
}
|
|
3106
|
-
}, _callee, null, [[0, 18, 22, 25]]);
|
|
3107
|
-
}));
|
|
3108
|
-
return _loadContent.apply(this, arguments);
|
|
3109
|
-
}
|
|
3110
|
-
|
|
3111
|
-
loadContent();
|
|
3112
|
-
}, [id, type, sdk]);
|
|
3113
|
-
|
|
3114
|
-
if (isLoading) {
|
|
3115
|
-
return /*#__PURE__*/createElement(Fragment, null, "Loading " + type.toLowerCase() + "...");
|
|
3116
|
-
}
|
|
3117
|
-
|
|
3118
|
-
if (hasError) {
|
|
3119
|
-
return /*#__PURE__*/createElement(Fragment, null, type + " missing or inaccessible");
|
|
3120
|
-
}
|
|
3121
|
-
|
|
3122
|
-
return /*#__PURE__*/createElement(Fragment, null, getEntityInfo({
|
|
3123
|
-
entityTitle: entityTitle,
|
|
3124
|
-
contentTypeName: type,
|
|
3125
|
-
entityStatus: entityStatus
|
|
3126
|
-
}), ' ', jobs.length > 0 ? getScheduleTooltipContent({
|
|
3127
|
-
job: jobs[0],
|
|
3128
|
-
jobsCount: jobs.length
|
|
3129
|
-
}) : '');
|
|
3130
|
-
}
|
|
3131
|
-
|
|
3132
2975
|
var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
|
|
3133
2976
|
var styles$b = {
|
|
3134
2977
|
removeSelectionLabel: /*#__PURE__*/css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
|
|
@@ -3440,11 +3283,213 @@ function _addOrEditLink() {
|
|
|
3440
3283
|
return _addOrEditLink.apply(this, arguments);
|
|
3441
3284
|
}
|
|
3442
3285
|
|
|
3286
|
+
function ToolbarHyperlinkButton(props) {
|
|
3287
|
+
var editor = useContentfulEditor();
|
|
3288
|
+
var isActive = !!(editor && isLinkActive(editor));
|
|
3289
|
+
var sdk = useSdkContext();
|
|
3290
|
+
|
|
3291
|
+
function handleClick() {
|
|
3292
|
+
return _handleClick.apply(this, arguments);
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
|
+
function _handleClick() {
|
|
3296
|
+
_handleClick = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
3297
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
3298
|
+
while (1) {
|
|
3299
|
+
switch (_context.prev = _context.next) {
|
|
3300
|
+
case 0:
|
|
3301
|
+
if (editor) {
|
|
3302
|
+
_context.next = 2;
|
|
3303
|
+
break;
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
return _context.abrupt("return");
|
|
3307
|
+
|
|
3308
|
+
case 2:
|
|
3309
|
+
if (isActive) {
|
|
3310
|
+
unwrapLink(editor);
|
|
3311
|
+
editor.tracking.onToolbarAction('unlinkHyperlinks');
|
|
3312
|
+
} else {
|
|
3313
|
+
addOrEditLink(editor, sdk, editor.tracking.onToolbarAction);
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
case 3:
|
|
3317
|
+
case "end":
|
|
3318
|
+
return _context.stop();
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
}, _callee);
|
|
3322
|
+
}));
|
|
3323
|
+
return _handleClick.apply(this, arguments);
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
if (!editor) return null;
|
|
3327
|
+
return /*#__PURE__*/createElement(ToolbarButton, {
|
|
3328
|
+
title: "Hyperlink",
|
|
3329
|
+
testId: "hyperlink-toolbar-button",
|
|
3330
|
+
onClick: handleClick,
|
|
3331
|
+
isActive: isActive,
|
|
3332
|
+
isDisabled: props.isDisabled
|
|
3333
|
+
}, /*#__PURE__*/createElement(LinkIcon, null));
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3443
3336
|
var hasText = function hasText(editor, entry) {
|
|
3444
3337
|
var node = entry[0];
|
|
3445
3338
|
return !isAncestorEmpty(editor, node) && Node.string(node).trim() !== '';
|
|
3446
3339
|
};
|
|
3447
3340
|
|
|
3341
|
+
function truncate(str, length) {
|
|
3342
|
+
if (typeof str === 'string' && str.length > length) {
|
|
3343
|
+
return str && str.substr(0, length + 1) // +1 to look ahead and be replaced below.
|
|
3344
|
+
// Get rid of orphan letters but not one letter words (I, a, 2).
|
|
3345
|
+
// Try to not have “.” as last character to avoid awkward “....”.
|
|
3346
|
+
.replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
return str;
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
function getEntityInfo(data) {
|
|
3353
|
+
if (!data) {
|
|
3354
|
+
return '';
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3357
|
+
var entityTitle = data.entityTitle,
|
|
3358
|
+
contentTypeName = data.contentTypeName,
|
|
3359
|
+
entityStatus = data.entityStatus,
|
|
3360
|
+
jobs = data.jobs;
|
|
3361
|
+
var title = truncate(entityTitle, 60) || 'Untitled';
|
|
3362
|
+
var scheduledActions = jobs.length > 0 ? getScheduleTooltipContent({
|
|
3363
|
+
job: jobs[0],
|
|
3364
|
+
jobsCount: jobs.length
|
|
3365
|
+
}) : '';
|
|
3366
|
+
return (contentTypeName || 'Asset') + " \"" + title + "\", " + entityStatus + " " + scheduledActions;
|
|
3367
|
+
}
|
|
3368
|
+
|
|
3369
|
+
function fetchAllData(_x) {
|
|
3370
|
+
return _fetchAllData.apply(this, arguments);
|
|
3371
|
+
}
|
|
3372
|
+
|
|
3373
|
+
function _fetchAllData() {
|
|
3374
|
+
_fetchAllData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
|
|
3375
|
+
var sdk, entityId, entityType, localeCode, defaultLocaleCode, contentType, getEntity, entity, contentTypeId, entityTitle, entityDescription, jobs, entityStatus;
|
|
3376
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
3377
|
+
while (1) {
|
|
3378
|
+
switch (_context.prev = _context.next) {
|
|
3379
|
+
case 0:
|
|
3380
|
+
sdk = _ref.sdk, entityId = _ref.entityId, entityType = _ref.entityType, localeCode = _ref.localeCode, defaultLocaleCode = _ref.defaultLocaleCode;
|
|
3381
|
+
getEntity = entityType === 'Entry' ? sdk.space.getEntry : sdk.space.getAsset;
|
|
3382
|
+
_context.next = 4;
|
|
3383
|
+
return getEntity(entityId);
|
|
3384
|
+
|
|
3385
|
+
case 4:
|
|
3386
|
+
entity = _context.sent;
|
|
3387
|
+
|
|
3388
|
+
if (entity.sys.contentType) {
|
|
3389
|
+
contentTypeId = entity.sys.contentType.sys.id;
|
|
3390
|
+
contentType = sdk.space.getCachedContentTypes().find(function (ct) {
|
|
3391
|
+
return ct.sys.id === contentTypeId;
|
|
3392
|
+
});
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
entityTitle = entityType === 'Entry' ? entityHelpers.getEntryTitle({
|
|
3396
|
+
entry: entity,
|
|
3397
|
+
contentType: contentType,
|
|
3398
|
+
localeCode: localeCode,
|
|
3399
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
3400
|
+
defaultTitle: 'Untitled'
|
|
3401
|
+
}) : entityHelpers.getAssetTitle({
|
|
3402
|
+
asset: entity,
|
|
3403
|
+
localeCode: localeCode,
|
|
3404
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
3405
|
+
defaultTitle: 'Untitled'
|
|
3406
|
+
});
|
|
3407
|
+
entityDescription = entityHelpers.getEntityDescription({
|
|
3408
|
+
entity: entity,
|
|
3409
|
+
contentType: contentType,
|
|
3410
|
+
localeCode: localeCode,
|
|
3411
|
+
defaultLocaleCode: defaultLocaleCode
|
|
3412
|
+
});
|
|
3413
|
+
_context.next = 10;
|
|
3414
|
+
return sdk.space.getEntityScheduledActions(entityType, entityId);
|
|
3415
|
+
|
|
3416
|
+
case 10:
|
|
3417
|
+
jobs = _context.sent;
|
|
3418
|
+
entityStatus = entityHelpers.getEntryStatus(entity.sys);
|
|
3419
|
+
return _context.abrupt("return", {
|
|
3420
|
+
jobs: jobs,
|
|
3421
|
+
entity: entity,
|
|
3422
|
+
entityTitle: entityTitle,
|
|
3423
|
+
entityDescription: entityDescription,
|
|
3424
|
+
entityStatus: entityStatus,
|
|
3425
|
+
contentTypeName: contentType ? contentType.name : ''
|
|
3426
|
+
});
|
|
3427
|
+
|
|
3428
|
+
case 13:
|
|
3429
|
+
case "end":
|
|
3430
|
+
return _context.stop();
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
}, _callee);
|
|
3434
|
+
}));
|
|
3435
|
+
return _fetchAllData.apply(this, arguments);
|
|
3436
|
+
}
|
|
3437
|
+
|
|
3438
|
+
function useRequestStatus(_ref2) {
|
|
3439
|
+
var sdk = _ref2.sdk,
|
|
3440
|
+
target = _ref2.target,
|
|
3441
|
+
onEntityFetchComplete = _ref2.onEntityFetchComplete;
|
|
3442
|
+
|
|
3443
|
+
var _useState = useState({
|
|
3444
|
+
type: 'loading'
|
|
3445
|
+
}),
|
|
3446
|
+
requestStatus = _useState[0],
|
|
3447
|
+
setRequestStatus = _useState[1];
|
|
3448
|
+
|
|
3449
|
+
useEffect(function () {
|
|
3450
|
+
if (target) {
|
|
3451
|
+
var _target$sys, _target$sys2;
|
|
3452
|
+
|
|
3453
|
+
fetchAllData({
|
|
3454
|
+
sdk: sdk,
|
|
3455
|
+
entityId: target == null ? void 0 : (_target$sys = target.sys) == null ? void 0 : _target$sys.id,
|
|
3456
|
+
entityType: target == null ? void 0 : (_target$sys2 = target.sys) == null ? void 0 : _target$sys2.linkType,
|
|
3457
|
+
localeCode: sdk.field.locale,
|
|
3458
|
+
defaultLocaleCode: sdk.locales["default"]
|
|
3459
|
+
}).then(function (entityInfo) {
|
|
3460
|
+
setRequestStatus({
|
|
3461
|
+
type: 'success',
|
|
3462
|
+
data: entityInfo
|
|
3463
|
+
});
|
|
3464
|
+
})["catch"](function (e) {
|
|
3465
|
+
console.log(e);
|
|
3466
|
+
setRequestStatus({
|
|
3467
|
+
type: 'error',
|
|
3468
|
+
error: e
|
|
3469
|
+
});
|
|
3470
|
+
})["finally"](function () {
|
|
3471
|
+
onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
|
|
3472
|
+
});
|
|
3473
|
+
}
|
|
3474
|
+
}, [sdk, target, onEntityFetchComplete]);
|
|
3475
|
+
return requestStatus;
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
function useEntityInfo(props) {
|
|
3479
|
+
var status = useRequestStatus(props);
|
|
3480
|
+
var linkType = props.target.sys.linkType;
|
|
3481
|
+
|
|
3482
|
+
if (status.type === 'loading') {
|
|
3483
|
+
return "Loading " + linkType.toLowerCase() + "...";
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
if (status.type === 'error') {
|
|
3487
|
+
return linkType + " missing or inaccessible";
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
return getEntityInfo(status.data);
|
|
3491
|
+
}
|
|
3492
|
+
|
|
3448
3493
|
var styles$c = {
|
|
3449
3494
|
hyperlinkWrapper: /*#__PURE__*/css({
|
|
3450
3495
|
display: 'inline',
|
|
@@ -3462,33 +3507,21 @@ var styles$c = {
|
|
|
3462
3507
|
'&:focus': {
|
|
3463
3508
|
fill: tokens.gray900
|
|
3464
3509
|
}
|
|
3465
|
-
}),
|
|
3466
|
-
hyperlinkIEFallback: /*#__PURE__*/css({
|
|
3467
|
-
color: '#1683d0',
|
|
3468
|
-
textDecoration: 'underline'
|
|
3469
|
-
}),
|
|
3470
|
-
// TODO: use these styles once we can use the icon
|
|
3471
|
-
hyperlinkIcon: /*#__PURE__*/css({
|
|
3472
|
-
position: 'relative',
|
|
3473
|
-
top: '4px',
|
|
3474
|
-
height: '14px',
|
|
3475
|
-
margin: '0 -2px 0 -1px',
|
|
3476
|
-
webkitTransition: 'fill 100ms ease-in-out',
|
|
3477
|
-
transition: 'fill 100ms ease-in-out',
|
|
3478
|
-
'&:hover': {
|
|
3479
|
-
fill: tokens.gray900
|
|
3480
|
-
},
|
|
3481
|
-
'&:focus': {
|
|
3482
|
-
fill: tokens.gray900
|
|
3483
|
-
}
|
|
3484
3510
|
})
|
|
3485
3511
|
};
|
|
3486
3512
|
|
|
3487
|
-
function
|
|
3513
|
+
function EntityHyperlink(props) {
|
|
3488
3514
|
var editor = useContentfulEditor();
|
|
3489
3515
|
var isReadOnly = useReadOnly();
|
|
3490
3516
|
var sdk = useSdkContext();
|
|
3491
|
-
var
|
|
3517
|
+
var target = props.element.data.target;
|
|
3518
|
+
var onEntityFetchComplete = props.onEntityFetchComplete;
|
|
3519
|
+
var tooltipContent = useEntityInfo({
|
|
3520
|
+
target: target,
|
|
3521
|
+
sdk: sdk,
|
|
3522
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
3523
|
+
});
|
|
3524
|
+
if (!target) return null;
|
|
3492
3525
|
|
|
3493
3526
|
function handleClick(event) {
|
|
3494
3527
|
event.preventDefault();
|
|
@@ -3498,33 +3531,25 @@ function UrlHyperlink(props) {
|
|
|
3498
3531
|
}
|
|
3499
3532
|
|
|
3500
3533
|
return /*#__PURE__*/createElement(Tooltip, {
|
|
3501
|
-
content:
|
|
3534
|
+
content: tooltipContent,
|
|
3502
3535
|
targetWrapperClassName: styles$c.hyperlinkWrapper,
|
|
3503
3536
|
placement: "bottom",
|
|
3504
3537
|
maxWidth: "auto"
|
|
3505
3538
|
}, /*#__PURE__*/createElement(TextLink, {
|
|
3506
3539
|
as: "a",
|
|
3507
|
-
href: uri,
|
|
3508
|
-
rel: "noopener noreferrer",
|
|
3509
3540
|
onClick: handleClick,
|
|
3510
3541
|
isDisabled: isReadOnly,
|
|
3511
|
-
className: styles$c.hyperlink
|
|
3542
|
+
className: styles$c.hyperlink,
|
|
3543
|
+
"data-link-type": target.sys.linkType,
|
|
3544
|
+
"data-link-id": target.sys.id
|
|
3512
3545
|
}, props.children));
|
|
3513
3546
|
}
|
|
3514
3547
|
|
|
3515
|
-
function
|
|
3548
|
+
function UrlHyperlink(props) {
|
|
3516
3549
|
var editor = useContentfulEditor();
|
|
3517
3550
|
var isReadOnly = useReadOnly();
|
|
3518
3551
|
var sdk = useSdkContext();
|
|
3519
|
-
var
|
|
3520
|
-
var onEntityFetchComplete = props.onEntityFetchComplete;
|
|
3521
|
-
useEffect(function () {
|
|
3522
|
-
// The real entity loading happens in the tooltip
|
|
3523
|
-
// Since that is deferred the link is considered rendered as soon
|
|
3524
|
-
// the component mounts (link text displayed)
|
|
3525
|
-
onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
|
|
3526
|
-
}, [onEntityFetchComplete]);
|
|
3527
|
-
if (!target) return null;
|
|
3552
|
+
var uri = props.element.data.uri;
|
|
3528
3553
|
|
|
3529
3554
|
function handleClick(event) {
|
|
3530
3555
|
event.preventDefault();
|
|
@@ -3534,74 +3559,20 @@ function EntityHyperlink(props) {
|
|
|
3534
3559
|
}
|
|
3535
3560
|
|
|
3536
3561
|
return /*#__PURE__*/createElement(Tooltip, {
|
|
3537
|
-
content:
|
|
3538
|
-
id: target.sys.id,
|
|
3539
|
-
type: target.sys.linkType,
|
|
3540
|
-
sdk: sdk
|
|
3541
|
-
}),
|
|
3562
|
+
content: uri,
|
|
3542
3563
|
targetWrapperClassName: styles$c.hyperlinkWrapper,
|
|
3543
3564
|
placement: "bottom",
|
|
3544
3565
|
maxWidth: "auto"
|
|
3545
3566
|
}, /*#__PURE__*/createElement(TextLink, {
|
|
3546
3567
|
as: "a",
|
|
3568
|
+
href: uri,
|
|
3569
|
+
rel: "noopener noreferrer",
|
|
3547
3570
|
onClick: handleClick,
|
|
3548
3571
|
isDisabled: isReadOnly,
|
|
3549
|
-
className: styles$c.hyperlink
|
|
3550
|
-
"data-link-type": target.sys.linkType,
|
|
3551
|
-
"data-link-id": target.sys.id
|
|
3572
|
+
className: styles$c.hyperlink
|
|
3552
3573
|
}, props.children));
|
|
3553
3574
|
}
|
|
3554
3575
|
|
|
3555
|
-
function ToolbarHyperlinkButton(props) {
|
|
3556
|
-
var editor = useContentfulEditor();
|
|
3557
|
-
var isActive = !!(editor && isLinkActive(editor));
|
|
3558
|
-
var sdk = useSdkContext();
|
|
3559
|
-
|
|
3560
|
-
function handleClick() {
|
|
3561
|
-
return _handleClick.apply(this, arguments);
|
|
3562
|
-
}
|
|
3563
|
-
|
|
3564
|
-
function _handleClick() {
|
|
3565
|
-
_handleClick = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
3566
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
3567
|
-
while (1) {
|
|
3568
|
-
switch (_context.prev = _context.next) {
|
|
3569
|
-
case 0:
|
|
3570
|
-
if (editor) {
|
|
3571
|
-
_context.next = 2;
|
|
3572
|
-
break;
|
|
3573
|
-
}
|
|
3574
|
-
|
|
3575
|
-
return _context.abrupt("return");
|
|
3576
|
-
|
|
3577
|
-
case 2:
|
|
3578
|
-
if (isActive) {
|
|
3579
|
-
unwrapLink(editor);
|
|
3580
|
-
editor.tracking.onToolbarAction('unlinkHyperlinks');
|
|
3581
|
-
} else {
|
|
3582
|
-
addOrEditLink(editor, sdk, editor.tracking.onToolbarAction);
|
|
3583
|
-
}
|
|
3584
|
-
|
|
3585
|
-
case 3:
|
|
3586
|
-
case "end":
|
|
3587
|
-
return _context.stop();
|
|
3588
|
-
}
|
|
3589
|
-
}
|
|
3590
|
-
}, _callee);
|
|
3591
|
-
}));
|
|
3592
|
-
return _handleClick.apply(this, arguments);
|
|
3593
|
-
}
|
|
3594
|
-
|
|
3595
|
-
if (!editor) return null;
|
|
3596
|
-
return /*#__PURE__*/createElement(ToolbarButton, {
|
|
3597
|
-
title: "Hyperlink",
|
|
3598
|
-
testId: "hyperlink-toolbar-button",
|
|
3599
|
-
onClick: handleClick,
|
|
3600
|
-
isActive: isActive,
|
|
3601
|
-
isDisabled: props.isDisabled
|
|
3602
|
-
}, /*#__PURE__*/createElement(LinkIcon, null));
|
|
3603
|
-
}
|
|
3604
|
-
|
|
3605
3576
|
var isAnchor = function isAnchor(element) {
|
|
3606
3577
|
return element.nodeName === 'A' && !!element.getAttribute('href') && element.getAttribute('href') !== '#';
|
|
3607
3578
|
};
|
|
@@ -4126,6 +4097,101 @@ var insertListFragment = function insertListFragment(editor) {
|
|
|
4126
4097
|
};
|
|
4127
4098
|
};
|
|
4128
4099
|
|
|
4100
|
+
/**
|
|
4101
|
+
* Credit: Modified version of Plate's list plugin
|
|
4102
|
+
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4103
|
+
*/
|
|
4104
|
+
var listTypes = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4105
|
+
var unwrapList = function unwrapList(editor, _temp) {
|
|
4106
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
4107
|
+
at = _ref.at;
|
|
4108
|
+
|
|
4109
|
+
Editor.withoutNormalizing(editor, function () {
|
|
4110
|
+
do {
|
|
4111
|
+
unwrapNodes(editor, {
|
|
4112
|
+
at: at,
|
|
4113
|
+
match: {
|
|
4114
|
+
type: BLOCKS.LIST_ITEM
|
|
4115
|
+
},
|
|
4116
|
+
split: true
|
|
4117
|
+
});
|
|
4118
|
+
unwrapNodes(editor, {
|
|
4119
|
+
at: at,
|
|
4120
|
+
match: {
|
|
4121
|
+
type: listTypes
|
|
4122
|
+
},
|
|
4123
|
+
split: true
|
|
4124
|
+
});
|
|
4125
|
+
} while (getAbove(editor, {
|
|
4126
|
+
match: {
|
|
4127
|
+
type: listTypes,
|
|
4128
|
+
at: at
|
|
4129
|
+
}
|
|
4130
|
+
}));
|
|
4131
|
+
});
|
|
4132
|
+
};
|
|
4133
|
+
|
|
4134
|
+
/**
|
|
4135
|
+
* Credit: Modified version of Plate's list plugin
|
|
4136
|
+
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4137
|
+
*/
|
|
4138
|
+
var deleteBackwardList = function deleteBackwardList(editor, unit) {
|
|
4139
|
+
var res = getListItemEntry(editor, {});
|
|
4140
|
+
var moved = false;
|
|
4141
|
+
|
|
4142
|
+
if (res) {
|
|
4143
|
+
var list = res.list,
|
|
4144
|
+
listItem = res.listItem;
|
|
4145
|
+
|
|
4146
|
+
if (isSelectionAtBlockStart(editor, {
|
|
4147
|
+
match: function match(node) {
|
|
4148
|
+
return node.type === BLOCKS.LIST_ITEM;
|
|
4149
|
+
}
|
|
4150
|
+
})) {
|
|
4151
|
+
Editor.withoutNormalizing(editor, function () {
|
|
4152
|
+
moved = removeFirstListItem(editor, {
|
|
4153
|
+
list: list,
|
|
4154
|
+
listItem: listItem
|
|
4155
|
+
});
|
|
4156
|
+
if (moved) return;
|
|
4157
|
+
moved = removeListItem(editor, {
|
|
4158
|
+
list: list,
|
|
4159
|
+
listItem: listItem
|
|
4160
|
+
});
|
|
4161
|
+
if (moved) return;
|
|
4162
|
+
|
|
4163
|
+
if (isFirstChild(listItem[1]) && !isListNested(editor, list[1])) {
|
|
4164
|
+
onKeyDownResetNode(editor, mockPlugin({
|
|
4165
|
+
options: {
|
|
4166
|
+
rules: [{
|
|
4167
|
+
types: [BLOCKS.LIST_ITEM],
|
|
4168
|
+
defaultType: BLOCKS.PARAGRAPH,
|
|
4169
|
+
hotkey: 'backspace',
|
|
4170
|
+
predicate: function predicate() {
|
|
4171
|
+
return isSelectionAtBlockStart(editor);
|
|
4172
|
+
},
|
|
4173
|
+
onReset: function onReset(e) {
|
|
4174
|
+
return unwrapList(e);
|
|
4175
|
+
}
|
|
4176
|
+
}]
|
|
4177
|
+
}
|
|
4178
|
+
}))(SIMULATE_BACKSPACE);
|
|
4179
|
+
moved = true;
|
|
4180
|
+
return;
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
deleteFragment(editor, {
|
|
4184
|
+
unit: unit,
|
|
4185
|
+
reverse: true
|
|
4186
|
+
});
|
|
4187
|
+
moved = true;
|
|
4188
|
+
});
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
|
|
4192
|
+
return moved;
|
|
4193
|
+
};
|
|
4194
|
+
|
|
4129
4195
|
/**
|
|
4130
4196
|
* Credit: Modified version of Plate's list plugin
|
|
4131
4197
|
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
@@ -4203,39 +4269,9 @@ var createListPlugin = function createListPlugin() {
|
|
|
4203
4269
|
});
|
|
4204
4270
|
};
|
|
4205
4271
|
|
|
4206
|
-
var listTypes = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4207
|
-
|
|
4208
|
-
var
|
|
4209
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
4210
|
-
at = _ref.at;
|
|
4211
|
-
|
|
4212
|
-
Editor.withoutNormalizing(editor, function () {
|
|
4213
|
-
do {
|
|
4214
|
-
unwrapNodes(editor, {
|
|
4215
|
-
at: at,
|
|
4216
|
-
match: {
|
|
4217
|
-
type: BLOCKS.LIST_ITEM
|
|
4218
|
-
},
|
|
4219
|
-
split: true
|
|
4220
|
-
});
|
|
4221
|
-
unwrapNodes(editor, {
|
|
4222
|
-
at: at,
|
|
4223
|
-
match: {
|
|
4224
|
-
type: listTypes
|
|
4225
|
-
},
|
|
4226
|
-
split: true
|
|
4227
|
-
});
|
|
4228
|
-
} while (getAbove(editor, {
|
|
4229
|
-
match: {
|
|
4230
|
-
type: listTypes,
|
|
4231
|
-
at: at
|
|
4232
|
-
}
|
|
4233
|
-
}));
|
|
4234
|
-
});
|
|
4235
|
-
};
|
|
4236
|
-
|
|
4237
|
-
var toggleList = function toggleList(editor, _ref2) {
|
|
4238
|
-
var type = _ref2.type;
|
|
4272
|
+
var listTypes$1 = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4273
|
+
var toggleList = function toggleList(editor, _ref) {
|
|
4274
|
+
var type = _ref.type;
|
|
4239
4275
|
return Editor.withoutNormalizing(editor, function () {
|
|
4240
4276
|
if (!editor.selection) {
|
|
4241
4277
|
return;
|
|
@@ -4254,7 +4290,7 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4254
4290
|
}, {
|
|
4255
4291
|
at: editor.selection,
|
|
4256
4292
|
match: function match(n) {
|
|
4257
|
-
return listTypes.includes(n.type);
|
|
4293
|
+
return listTypes$1.includes(n.type);
|
|
4258
4294
|
},
|
|
4259
4295
|
mode: 'lowest'
|
|
4260
4296
|
});
|
|
@@ -4295,19 +4331,19 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4295
4331
|
|
|
4296
4332
|
var commonEntry = Node.common(editor, startPoint.path, endPoint.path);
|
|
4297
4333
|
|
|
4298
|
-
if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === BLOCKS.LIST_ITEM) {
|
|
4334
|
+
if (listTypes$1.includes(commonEntry[0].type) || commonEntry[0].type === BLOCKS.LIST_ITEM) {
|
|
4299
4335
|
if (commonEntry[0].type !== type) {
|
|
4300
4336
|
var startList = findNode(editor, {
|
|
4301
4337
|
at: Range.start(editor.selection),
|
|
4302
4338
|
match: {
|
|
4303
|
-
type: listTypes
|
|
4339
|
+
type: listTypes$1
|
|
4304
4340
|
},
|
|
4305
4341
|
mode: 'lowest'
|
|
4306
4342
|
});
|
|
4307
4343
|
var endList = findNode(editor, {
|
|
4308
4344
|
at: Range.end(editor.selection),
|
|
4309
4345
|
match: {
|
|
4310
|
-
type: listTypes
|
|
4346
|
+
type: listTypes$1
|
|
4311
4347
|
},
|
|
4312
4348
|
mode: 'lowest'
|
|
4313
4349
|
});
|
|
@@ -4322,7 +4358,7 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4322
4358
|
}, {
|
|
4323
4359
|
at: editor.selection,
|
|
4324
4360
|
match: function match(n, path) {
|
|
4325
|
-
return listTypes.includes(n.type) && path.length >= rangeLength;
|
|
4361
|
+
return listTypes$1.includes(n.type) && path.length >= rangeLength;
|
|
4326
4362
|
},
|
|
4327
4363
|
mode: 'all'
|
|
4328
4364
|
});
|
|
@@ -4334,13 +4370,13 @@ var toggleList = function toggleList(editor, _ref2) {
|
|
|
4334
4370
|
|
|
4335
4371
|
var _nodes = Array.from(getNodes(editor, {
|
|
4336
4372
|
mode: 'all'
|
|
4337
|
-
})).filter(function (
|
|
4338
|
-
var path =
|
|
4373
|
+
})).filter(function (_ref2) {
|
|
4374
|
+
var path = _ref2[1];
|
|
4339
4375
|
return path.length === rootPathLength + 1;
|
|
4340
4376
|
}).reverse();
|
|
4341
4377
|
|
|
4342
4378
|
_nodes.forEach(function (n) {
|
|
4343
|
-
if (listTypes.includes(n[0].type)) {
|
|
4379
|
+
if (listTypes$1.includes(n[0].type)) {
|
|
4344
4380
|
setNodes(editor, {
|
|
4345
4381
|
type: type
|
|
4346
4382
|
}, {
|
|
@@ -5056,10 +5092,51 @@ function Quote(props) {
|
|
|
5056
5092
|
}), props.children);
|
|
5057
5093
|
}
|
|
5058
5094
|
|
|
5095
|
+
/**
|
|
5096
|
+
* Returns true if we are:
|
|
5097
|
+
* 1) Inside a blockquote
|
|
5098
|
+
* 2) With no only one child paragraph/heading and
|
|
5099
|
+
* 3) that child is empty
|
|
5100
|
+
*/
|
|
5101
|
+
|
|
5102
|
+
var shouldResetQuoteOnBackspace = function shouldResetQuoteOnBackspace(editor) {
|
|
5103
|
+
var container = getAbove(editor, {
|
|
5104
|
+
match: {
|
|
5105
|
+
type: TEXT_CONTAINERS
|
|
5106
|
+
},
|
|
5107
|
+
mode: 'lowest'
|
|
5108
|
+
});
|
|
5109
|
+
|
|
5110
|
+
if (!container) {
|
|
5111
|
+
return false;
|
|
5112
|
+
}
|
|
5113
|
+
|
|
5114
|
+
if (!isAncestorEmpty(editor, container[0])) {
|
|
5115
|
+
return false;
|
|
5116
|
+
}
|
|
5117
|
+
|
|
5118
|
+
var quote = getBlockAbove(editor, {
|
|
5119
|
+
match: {
|
|
5120
|
+
type: BLOCKS.QUOTE
|
|
5121
|
+
},
|
|
5122
|
+
mode: 'lowest'
|
|
5123
|
+
});
|
|
5124
|
+
|
|
5125
|
+
if (!quote) {
|
|
5126
|
+
return false;
|
|
5127
|
+
}
|
|
5128
|
+
|
|
5129
|
+
if (hasSingleChild(quote[0]) && isLastChild(quote, container[1])) {
|
|
5130
|
+
return true;
|
|
5131
|
+
}
|
|
5132
|
+
|
|
5133
|
+
return false;
|
|
5134
|
+
};
|
|
5135
|
+
|
|
5059
5136
|
function toggleQuote(editor, logAction) {
|
|
5060
5137
|
if (!editor.selection) return;
|
|
5061
5138
|
var isActive = isBlockSelected(editor, BLOCKS.QUOTE);
|
|
5062
|
-
logAction(isActive ? 'remove' : 'insert', {
|
|
5139
|
+
logAction == null ? void 0 : logAction(isActive ? 'remove' : 'insert', {
|
|
5063
5140
|
nodeType: BLOCKS.QUOTE
|
|
5064
5141
|
});
|
|
5065
5142
|
Editor.withoutNormalizing(editor, function () {
|
|
@@ -5092,6 +5169,54 @@ var onKeyDownToggleQuote = function onKeyDownToggleQuote(editor, plugin) {
|
|
|
5092
5169
|
};
|
|
5093
5170
|
};
|
|
5094
5171
|
|
|
5172
|
+
var withQuote = function withQuote(editor) {
|
|
5173
|
+
var insertFragment = editor.insertFragment;
|
|
5174
|
+
|
|
5175
|
+
editor.insertFragment = function (fragment) {
|
|
5176
|
+
var startingNode = fragment.length && fragment[0];
|
|
5177
|
+
var startsWithBlockquote = Element.isElement(startingNode) && startingNode.type === BLOCKS.QUOTE;
|
|
5178
|
+
var containerEntry = getAbove(editor, {
|
|
5179
|
+
match: {
|
|
5180
|
+
type: TEXT_CONTAINERS
|
|
5181
|
+
}
|
|
5182
|
+
});
|
|
5183
|
+
var containerIsNotEmpty = containerEntry && Node.string(containerEntry[0]) !== '';
|
|
5184
|
+
|
|
5185
|
+
if (startsWithBlockquote && containerIsNotEmpty) {
|
|
5186
|
+
var selection = editor.selection;
|
|
5187
|
+
|
|
5188
|
+
var isContentSelected = function isContentSelected(selection) {
|
|
5189
|
+
return !!selection && Point.compare(selection.anchor, selection.focus) !== 0;
|
|
5190
|
+
}; // if something is selected (highlighted) we replace the selection
|
|
5191
|
+
|
|
5192
|
+
|
|
5193
|
+
if (isContentSelected(selection)) {
|
|
5194
|
+
Transforms["delete"](editor, {
|
|
5195
|
+
at: selection
|
|
5196
|
+
});
|
|
5197
|
+
} // get the cursor entry again, it may be different after deletion
|
|
5198
|
+
|
|
5199
|
+
|
|
5200
|
+
var _containerEntry = getAbove(editor, {
|
|
5201
|
+
match: {
|
|
5202
|
+
type: TEXT_CONTAINERS
|
|
5203
|
+
}
|
|
5204
|
+
});
|
|
5205
|
+
|
|
5206
|
+
var _containerIsNotEmpty = _containerEntry && Node.string(_containerEntry[0]) !== '';
|
|
5207
|
+
|
|
5208
|
+
if (_containerIsNotEmpty) {
|
|
5209
|
+
Transforms.insertNodes(editor, fragment);
|
|
5210
|
+
return;
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
|
|
5214
|
+
insertFragment(fragment);
|
|
5215
|
+
};
|
|
5216
|
+
|
|
5217
|
+
return editor;
|
|
5218
|
+
};
|
|
5219
|
+
|
|
5095
5220
|
function createQuotePlugin() {
|
|
5096
5221
|
var _transform;
|
|
5097
5222
|
|
|
@@ -5111,57 +5236,18 @@ function createQuotePlugin() {
|
|
|
5111
5236
|
validNodeName: 'BLOCKQUOTE'
|
|
5112
5237
|
}]
|
|
5113
5238
|
},
|
|
5239
|
+
resetNode: [{
|
|
5240
|
+
// toggle off blockquote on backspace when it's empty
|
|
5241
|
+
hotkey: 'backspace',
|
|
5242
|
+
types: [BLOCKS.QUOTE],
|
|
5243
|
+
predicate: shouldResetQuoteOnBackspace,
|
|
5244
|
+
onReset: toggleQuote
|
|
5245
|
+
}],
|
|
5114
5246
|
normalizer: [{
|
|
5115
5247
|
validChildren: CONTAINERS[BLOCKS.QUOTE],
|
|
5116
5248
|
transform: (_transform = {}, _transform[BLOCKS.QUOTE] = transformUnwrap, _transform["default"] = transformLift, _transform)
|
|
5117
5249
|
}],
|
|
5118
|
-
withOverrides:
|
|
5119
|
-
var insertFragment = editor.insertFragment;
|
|
5120
|
-
|
|
5121
|
-
editor.insertFragment = function (fragment) {
|
|
5122
|
-
var startingNode = fragment.length && fragment[0];
|
|
5123
|
-
var startsWithBlockquote = Element.isElement(startingNode) && startingNode.type === BLOCKS.QUOTE;
|
|
5124
|
-
var containerEntry = getAbove(editor, {
|
|
5125
|
-
match: {
|
|
5126
|
-
type: TEXT_CONTAINERS
|
|
5127
|
-
}
|
|
5128
|
-
});
|
|
5129
|
-
var containerIsNotEmpty = containerEntry && Node.string(containerEntry[0]) !== '';
|
|
5130
|
-
|
|
5131
|
-
if (startsWithBlockquote && containerIsNotEmpty) {
|
|
5132
|
-
var selection = editor.selection;
|
|
5133
|
-
|
|
5134
|
-
var isContentSelected = function isContentSelected(selection) {
|
|
5135
|
-
return !!selection && Point.compare(selection.anchor, selection.focus) !== 0;
|
|
5136
|
-
}; // if something is selected (highlighted) we replace the selection
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
if (isContentSelected(selection)) {
|
|
5140
|
-
Transforms["delete"](editor, {
|
|
5141
|
-
at: selection
|
|
5142
|
-
});
|
|
5143
|
-
} // get the cursor entry again, it may be different after deletion
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
var _containerEntry = getAbove(editor, {
|
|
5147
|
-
match: {
|
|
5148
|
-
type: TEXT_CONTAINERS
|
|
5149
|
-
}
|
|
5150
|
-
});
|
|
5151
|
-
|
|
5152
|
-
var _containerIsNotEmpty = _containerEntry && Node.string(_containerEntry[0]) !== '';
|
|
5153
|
-
|
|
5154
|
-
if (_containerIsNotEmpty) {
|
|
5155
|
-
Transforms.insertNodes(editor, fragment);
|
|
5156
|
-
return;
|
|
5157
|
-
}
|
|
5158
|
-
}
|
|
5159
|
-
|
|
5160
|
-
insertFragment(fragment);
|
|
5161
|
-
};
|
|
5162
|
-
|
|
5163
|
-
return editor;
|
|
5164
|
-
}
|
|
5250
|
+
withOverrides: withQuote
|
|
5165
5251
|
};
|
|
5166
5252
|
}
|
|
5167
5253
|
|
|
@@ -5836,11 +5922,11 @@ function createTextPlugin() {
|
|
|
5836
5922
|
deleteBackward = editor.deleteBackward;
|
|
5837
5923
|
|
|
5838
5924
|
editor.deleteBackward = function (unit) {
|
|
5839
|
-
|
|
5925
|
+
deleteFirstEmptyParagraph(unit, editor, deleteBackward);
|
|
5840
5926
|
};
|
|
5841
5927
|
|
|
5842
5928
|
editor.deleteForward = function (unit) {
|
|
5843
|
-
|
|
5929
|
+
deleteFirstEmptyParagraph(unit, editor, deleteForward);
|
|
5844
5930
|
};
|
|
5845
5931
|
|
|
5846
5932
|
return editor;
|
|
@@ -5848,7 +5934,7 @@ function createTextPlugin() {
|
|
|
5848
5934
|
};
|
|
5849
5935
|
}
|
|
5850
5936
|
|
|
5851
|
-
function
|
|
5937
|
+
function deleteFirstEmptyParagraph(unit, editor, deleteFunction) {
|
|
5852
5938
|
var entry = getAbove(editor, {
|
|
5853
5939
|
match: {
|
|
5854
5940
|
type: TEXT_CONTAINERS
|
|
@@ -5861,8 +5947,9 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
5861
5947
|
var isTextEmpty = isAncestorEmpty(editor, paragraphOrHeading); // We ignore paragraphs/headings that are children of ul, ol, blockquote, tables, etc
|
|
5862
5948
|
|
|
5863
5949
|
var isRootLevel = path.length === 1;
|
|
5950
|
+
var hasSiblings = editor.children.length > 1; // prevent editor from losing focus
|
|
5864
5951
|
|
|
5865
|
-
if (isTextEmpty && isRootLevel) {
|
|
5952
|
+
if (isTextEmpty && isRootLevel && isFirstChild(path) && hasSiblings) {
|
|
5866
5953
|
Transforms.removeNodes(editor, {
|
|
5867
5954
|
at: path
|
|
5868
5955
|
});
|
|
@@ -6113,7 +6200,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
6113
6200
|
createTrailingParagraphPlugin(), createTextPlugin(), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
6114
6201
|
createPasteHTMLPlugin(), // These plugins drive their configurations from the list of plugins
|
|
6115
6202
|
// above. They MUST come last.
|
|
6116
|
-
createSoftBreakPlugin(), createExitBreakPlugin(), createNormalizerPlugin()];
|
|
6203
|
+
createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()];
|
|
6117
6204
|
};
|
|
6118
6205
|
var disableCorePlugins = {
|
|
6119
6206
|
// Temporarily until the upstream issue is fixed.
|