@crashbytes/contentful-richtext-editor 3.0.0 → 3.0.1
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/index.esm.js +1145 -552
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1148 -552
- package/dist/index.js.map +1 -1
- package/package.json +29 -29
package/dist/index.esm.js
CHANGED
|
@@ -73,6 +73,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
73
73
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
function getDefaultExportFromCjs (x) {
|
|
77
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
78
|
+
}
|
|
79
|
+
|
|
76
80
|
var shim = {exports: {}};
|
|
77
81
|
|
|
78
82
|
var useSyncExternalStoreShim_production = {};
|
|
@@ -5813,6 +5817,27 @@ class Transform {
|
|
|
5813
5817
|
return this.steps.length > 0;
|
|
5814
5818
|
}
|
|
5815
5819
|
/**
|
|
5820
|
+
Return a single range, in post-transform document positions,
|
|
5821
|
+
that covers all content changed by this transform. Returns null
|
|
5822
|
+
if no replacements are made. Note that this will ignore changes
|
|
5823
|
+
that add/remove marks without replacing the underlying content.
|
|
5824
|
+
*/
|
|
5825
|
+
changedRange() {
|
|
5826
|
+
let from = 1e9, to = -1e9;
|
|
5827
|
+
for (let i = 0; i < this.mapping.maps.length; i++) {
|
|
5828
|
+
let map = this.mapping.maps[i];
|
|
5829
|
+
if (i) {
|
|
5830
|
+
from = map.map(from, 1);
|
|
5831
|
+
to = map.map(to, -1);
|
|
5832
|
+
}
|
|
5833
|
+
map.forEach((_f, _t, fromB, toB) => {
|
|
5834
|
+
from = Math.min(from, fromB);
|
|
5835
|
+
to = Math.max(to, toB);
|
|
5836
|
+
});
|
|
5837
|
+
}
|
|
5838
|
+
return from == 1e9 ? null : { from, to };
|
|
5839
|
+
}
|
|
5840
|
+
/**
|
|
5816
5841
|
@internal
|
|
5817
5842
|
*/
|
|
5818
5843
|
addStep(step, doc) {
|
|
@@ -9195,15 +9220,15 @@ class NodeViewDesc extends ViewDesc {
|
|
|
9195
9220
|
let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
|
|
9196
9221
|
iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
|
|
9197
9222
|
if (widget.spec.marks)
|
|
9198
|
-
updater.syncToMarks(widget.spec.marks, inline, view);
|
|
9223
|
+
updater.syncToMarks(widget.spec.marks, inline, view, i);
|
|
9199
9224
|
else if (widget.type.side >= 0 && !insideNode)
|
|
9200
|
-
updater.syncToMarks(i == this.node.childCount ? Mark$1.none : this.node.child(i).marks, inline, view);
|
|
9225
|
+
updater.syncToMarks(i == this.node.childCount ? Mark$1.none : this.node.child(i).marks, inline, view, i);
|
|
9201
9226
|
// If the next node is a desc matching this widget, reuse it,
|
|
9202
9227
|
// otherwise insert the widget as a new view desc.
|
|
9203
9228
|
updater.placeWidget(widget, view, off);
|
|
9204
9229
|
}, (child, outerDeco, innerDeco, i) => {
|
|
9205
9230
|
// Make sure the wrapping mark descs match the node's marks.
|
|
9206
|
-
updater.syncToMarks(child.marks, inline, view);
|
|
9231
|
+
updater.syncToMarks(child.marks, inline, view, i);
|
|
9207
9232
|
// Try several strategies for drawing this node
|
|
9208
9233
|
let compIndex;
|
|
9209
9234
|
if (updater.findNodeMatch(child, outerDeco, innerDeco, i)) ;
|
|
@@ -9219,7 +9244,7 @@ class NodeViewDesc extends ViewDesc {
|
|
|
9219
9244
|
off += child.nodeSize;
|
|
9220
9245
|
});
|
|
9221
9246
|
// Drop all remaining descs after the current position.
|
|
9222
|
-
updater.syncToMarks([], inline, view);
|
|
9247
|
+
updater.syncToMarks([], inline, view, 0);
|
|
9223
9248
|
if (this.node.isTextblock)
|
|
9224
9249
|
updater.addTextblockHacks();
|
|
9225
9250
|
updater.destroyRest();
|
|
@@ -9609,7 +9634,7 @@ class ViewTreeUpdater {
|
|
|
9609
9634
|
}
|
|
9610
9635
|
// Sync the current stack of mark descs with the given array of
|
|
9611
9636
|
// marks, reusing existing mark descs when possible.
|
|
9612
|
-
syncToMarks(marks, inline, view) {
|
|
9637
|
+
syncToMarks(marks, inline, view, parentIndex) {
|
|
9613
9638
|
let keep = 0, depth = this.stack.length >> 1;
|
|
9614
9639
|
let maxKeep = Math.min(depth, marks.length);
|
|
9615
9640
|
while (keep < maxKeep &&
|
|
@@ -9625,8 +9650,10 @@ class ViewTreeUpdater {
|
|
|
9625
9650
|
}
|
|
9626
9651
|
while (depth < marks.length) {
|
|
9627
9652
|
this.stack.push(this.top, this.index + 1);
|
|
9628
|
-
let found = -1;
|
|
9629
|
-
|
|
9653
|
+
let found = -1, scanTo = this.top.children.length;
|
|
9654
|
+
if (parentIndex < this.preMatch.index)
|
|
9655
|
+
scanTo = Math.min(this.index + 3, scanTo);
|
|
9656
|
+
for (let i = this.index; i < scanTo; i++) {
|
|
9630
9657
|
let next = this.top.children[i];
|
|
9631
9658
|
if (next.matchesMark(marks[depth]) && !this.isLocked(next.dom)) {
|
|
9632
9659
|
found = i;
|
|
@@ -9822,9 +9849,7 @@ class ViewTreeUpdater {
|
|
|
9822
9849
|
}
|
|
9823
9850
|
// Iterate from the end of the fragment and array of descs to find
|
|
9824
9851
|
// directly matching ones, in order to avoid overeagerly reusing those
|
|
9825
|
-
// for other nodes.
|
|
9826
|
-
// is part of the sequence of matched nodes at the end of the
|
|
9827
|
-
// fragment.
|
|
9852
|
+
// for other nodes.
|
|
9828
9853
|
function preMatch(frag, parentDesc) {
|
|
9829
9854
|
let curDesc = parentDesc, descI = curDesc.children.length;
|
|
9830
9855
|
let fI = frag.childCount, matched = new Map, matches = [];
|
|
@@ -9847,7 +9872,6 @@ function preMatch(frag, parentDesc) {
|
|
|
9847
9872
|
break outer;
|
|
9848
9873
|
}
|
|
9849
9874
|
else {
|
|
9850
|
-
// FIXME
|
|
9851
9875
|
descI = curDesc.parent.children.indexOf(curDesc);
|
|
9852
9876
|
curDesc = curDesc.parent;
|
|
9853
9877
|
}
|
|
@@ -10894,6 +10918,7 @@ class InputState {
|
|
|
10894
10918
|
this.compositionNodes = [];
|
|
10895
10919
|
this.compositionEndedAt = -2e8;
|
|
10896
10920
|
this.compositionID = 1;
|
|
10921
|
+
this.badSafariComposition = false;
|
|
10897
10922
|
// Set to a composition ID when there are pending changes at compositionend
|
|
10898
10923
|
this.compositionPendingChanges = 0;
|
|
10899
10924
|
this.domChangeCount = 0;
|
|
@@ -11340,7 +11365,9 @@ editHandlers.compositionend = (view, event) => {
|
|
|
11340
11365
|
view.input.compositionEndedAt = event.timeStamp;
|
|
11341
11366
|
view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
|
|
11342
11367
|
view.input.compositionNode = null;
|
|
11343
|
-
if (view.input.
|
|
11368
|
+
if (view.input.badSafariComposition)
|
|
11369
|
+
view.domObserver.forceFlush();
|
|
11370
|
+
else if (view.input.compositionPendingChanges)
|
|
11344
11371
|
Promise.resolve().then(() => view.domObserver.flush());
|
|
11345
11372
|
view.input.compositionID++;
|
|
11346
11373
|
scheduleComposeEnd(view, 20);
|
|
@@ -12403,15 +12430,24 @@ class DOMObserver {
|
|
|
12403
12430
|
new window.MutationObserver(mutations => {
|
|
12404
12431
|
for (let i = 0; i < mutations.length; i++)
|
|
12405
12432
|
this.queue.push(mutations[i]);
|
|
12406
|
-
// IE11 will sometimes (on backspacing out a single character
|
|
12407
|
-
// text node after a BR node) call the observer callback
|
|
12408
|
-
// before actually updating the DOM, which will cause
|
|
12409
|
-
// ProseMirror to miss the change (see #930)
|
|
12410
12433
|
if (ie$1 && ie_version <= 11 && mutations.some(m => m.type == "childList" && m.removedNodes.length ||
|
|
12411
|
-
m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
|
|
12434
|
+
m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length)) {
|
|
12435
|
+
// IE11 will sometimes (on backspacing out a single character
|
|
12436
|
+
// text node after a BR node) call the observer callback
|
|
12437
|
+
// before actually updating the DOM, which will cause
|
|
12438
|
+
// ProseMirror to miss the change (see #930)
|
|
12412
12439
|
this.flushSoon();
|
|
12413
|
-
|
|
12440
|
+
}
|
|
12441
|
+
else if (safari && view.composing && mutations.some(m => m.type == "childList" && m.target.nodeName == "TR")) {
|
|
12442
|
+
// Safari does weird stuff when finishing a composition in a
|
|
12443
|
+
// table cell, which tends to involve inserting inappropriate
|
|
12444
|
+
// nodes in the table row.
|
|
12445
|
+
view.input.badSafariComposition = true;
|
|
12446
|
+
this.flushSoon();
|
|
12447
|
+
}
|
|
12448
|
+
else {
|
|
12414
12449
|
this.flush();
|
|
12450
|
+
}
|
|
12415
12451
|
});
|
|
12416
12452
|
if (useCharData) {
|
|
12417
12453
|
this.onCharData = e => {
|
|
@@ -12531,7 +12567,17 @@ class DOMObserver {
|
|
|
12531
12567
|
}
|
|
12532
12568
|
}
|
|
12533
12569
|
}
|
|
12534
|
-
if (
|
|
12570
|
+
if (added.some(n => n.nodeName == "BR") && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46)) {
|
|
12571
|
+
// Browsers sometimes insert a bogus break node if you
|
|
12572
|
+
// backspace out the last bit of text before an inline-flex node (#1552)
|
|
12573
|
+
for (let node of added)
|
|
12574
|
+
if (node.nodeName == "BR" && node.parentNode) {
|
|
12575
|
+
let after = node.nextSibling;
|
|
12576
|
+
if (after && after.nodeType == 1 && after.contentEditable == "false")
|
|
12577
|
+
node.parentNode.removeChild(node);
|
|
12578
|
+
}
|
|
12579
|
+
}
|
|
12580
|
+
else if (gecko && added.length) {
|
|
12535
12581
|
let brs = added.filter(n => n.nodeName == "BR");
|
|
12536
12582
|
if (brs.length == 2) {
|
|
12537
12583
|
let [a, b] = brs;
|
|
@@ -12549,17 +12595,6 @@ class DOMObserver {
|
|
|
12549
12595
|
}
|
|
12550
12596
|
}
|
|
12551
12597
|
}
|
|
12552
|
-
else if ((chrome || safari) && added.some(n => n.nodeName == "BR") &&
|
|
12553
|
-
(view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46)) {
|
|
12554
|
-
// Chrome/Safari sometimes insert a bogus break node if you
|
|
12555
|
-
// backspace out the last bit of text before an inline-flex node (#1552)
|
|
12556
|
-
for (let node of added)
|
|
12557
|
-
if (node.nodeName == "BR" && node.parentNode) {
|
|
12558
|
-
let after = node.nextSibling;
|
|
12559
|
-
if (after && after.nodeType == 1 && after.contentEditable == "false")
|
|
12560
|
-
node.parentNode.removeChild(node);
|
|
12561
|
-
}
|
|
12562
|
-
}
|
|
12563
12598
|
let readSel = null;
|
|
12564
12599
|
// If it looks like the browser has reset the selection to the
|
|
12565
12600
|
// start of the document after focus, restore the selection from
|
|
@@ -12578,6 +12613,10 @@ class DOMObserver {
|
|
|
12578
12613
|
view.docView.markDirty(from, to);
|
|
12579
12614
|
checkCSS(view);
|
|
12580
12615
|
}
|
|
12616
|
+
if (view.input.badSafariComposition) {
|
|
12617
|
+
view.input.badSafariComposition = false;
|
|
12618
|
+
fixUpBadSafariComposition(view, added);
|
|
12619
|
+
}
|
|
12581
12620
|
this.handleDOMChange(from, to, typeOver, added);
|
|
12582
12621
|
if (view.docView && view.docView.dirty)
|
|
12583
12622
|
view.updateState(view.state);
|
|
@@ -12701,6 +12740,37 @@ function blockParent(view, node) {
|
|
|
12701
12740
|
}
|
|
12702
12741
|
return null;
|
|
12703
12742
|
}
|
|
12743
|
+
// Kludge for a Safari bug where, on ending a composition in an
|
|
12744
|
+
// otherwise empty table cell, it randomly moves the composed text
|
|
12745
|
+
// into the table row around that cell, greatly confusing everything
|
|
12746
|
+
// (#188).
|
|
12747
|
+
function fixUpBadSafariComposition(view, addedNodes) {
|
|
12748
|
+
var _a;
|
|
12749
|
+
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
12750
|
+
for (let node of addedNodes) {
|
|
12751
|
+
if (((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.nodeName) == "TR") {
|
|
12752
|
+
let nextCell = node.nextSibling;
|
|
12753
|
+
while (nextCell && (nextCell.nodeName != "TD" && nextCell.nodeName != "TH"))
|
|
12754
|
+
nextCell = nextCell.nextSibling;
|
|
12755
|
+
if (nextCell) {
|
|
12756
|
+
let parent = nextCell;
|
|
12757
|
+
for (;;) {
|
|
12758
|
+
let first = parent.firstChild;
|
|
12759
|
+
if (!first || first.nodeType != 1 || first.contentEditable == "false" ||
|
|
12760
|
+
/^(BR|IMG)$/.test(first.nodeName))
|
|
12761
|
+
break;
|
|
12762
|
+
parent = first;
|
|
12763
|
+
}
|
|
12764
|
+
parent.insertBefore(node, parent.firstChild);
|
|
12765
|
+
if (focusNode == node)
|
|
12766
|
+
view.domSelection().collapse(node, focusOffset);
|
|
12767
|
+
}
|
|
12768
|
+
else {
|
|
12769
|
+
node.parentNode.removeChild(node);
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
}
|
|
12773
|
+
}
|
|
12704
12774
|
|
|
12705
12775
|
// Note that all referencing and parsing is done with the
|
|
12706
12776
|
// start-of-operation selection and document, since that's the one
|
|
@@ -13264,7 +13334,7 @@ class EditorView {
|
|
|
13264
13334
|
this.docView.destroy();
|
|
13265
13335
|
this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);
|
|
13266
13336
|
}
|
|
13267
|
-
if (chromeKludge && !this.trackWrites)
|
|
13337
|
+
if (chromeKludge && (!this.trackWrites || !this.dom.contains(this.trackWrites)))
|
|
13268
13338
|
forceSelUpdate = true;
|
|
13269
13339
|
}
|
|
13270
13340
|
// Work around for an issue where an update arriving right between
|
|
@@ -14418,8 +14488,12 @@ var focus = (position = null, options = {}) => ({ editor, view, tr, dispatch })
|
|
|
14418
14488
|
}
|
|
14419
14489
|
});
|
|
14420
14490
|
};
|
|
14421
|
-
|
|
14422
|
-
|
|
14491
|
+
try {
|
|
14492
|
+
if (view.hasFocus() && position === null || position === false) {
|
|
14493
|
+
return true;
|
|
14494
|
+
}
|
|
14495
|
+
} catch {
|
|
14496
|
+
return false;
|
|
14423
14497
|
}
|
|
14424
14498
|
if (dispatch && position === null && !isTextSelection(editor.state.selection)) {
|
|
14425
14499
|
delayedFocus();
|
|
@@ -16718,7 +16792,7 @@ function inputRulesPlugin(props) {
|
|
|
16718
16792
|
function getType(value) {
|
|
16719
16793
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
16720
16794
|
}
|
|
16721
|
-
function isPlainObject(value) {
|
|
16795
|
+
function isPlainObject$1(value) {
|
|
16722
16796
|
if (getType(value) !== "Object") {
|
|
16723
16797
|
return false;
|
|
16724
16798
|
}
|
|
@@ -16728,9 +16802,9 @@ function isPlainObject(value) {
|
|
|
16728
16802
|
// src/utilities/mergeDeep.ts
|
|
16729
16803
|
function mergeDeep(target, source) {
|
|
16730
16804
|
const output = { ...target };
|
|
16731
|
-
if (isPlainObject(target) && isPlainObject(source)) {
|
|
16805
|
+
if (isPlainObject$1(target) && isPlainObject$1(source)) {
|
|
16732
16806
|
Object.keys(source).forEach((key) => {
|
|
16733
|
-
if (isPlainObject(source[key]) && isPlainObject(target[key])) {
|
|
16807
|
+
if (isPlainObject$1(source[key]) && isPlainObject$1(target[key])) {
|
|
16734
16808
|
output[key] = mergeDeep(target[key], source[key]);
|
|
16735
16809
|
} else {
|
|
16736
16810
|
output[key] = source[key];
|
|
@@ -17864,19 +17938,20 @@ var NodePos = class _NodePos {
|
|
|
17864
17938
|
this.node.content.forEach((node, offset) => {
|
|
17865
17939
|
const isBlock = node.isBlock && !node.isTextblock;
|
|
17866
17940
|
const isNonTextAtom = node.isAtom && !node.isText;
|
|
17941
|
+
const isInline = node.isInline;
|
|
17867
17942
|
const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);
|
|
17868
17943
|
if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {
|
|
17869
17944
|
return;
|
|
17870
17945
|
}
|
|
17871
17946
|
const $pos = this.resolvedPos.doc.resolve(targetPos);
|
|
17872
|
-
if (!isBlock && $pos.depth <= this.depth) {
|
|
17947
|
+
if (!isBlock && !isInline && $pos.depth <= this.depth) {
|
|
17873
17948
|
return;
|
|
17874
17949
|
}
|
|
17875
|
-
const childNodePos = new _NodePos($pos, this.editor, isBlock, isBlock ? node : null);
|
|
17950
|
+
const childNodePos = new _NodePos($pos, this.editor, isBlock, isBlock || isInline ? node : null);
|
|
17876
17951
|
if (isBlock) {
|
|
17877
17952
|
childNodePos.actualDepth = this.depth + 1;
|
|
17878
17953
|
}
|
|
17879
|
-
children.push(
|
|
17954
|
+
children.push(childNodePos);
|
|
17880
17955
|
});
|
|
17881
17956
|
return children;
|
|
17882
17957
|
}
|
|
@@ -20732,6 +20807,35 @@ React.createContext({
|
|
|
20732
20807
|
markViewContentRef: () => {
|
|
20733
20808
|
}
|
|
20734
20809
|
});
|
|
20810
|
+
var TiptapContext = createContext({
|
|
20811
|
+
get editor() {
|
|
20812
|
+
throw new Error("useTiptap must be used within a <Tiptap> provider");
|
|
20813
|
+
}
|
|
20814
|
+
});
|
|
20815
|
+
TiptapContext.displayName = "TiptapContext";
|
|
20816
|
+
var useTiptap = () => useContext(TiptapContext);
|
|
20817
|
+
function TiptapWrapper({ editor, instance, children }) {
|
|
20818
|
+
const resolvedEditor = editor != null ? editor : instance;
|
|
20819
|
+
if (!resolvedEditor) {
|
|
20820
|
+
throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");
|
|
20821
|
+
}
|
|
20822
|
+
const tiptapContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
|
|
20823
|
+
const legacyContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
|
|
20824
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, { value: legacyContextValue, children: /* @__PURE__ */ jsx(TiptapContext.Provider, { value: tiptapContextValue, children }) });
|
|
20825
|
+
}
|
|
20826
|
+
TiptapWrapper.displayName = "Tiptap";
|
|
20827
|
+
function TiptapContent({ ...rest }) {
|
|
20828
|
+
const { editor } = useTiptap();
|
|
20829
|
+
return /* @__PURE__ */ jsx(EditorContent, { editor, ...rest });
|
|
20830
|
+
}
|
|
20831
|
+
TiptapContent.displayName = "Tiptap.Content";
|
|
20832
|
+
Object.assign(TiptapWrapper, {
|
|
20833
|
+
/**
|
|
20834
|
+
* The Tiptap Content component that renders the EditorContent with the editor instance from the context.
|
|
20835
|
+
* @see TiptapContent
|
|
20836
|
+
*/
|
|
20837
|
+
Content: TiptapContent
|
|
20838
|
+
});
|
|
20735
20839
|
|
|
20736
20840
|
// src/jsx-runtime.ts
|
|
20737
20841
|
var h = (tag, attributes) => {
|
|
@@ -23447,31 +23551,33 @@ function clickHandler(options) {
|
|
|
23447
23551
|
if (!view.editable) {
|
|
23448
23552
|
return false;
|
|
23449
23553
|
}
|
|
23554
|
+
let link = null;
|
|
23555
|
+
if (event.target instanceof HTMLAnchorElement) {
|
|
23556
|
+
link = event.target;
|
|
23557
|
+
} else {
|
|
23558
|
+
const target = event.target;
|
|
23559
|
+
if (!target) {
|
|
23560
|
+
return false;
|
|
23561
|
+
}
|
|
23562
|
+
const root = options.editor.view.dom;
|
|
23563
|
+
link = target.closest("a");
|
|
23564
|
+
if (link && !root.contains(link)) {
|
|
23565
|
+
link = null;
|
|
23566
|
+
}
|
|
23567
|
+
}
|
|
23568
|
+
if (!link) {
|
|
23569
|
+
return false;
|
|
23570
|
+
}
|
|
23450
23571
|
let handled = false;
|
|
23451
23572
|
if (options.enableClickSelection) {
|
|
23452
23573
|
const commandResult = options.editor.commands.extendMarkRange(options.type.name);
|
|
23453
23574
|
handled = commandResult;
|
|
23454
23575
|
}
|
|
23455
23576
|
if (options.openOnClick) {
|
|
23456
|
-
let link = null;
|
|
23457
|
-
if (event.target instanceof HTMLAnchorElement) {
|
|
23458
|
-
link = event.target;
|
|
23459
|
-
} else {
|
|
23460
|
-
let a = event.target;
|
|
23461
|
-
const els = [];
|
|
23462
|
-
while (a.nodeName !== "DIV") {
|
|
23463
|
-
els.push(a);
|
|
23464
|
-
a = a.parentNode;
|
|
23465
|
-
}
|
|
23466
|
-
link = els.find((value) => value.nodeName === "A");
|
|
23467
|
-
}
|
|
23468
|
-
if (!link) {
|
|
23469
|
-
return handled;
|
|
23470
|
-
}
|
|
23471
23577
|
const attrs = getAttributes(view.state, options.type.name);
|
|
23472
|
-
const href = (_a = link
|
|
23473
|
-
const target = (_b = link
|
|
23474
|
-
if (
|
|
23578
|
+
const href = (_a = link.href) != null ? _a : attrs.href;
|
|
23579
|
+
const target = (_b = link.target) != null ? _b : attrs.target;
|
|
23580
|
+
if (href) {
|
|
23475
23581
|
window.open(href, target);
|
|
23476
23582
|
handled = true;
|
|
23477
23583
|
}
|
|
@@ -23601,6 +23707,9 @@ var Link = Mark.create({
|
|
|
23601
23707
|
},
|
|
23602
23708
|
class: {
|
|
23603
23709
|
default: this.options.HTMLAttributes.class
|
|
23710
|
+
},
|
|
23711
|
+
title: {
|
|
23712
|
+
default: null
|
|
23604
23713
|
}
|
|
23605
23714
|
};
|
|
23606
23715
|
},
|
|
@@ -23640,10 +23749,11 @@ var Link = Mark.create({
|
|
|
23640
23749
|
});
|
|
23641
23750
|
},
|
|
23642
23751
|
renderMarkdown: (node, h) => {
|
|
23643
|
-
var _a;
|
|
23644
|
-
const href = ((_a = node.attrs) == null ? void 0 : _a.href)
|
|
23752
|
+
var _a, _b, _c, _d;
|
|
23753
|
+
const href = (_b = (_a = node.attrs) == null ? void 0 : _a.href) != null ? _b : "";
|
|
23754
|
+
const title = (_d = (_c = node.attrs) == null ? void 0 : _c.title) != null ? _d : "";
|
|
23645
23755
|
const text = h.renderChildren(node);
|
|
23646
|
-
return `[${text}](${href})`;
|
|
23756
|
+
return title ? `[${text}](${href} "${title}")` : `[${text}](${href})`;
|
|
23647
23757
|
},
|
|
23648
23758
|
addCommands() {
|
|
23649
23759
|
return {
|
|
@@ -23905,11 +24015,13 @@ var ListItem = Node3.create({
|
|
|
23905
24015
|
node,
|
|
23906
24016
|
h,
|
|
23907
24017
|
(context) => {
|
|
24018
|
+
var _a, _b;
|
|
23908
24019
|
if (context.parentType === "bulletList") {
|
|
23909
24020
|
return "- ";
|
|
23910
24021
|
}
|
|
23911
24022
|
if (context.parentType === "orderedList") {
|
|
23912
|
-
|
|
24023
|
+
const start = ((_b = (_a = context.meta) == null ? void 0 : _a.parentAttrs) == null ? void 0 : _b.start) || 1;
|
|
24024
|
+
return `${start + context.index}. `;
|
|
23913
24025
|
}
|
|
23914
24026
|
return "- ";
|
|
23915
24027
|
},
|
|
@@ -24801,6 +24913,8 @@ Extension.create({
|
|
|
24801
24913
|
});
|
|
24802
24914
|
|
|
24803
24915
|
// src/paragraph.ts
|
|
24916
|
+
var EMPTY_PARAGRAPH_MARKDOWN = " ";
|
|
24917
|
+
var NBSP_CHAR = "\xA0";
|
|
24804
24918
|
var Paragraph = Node3.create({
|
|
24805
24919
|
name: "paragraph",
|
|
24806
24920
|
priority: 1e3,
|
|
@@ -24822,18 +24936,21 @@ var Paragraph = Node3.create({
|
|
|
24822
24936
|
if (tokens.length === 1 && tokens[0].type === "image") {
|
|
24823
24937
|
return helpers.parseChildren([tokens[0]]);
|
|
24824
24938
|
}
|
|
24825
|
-
|
|
24826
|
-
|
|
24827
|
-
void 0,
|
|
24828
|
-
|
|
24829
|
-
|
|
24830
|
-
);
|
|
24939
|
+
const content = helpers.parseInline(tokens);
|
|
24940
|
+
if (content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
|
|
24941
|
+
return helpers.createNode("paragraph", void 0, []);
|
|
24942
|
+
}
|
|
24943
|
+
return helpers.createNode("paragraph", void 0, content);
|
|
24831
24944
|
},
|
|
24832
24945
|
renderMarkdown: (node, h) => {
|
|
24833
|
-
if (!node
|
|
24946
|
+
if (!node) {
|
|
24834
24947
|
return "";
|
|
24835
24948
|
}
|
|
24836
|
-
|
|
24949
|
+
const content = Array.isArray(node.content) ? node.content : [];
|
|
24950
|
+
if (content.length === 0) {
|
|
24951
|
+
return EMPTY_PARAGRAPH_MARKDOWN;
|
|
24952
|
+
}
|
|
24953
|
+
return h.renderChildren(content);
|
|
24837
24954
|
},
|
|
24838
24955
|
addCommands() {
|
|
24839
24956
|
return {
|
|
@@ -26183,12 +26300,17 @@ var Gapcursor = Extension.create({
|
|
|
26183
26300
|
};
|
|
26184
26301
|
}
|
|
26185
26302
|
});
|
|
26303
|
+
var DEFAULT_DATA_ATTRIBUTE = "placeholder";
|
|
26304
|
+
function preparePlaceholderAttribute(attr) {
|
|
26305
|
+
return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
26306
|
+
}
|
|
26186
26307
|
Extension.create({
|
|
26187
26308
|
name: "placeholder",
|
|
26188
26309
|
addOptions() {
|
|
26189
26310
|
return {
|
|
26190
26311
|
emptyEditorClass: "is-editor-empty",
|
|
26191
26312
|
emptyNodeClass: "is-empty",
|
|
26313
|
+
dataAttribute: DEFAULT_DATA_ATTRIBUTE,
|
|
26192
26314
|
placeholder: "Write something \u2026",
|
|
26193
26315
|
showOnlyWhenEditable: true,
|
|
26194
26316
|
showOnlyCurrent: true,
|
|
@@ -26196,6 +26318,7 @@ Extension.create({
|
|
|
26196
26318
|
};
|
|
26197
26319
|
},
|
|
26198
26320
|
addProseMirrorPlugins() {
|
|
26321
|
+
const dataAttribute = this.options.dataAttribute ? `data-${preparePlaceholderAttribute(this.options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
|
|
26199
26322
|
return [
|
|
26200
26323
|
new Plugin({
|
|
26201
26324
|
key: new PluginKey("placeholder"),
|
|
@@ -26218,7 +26341,7 @@ Extension.create({
|
|
|
26218
26341
|
}
|
|
26219
26342
|
const decoration = Decoration.node(pos, pos + node.nodeSize, {
|
|
26220
26343
|
class: classes.join(" "),
|
|
26221
|
-
|
|
26344
|
+
[dataAttribute]: typeof this.options.placeholder === "function" ? this.options.placeholder({
|
|
26222
26345
|
editor: this.editor,
|
|
26223
26346
|
node,
|
|
26224
26347
|
pos,
|
|
@@ -29057,432 +29180,905 @@ var ContentfulToolbar = function (_a) {
|
|
|
29057
29180
|
}, autoFocus: true }), jsx("button", { onClick: handleLinkSubmit, title: "Apply link", children: "\u2713" }), jsx("button", { onClick: handleLinkCancel, title: "Cancel", children: "\u2717" })] }))] }))] })] })), (!isDisabled('lists') || !isDisabled('quote') || !isDisabled('table')) && (jsxs(Fragment$1, { children: [jsx("div", { className: "contentful-toolbar__separator" }), jsxs("div", { className: "contentful-toolbar__group", children: [!isDisabled('lists') && (jsxs(Fragment$1, { children: [jsx("button", { className: "contentful-toolbar__button ".concat(editor.isActive('bulletList') ? 'contentful-toolbar__button--active' : ''), onClick: function () { return editor.chain().focus().toggleBulletList().run(); }, title: "Bullet List", children: "\u2022 \u2261" }), jsx("button", { className: "contentful-toolbar__button ".concat(editor.isActive('orderedList') ? 'contentful-toolbar__button--active' : ''), onClick: function () { return editor.chain().focus().toggleOrderedList().run(); }, title: "Numbered List", children: "1. \u2261" })] })), !isDisabled('quote') && (jsx("button", { className: "contentful-toolbar__button ".concat(editor.isActive('blockquote') ? 'contentful-toolbar__button--active' : ''), onClick: function () { return editor.chain().focus().toggleBlockquote().run(); }, title: "Quote", children: "\"" })), jsx("button", { className: "contentful-toolbar__button", onClick: function () { return editor.chain().focus().setHorizontalRule().run(); }, title: "Horizontal Rule", children: "\u2014" }), !isDisabled('table') && (jsx("button", { className: "contentful-toolbar__button", onClick: insertTable, title: "Insert Table", children: "\u229E" }))] })] })), hasAnyEmbedOptions && !isDisabled('embed') && (jsxs(Fragment$1, { children: [jsx("div", { className: "contentful-toolbar__separator" }), jsx("div", { className: "contentful-toolbar__group contentful-toolbar__group--right", children: jsxs("div", { className: "contentful-toolbar__embed-dropdown", children: [jsx("button", { className: "contentful-toolbar__embed-button", children: "+ Embed \u25BC" }), jsxs("div", { className: "contentful-toolbar__embed-menu", children: [onEmbedEntry && (jsx("button", { className: "contentful-toolbar__embed-option", onClick: onEmbedEntry, children: "\uD83D\uDCC4 Entry" })), onEmbedInlineEntry && (jsx("button", { className: "contentful-toolbar__embed-option", onClick: onEmbedInlineEntry, children: "\uD83D\uDCDD Inline Entry" })), onEmbedAsset && (jsx("button", { className: "contentful-toolbar__embed-option", onClick: onEmbedAsset, children: "\uD83D\uDDBC\uFE0F Media" }))] })] }) })] }))] }));
|
|
29058
29181
|
};
|
|
29059
29182
|
|
|
29060
|
-
var
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
|
|
29068
|
-
|
|
29069
|
-
|
|
29070
|
-
|
|
29071
|
-
|
|
29072
|
-
|
|
29073
|
-
|
|
29074
|
-
|
|
29075
|
-
|
|
29076
|
-
|
|
29077
|
-
|
|
29078
|
-
|
|
29079
|
-
|
|
29080
|
-
|
|
29081
|
-
|
|
29082
|
-
|
|
29083
|
-
|
|
29084
|
-
|
|
29085
|
-
|
|
29086
|
-
|
|
29087
|
-
|
|
29088
|
-
|
|
29089
|
-
|
|
29090
|
-
|
|
29091
|
-
|
|
29092
|
-
|
|
29093
|
-
|
|
29094
|
-
|
|
29095
|
-
|
|
29096
|
-
|
|
29097
|
-
|
|
29098
|
-
|
|
29099
|
-
|
|
29100
|
-
|
|
29101
|
-
|
|
29102
|
-
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
function
|
|
29106
|
-
|
|
29107
|
-
|
|
29108
|
-
|
|
29109
|
-
|
|
29110
|
-
|
|
29111
|
-
|
|
29112
|
-
|
|
29113
|
-
|
|
29114
|
-
|
|
29115
|
-
|
|
29116
|
-
|
|
29117
|
-
|
|
29118
|
-
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
|
|
29122
|
-
|
|
29123
|
-
|
|
29124
|
-
|
|
29125
|
-
|
|
29126
|
-
|
|
29127
|
-
|
|
29128
|
-
}
|
|
29129
|
-
|
|
29130
|
-
|
|
29131
|
-
|
|
29132
|
-
|
|
29133
|
-
|
|
29134
|
-
|
|
29135
|
-
|
|
29136
|
-
|
|
29137
|
-
|
|
29138
|
-
|
|
29139
|
-
|
|
29140
|
-
|
|
29141
|
-
|
|
29142
|
-
|
|
29143
|
-
|
|
29144
|
-
|
|
29145
|
-
|
|
29146
|
-
|
|
29147
|
-
|
|
29148
|
-
|
|
29149
|
-
|
|
29150
|
-
|
|
29151
|
-
|
|
29152
|
-
|
|
29153
|
-
|
|
29154
|
-
|
|
29155
|
-
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
|
|
29172
|
-
|
|
29173
|
-
|
|
29174
|
-
|
|
29175
|
-
|
|
29176
|
-
|
|
29177
|
-
|
|
29178
|
-
|
|
29179
|
-
|
|
29180
|
-
|
|
29181
|
-
|
|
29182
|
-
|
|
29183
|
-
|
|
29184
|
-
|
|
29185
|
-
|
|
29186
|
-
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
|
|
29192
|
-
|
|
29193
|
-
|
|
29194
|
-
|
|
29195
|
-
|
|
29196
|
-
|
|
29197
|
-
|
|
29198
|
-
|
|
29199
|
-
|
|
29200
|
-
|
|
29201
|
-
|
|
29202
|
-
|
|
29203
|
-
|
|
29204
|
-
|
|
29205
|
-
|
|
29206
|
-
|
|
29207
|
-
|
|
29208
|
-
|
|
29209
|
-
|
|
29210
|
-
|
|
29211
|
-
|
|
29212
|
-
|
|
29213
|
-
|
|
29214
|
-
|
|
29215
|
-
|
|
29216
|
-
|
|
29217
|
-
|
|
29218
|
-
|
|
29219
|
-
|
|
29220
|
-
|
|
29221
|
-
|
|
29222
|
-
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
|
|
29226
|
-
|
|
29227
|
-
|
|
29228
|
-
|
|
29229
|
-
|
|
29230
|
-
|
|
29231
|
-
|
|
29232
|
-
|
|
29233
|
-
|
|
29234
|
-
|
|
29235
|
-
|
|
29236
|
-
|
|
29237
|
-
|
|
29238
|
-
|
|
29239
|
-
|
|
29240
|
-
|
|
29241
|
-
|
|
29242
|
-
|
|
29243
|
-
|
|
29244
|
-
|
|
29245
|
-
|
|
29246
|
-
|
|
29247
|
-
|
|
29248
|
-
|
|
29249
|
-
|
|
29250
|
-
|
|
29251
|
-
|
|
29252
|
-
|
|
29253
|
-
|
|
29254
|
-
|
|
29255
|
-
|
|
29256
|
-
|
|
29257
|
-
|
|
29258
|
-
|
|
29259
|
-
|
|
29260
|
-
|
|
29261
|
-
|
|
29262
|
-
|
|
29263
|
-
|
|
29264
|
-
|
|
29265
|
-
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
|
|
29269
|
-
|
|
29270
|
-
|
|
29271
|
-
|
|
29272
|
-
|
|
29273
|
-
|
|
29274
|
-
|
|
29275
|
-
|
|
29276
|
-
|
|
29277
|
-
|
|
29278
|
-
|
|
29279
|
-
blocks_1.BLOCKS.HR,
|
|
29280
|
-
blocks_1.BLOCKS.QUOTE,
|
|
29281
|
-
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
29282
|
-
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
29283
|
-
inlines_1.INLINES.HYPERLINK,
|
|
29284
|
-
inlines_1.INLINES.ENTRY_HYPERLINK,
|
|
29285
|
-
inlines_1.INLINES.ASSET_HYPERLINK,
|
|
29286
|
-
inlines_1.INLINES.EMBEDDED_ENTRY,
|
|
29287
|
-
'text',
|
|
29288
|
-
];
|
|
29289
|
-
/**
|
|
29290
|
-
* Marks before `superscript` & `subscript` release.
|
|
29291
|
-
*/
|
|
29292
|
-
exports$1.V1_MARKS = [marks_1.MARKS.BOLD, marks_1.MARKS.CODE, marks_1.MARKS.ITALIC, marks_1.MARKS.UNDERLINE];
|
|
29293
|
-
|
|
29294
|
-
} (schemaConstraints));
|
|
29295
|
-
return schemaConstraints;
|
|
29296
|
-
}
|
|
29297
|
-
|
|
29298
|
-
var types = {};
|
|
29299
|
-
|
|
29300
|
-
var hasRequiredTypes;
|
|
29301
|
-
|
|
29302
|
-
function requireTypes () {
|
|
29303
|
-
if (hasRequiredTypes) return types;
|
|
29304
|
-
hasRequiredTypes = 1;
|
|
29305
|
-
Object.defineProperty(types, "__esModule", { value: true });
|
|
29306
|
-
|
|
29307
|
-
return types;
|
|
29308
|
-
}
|
|
29309
|
-
|
|
29310
|
-
var nodeTypes = {};
|
|
29311
|
-
|
|
29312
|
-
var hasRequiredNodeTypes;
|
|
29313
|
-
|
|
29314
|
-
function requireNodeTypes () {
|
|
29315
|
-
if (hasRequiredNodeTypes) return nodeTypes;
|
|
29316
|
-
hasRequiredNodeTypes = 1;
|
|
29317
|
-
Object.defineProperty(nodeTypes, "__esModule", { value: true });
|
|
29318
|
-
|
|
29319
|
-
return nodeTypes;
|
|
29320
|
-
}
|
|
29321
|
-
|
|
29322
|
-
var emptyDocument = {};
|
|
29323
|
-
|
|
29324
|
-
var hasRequiredEmptyDocument;
|
|
29325
|
-
|
|
29326
|
-
function requireEmptyDocument () {
|
|
29327
|
-
if (hasRequiredEmptyDocument) return emptyDocument;
|
|
29328
|
-
hasRequiredEmptyDocument = 1;
|
|
29329
|
-
Object.defineProperty(emptyDocument, "__esModule", { value: true });
|
|
29330
|
-
emptyDocument.EMPTY_DOCUMENT = void 0;
|
|
29331
|
-
var blocks_1 = requireBlocks();
|
|
29332
|
-
/**
|
|
29333
|
-
* A rich text document considered to be empty.
|
|
29334
|
-
* Any other document structure than this is not considered empty.
|
|
29335
|
-
*/
|
|
29336
|
-
emptyDocument.EMPTY_DOCUMENT = {
|
|
29337
|
-
nodeType: blocks_1.BLOCKS.DOCUMENT,
|
|
29338
|
-
data: {},
|
|
29339
|
-
content: [
|
|
29340
|
-
{
|
|
29341
|
-
nodeType: blocks_1.BLOCKS.PARAGRAPH,
|
|
29342
|
-
data: {},
|
|
29343
|
-
content: [
|
|
29344
|
-
{
|
|
29345
|
-
nodeType: 'text',
|
|
29346
|
-
value: '',
|
|
29347
|
-
marks: [],
|
|
29348
|
-
data: {},
|
|
29349
|
-
},
|
|
29350
|
-
],
|
|
29351
|
-
},
|
|
29352
|
-
],
|
|
29183
|
+
var BLOCKS = /*#__PURE__*/ function(BLOCKS) {
|
|
29184
|
+
BLOCKS["DOCUMENT"] = "document";
|
|
29185
|
+
BLOCKS["PARAGRAPH"] = "paragraph";
|
|
29186
|
+
BLOCKS["HEADING_1"] = "heading-1";
|
|
29187
|
+
BLOCKS["HEADING_2"] = "heading-2";
|
|
29188
|
+
BLOCKS["HEADING_3"] = "heading-3";
|
|
29189
|
+
BLOCKS["HEADING_4"] = "heading-4";
|
|
29190
|
+
BLOCKS["HEADING_5"] = "heading-5";
|
|
29191
|
+
BLOCKS["HEADING_6"] = "heading-6";
|
|
29192
|
+
BLOCKS["OL_LIST"] = "ordered-list";
|
|
29193
|
+
BLOCKS["UL_LIST"] = "unordered-list";
|
|
29194
|
+
BLOCKS["LIST_ITEM"] = "list-item";
|
|
29195
|
+
BLOCKS["HR"] = "hr";
|
|
29196
|
+
BLOCKS["QUOTE"] = "blockquote";
|
|
29197
|
+
BLOCKS["EMBEDDED_ENTRY"] = "embedded-entry-block";
|
|
29198
|
+
BLOCKS["EMBEDDED_ASSET"] = "embedded-asset-block";
|
|
29199
|
+
BLOCKS["EMBEDDED_RESOURCE"] = "embedded-resource-block";
|
|
29200
|
+
BLOCKS["TABLE"] = "table";
|
|
29201
|
+
BLOCKS["TABLE_ROW"] = "table-row";
|
|
29202
|
+
BLOCKS["TABLE_CELL"] = "table-cell";
|
|
29203
|
+
BLOCKS["TABLE_HEADER_CELL"] = "table-header-cell";
|
|
29204
|
+
return BLOCKS;
|
|
29205
|
+
}({});
|
|
29206
|
+
|
|
29207
|
+
var INLINES = /*#__PURE__*/ function(INLINES) {
|
|
29208
|
+
INLINES["ASSET_HYPERLINK"] = "asset-hyperlink";
|
|
29209
|
+
INLINES["EMBEDDED_ENTRY"] = "embedded-entry-inline";
|
|
29210
|
+
INLINES["EMBEDDED_RESOURCE"] = "embedded-resource-inline";
|
|
29211
|
+
INLINES["ENTRY_HYPERLINK"] = "entry-hyperlink";
|
|
29212
|
+
INLINES["HYPERLINK"] = "hyperlink";
|
|
29213
|
+
INLINES["RESOURCE_HYPERLINK"] = "resource-hyperlink";
|
|
29214
|
+
return INLINES;
|
|
29215
|
+
}({});
|
|
29216
|
+
|
|
29217
|
+
var MARKS = /*#__PURE__*/ function(MARKS) {
|
|
29218
|
+
MARKS["BOLD"] = "bold";
|
|
29219
|
+
MARKS["ITALIC"] = "italic";
|
|
29220
|
+
MARKS["UNDERLINE"] = "underline";
|
|
29221
|
+
MARKS["CODE"] = "code";
|
|
29222
|
+
MARKS["SUPERSCRIPT"] = "superscript";
|
|
29223
|
+
MARKS["SUBSCRIPT"] = "subscript";
|
|
29224
|
+
MARKS["STRIKETHROUGH"] = "strikethrough";
|
|
29225
|
+
return MARKS;
|
|
29226
|
+
}({});
|
|
29227
|
+
|
|
29228
|
+
function _array_like_to_array$4(arr, len) {
|
|
29229
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
29230
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
29231
|
+
return arr2;
|
|
29232
|
+
}
|
|
29233
|
+
function _array_without_holes$4(arr) {
|
|
29234
|
+
if (Array.isArray(arr)) return _array_like_to_array$4(arr);
|
|
29235
|
+
}
|
|
29236
|
+
function _define_property$3(obj, key, value) {
|
|
29237
|
+
if (key in obj) {
|
|
29238
|
+
Object.defineProperty(obj, key, {
|
|
29239
|
+
value: value,
|
|
29240
|
+
enumerable: true,
|
|
29241
|
+
configurable: true,
|
|
29242
|
+
writable: true
|
|
29243
|
+
});
|
|
29244
|
+
} else {
|
|
29245
|
+
obj[key] = value;
|
|
29246
|
+
}
|
|
29247
|
+
return obj;
|
|
29248
|
+
}
|
|
29249
|
+
function _iterable_to_array$4(iter) {
|
|
29250
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
29251
|
+
}
|
|
29252
|
+
function _non_iterable_spread$4() {
|
|
29253
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29254
|
+
}
|
|
29255
|
+
function _to_consumable_array$4(arr) {
|
|
29256
|
+
return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$4();
|
|
29257
|
+
}
|
|
29258
|
+
function _unsupported_iterable_to_array$4(o, minLen) {
|
|
29259
|
+
if (!o) return;
|
|
29260
|
+
if (typeof o === "string") return _array_like_to_array$4(o, minLen);
|
|
29261
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
29262
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
29263
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
29264
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
|
|
29265
|
+
}
|
|
29266
|
+
var TOP_LEVEL_BLOCKS = [
|
|
29267
|
+
BLOCKS.PARAGRAPH,
|
|
29268
|
+
BLOCKS.HEADING_1,
|
|
29269
|
+
BLOCKS.HEADING_2,
|
|
29270
|
+
BLOCKS.HEADING_3,
|
|
29271
|
+
BLOCKS.HEADING_4,
|
|
29272
|
+
BLOCKS.HEADING_5,
|
|
29273
|
+
BLOCKS.HEADING_6,
|
|
29274
|
+
BLOCKS.OL_LIST,
|
|
29275
|
+
BLOCKS.UL_LIST,
|
|
29276
|
+
BLOCKS.HR,
|
|
29277
|
+
BLOCKS.QUOTE,
|
|
29278
|
+
BLOCKS.EMBEDDED_ENTRY,
|
|
29279
|
+
BLOCKS.EMBEDDED_ASSET,
|
|
29280
|
+
BLOCKS.EMBEDDED_RESOURCE,
|
|
29281
|
+
BLOCKS.TABLE
|
|
29282
|
+
];
|
|
29283
|
+
var LIST_ITEM_BLOCKS = [
|
|
29284
|
+
BLOCKS.PARAGRAPH,
|
|
29285
|
+
BLOCKS.HEADING_1,
|
|
29286
|
+
BLOCKS.HEADING_2,
|
|
29287
|
+
BLOCKS.HEADING_3,
|
|
29288
|
+
BLOCKS.HEADING_4,
|
|
29289
|
+
BLOCKS.HEADING_5,
|
|
29290
|
+
BLOCKS.HEADING_6,
|
|
29291
|
+
BLOCKS.OL_LIST,
|
|
29292
|
+
BLOCKS.UL_LIST,
|
|
29293
|
+
BLOCKS.HR,
|
|
29294
|
+
BLOCKS.QUOTE,
|
|
29295
|
+
BLOCKS.EMBEDDED_ENTRY,
|
|
29296
|
+
BLOCKS.EMBEDDED_ASSET,
|
|
29297
|
+
BLOCKS.EMBEDDED_RESOURCE
|
|
29298
|
+
];
|
|
29299
|
+
[
|
|
29300
|
+
BLOCKS.TABLE,
|
|
29301
|
+
BLOCKS.TABLE_ROW,
|
|
29302
|
+
BLOCKS.TABLE_CELL,
|
|
29303
|
+
BLOCKS.TABLE_HEADER_CELL
|
|
29304
|
+
];
|
|
29305
|
+
[
|
|
29306
|
+
BLOCKS.HR,
|
|
29307
|
+
BLOCKS.EMBEDDED_ENTRY,
|
|
29308
|
+
BLOCKS.EMBEDDED_ASSET,
|
|
29309
|
+
BLOCKS.EMBEDDED_RESOURCE
|
|
29310
|
+
];
|
|
29311
|
+
var _obj$1;
|
|
29312
|
+
var CONTAINERS = (_obj$1 = {}, _define_property$3(_obj$1, BLOCKS.OL_LIST, [
|
|
29313
|
+
BLOCKS.LIST_ITEM
|
|
29314
|
+
]), _define_property$3(_obj$1, BLOCKS.UL_LIST, [
|
|
29315
|
+
BLOCKS.LIST_ITEM
|
|
29316
|
+
]), _define_property$3(_obj$1, BLOCKS.LIST_ITEM, LIST_ITEM_BLOCKS), _define_property$3(_obj$1, BLOCKS.QUOTE, [
|
|
29317
|
+
BLOCKS.PARAGRAPH
|
|
29318
|
+
]), _define_property$3(_obj$1, BLOCKS.TABLE, [
|
|
29319
|
+
BLOCKS.TABLE_ROW
|
|
29320
|
+
]), _define_property$3(_obj$1, BLOCKS.TABLE_ROW, [
|
|
29321
|
+
BLOCKS.TABLE_CELL,
|
|
29322
|
+
BLOCKS.TABLE_HEADER_CELL
|
|
29323
|
+
]), _define_property$3(_obj$1, BLOCKS.TABLE_CELL, [
|
|
29324
|
+
BLOCKS.PARAGRAPH,
|
|
29325
|
+
BLOCKS.UL_LIST,
|
|
29326
|
+
BLOCKS.OL_LIST
|
|
29327
|
+
]), _define_property$3(_obj$1, BLOCKS.TABLE_HEADER_CELL, [
|
|
29328
|
+
BLOCKS.PARAGRAPH
|
|
29329
|
+
]), _obj$1);
|
|
29330
|
+
var HEADINGS = [
|
|
29331
|
+
BLOCKS.HEADING_1,
|
|
29332
|
+
BLOCKS.HEADING_2,
|
|
29333
|
+
BLOCKS.HEADING_3,
|
|
29334
|
+
BLOCKS.HEADING_4,
|
|
29335
|
+
BLOCKS.HEADING_5,
|
|
29336
|
+
BLOCKS.HEADING_6
|
|
29337
|
+
];
|
|
29338
|
+
[
|
|
29339
|
+
BLOCKS.PARAGRAPH
|
|
29340
|
+
].concat(_to_consumable_array$4(HEADINGS));
|
|
29341
|
+
[
|
|
29342
|
+
BLOCKS.DOCUMENT,
|
|
29343
|
+
BLOCKS.PARAGRAPH,
|
|
29344
|
+
BLOCKS.HEADING_1,
|
|
29345
|
+
BLOCKS.HEADING_2,
|
|
29346
|
+
BLOCKS.HEADING_3,
|
|
29347
|
+
BLOCKS.HEADING_4,
|
|
29348
|
+
BLOCKS.HEADING_5,
|
|
29349
|
+
BLOCKS.HEADING_6,
|
|
29350
|
+
BLOCKS.OL_LIST,
|
|
29351
|
+
BLOCKS.UL_LIST,
|
|
29352
|
+
BLOCKS.LIST_ITEM,
|
|
29353
|
+
BLOCKS.HR,
|
|
29354
|
+
BLOCKS.QUOTE,
|
|
29355
|
+
BLOCKS.EMBEDDED_ENTRY,
|
|
29356
|
+
BLOCKS.EMBEDDED_ASSET,
|
|
29357
|
+
INLINES.HYPERLINK,
|
|
29358
|
+
INLINES.ENTRY_HYPERLINK,
|
|
29359
|
+
INLINES.ASSET_HYPERLINK,
|
|
29360
|
+
INLINES.EMBEDDED_ENTRY,
|
|
29361
|
+
'text'
|
|
29362
|
+
];
|
|
29363
|
+
[
|
|
29364
|
+
MARKS.BOLD,
|
|
29365
|
+
MARKS.CODE,
|
|
29366
|
+
MARKS.ITALIC,
|
|
29367
|
+
MARKS.UNDERLINE
|
|
29368
|
+
];
|
|
29369
|
+
|
|
29370
|
+
({
|
|
29371
|
+
nodeType: BLOCKS.DOCUMENT,
|
|
29372
|
+
content: [
|
|
29373
|
+
{
|
|
29374
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
29375
|
+
data: {},
|
|
29376
|
+
content: [
|
|
29377
|
+
{
|
|
29378
|
+
nodeType: 'text',
|
|
29379
|
+
value: '',
|
|
29380
|
+
marks: [],
|
|
29381
|
+
data: {}
|
|
29382
|
+
}
|
|
29383
|
+
]
|
|
29384
|
+
}
|
|
29385
|
+
]
|
|
29386
|
+
});
|
|
29387
|
+
|
|
29388
|
+
var isPlainObj;
|
|
29389
|
+
var hasRequiredIsPlainObj;
|
|
29390
|
+
|
|
29391
|
+
function requireIsPlainObj () {
|
|
29392
|
+
if (hasRequiredIsPlainObj) return isPlainObj;
|
|
29393
|
+
hasRequiredIsPlainObj = 1;
|
|
29394
|
+
|
|
29395
|
+
isPlainObj = value => {
|
|
29396
|
+
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
29397
|
+
return false;
|
|
29398
|
+
}
|
|
29399
|
+
|
|
29400
|
+
const prototype = Object.getPrototypeOf(value);
|
|
29401
|
+
return prototype === null || prototype === Object.prototype;
|
|
29353
29402
|
};
|
|
29354
|
-
|
|
29355
|
-
return emptyDocument;
|
|
29356
|
-
}
|
|
29357
|
-
|
|
29358
|
-
var helpers = {};
|
|
29359
|
-
|
|
29360
|
-
var hasRequiredHelpers;
|
|
29361
|
-
|
|
29362
|
-
function requireHelpers () {
|
|
29363
|
-
if (hasRequiredHelpers) return helpers;
|
|
29364
|
-
hasRequiredHelpers = 1;
|
|
29365
|
-
Object.defineProperty(helpers, "__esModule", { value: true });
|
|
29366
|
-
helpers.isInline = isInline;
|
|
29367
|
-
helpers.isBlock = isBlock;
|
|
29368
|
-
helpers.isText = isText;
|
|
29369
|
-
var blocks_1 = requireBlocks();
|
|
29370
|
-
var inlines_1 = requireInlines();
|
|
29371
|
-
/**
|
|
29372
|
-
* Tiny replacement for Object.values(object).includes(key) to
|
|
29373
|
-
* avoid including CoreJS polyfills
|
|
29374
|
-
*/
|
|
29375
|
-
function hasValue(obj, value) {
|
|
29376
|
-
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
29377
|
-
var key = _a[_i];
|
|
29378
|
-
if (value === obj[key]) {
|
|
29379
|
-
return true;
|
|
29380
|
-
}
|
|
29381
|
-
}
|
|
29382
|
-
return false;
|
|
29383
|
-
}
|
|
29384
|
-
/**
|
|
29385
|
-
* Checks if the node is an instance of Inline.
|
|
29386
|
-
*/
|
|
29387
|
-
function isInline(node) {
|
|
29388
|
-
return hasValue(inlines_1.INLINES, node.nodeType);
|
|
29389
|
-
}
|
|
29390
|
-
/**
|
|
29391
|
-
* Checks if the node is an instance of Block.
|
|
29392
|
-
*/
|
|
29393
|
-
function isBlock(node) {
|
|
29394
|
-
return hasValue(blocks_1.BLOCKS, node.nodeType);
|
|
29395
|
-
}
|
|
29396
|
-
/**
|
|
29397
|
-
* Checks if the node is an instance of Text.
|
|
29398
|
-
*/
|
|
29399
|
-
function isText(node) {
|
|
29400
|
-
return node.nodeType === 'text';
|
|
29401
|
-
}
|
|
29402
|
-
|
|
29403
|
-
return helpers;
|
|
29403
|
+
return isPlainObj;
|
|
29404
29404
|
}
|
|
29405
29405
|
|
|
29406
|
-
|
|
29407
|
-
|
|
29406
|
+
var isPlainObjExports = requireIsPlainObj();
|
|
29407
|
+
var isPlainObject = /*@__PURE__*/getDefaultExportFromCjs(isPlainObjExports);
|
|
29408
|
+
|
|
29409
|
+
function _array_like_to_array$3(arr, len) {
|
|
29410
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
29411
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
29412
|
+
return arr2;
|
|
29413
|
+
}
|
|
29414
|
+
function _array_without_holes$3(arr) {
|
|
29415
|
+
if (Array.isArray(arr)) return _array_like_to_array$3(arr);
|
|
29408
29416
|
}
|
|
29417
|
+
function _iterable_to_array$3(iter) {
|
|
29418
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
29419
|
+
}
|
|
29420
|
+
function _non_iterable_spread$3() {
|
|
29421
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29422
|
+
}
|
|
29423
|
+
function _to_consumable_array$3(arr) {
|
|
29424
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread$3();
|
|
29425
|
+
}
|
|
29426
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
29427
|
+
if (!o) return;
|
|
29428
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
29429
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
29430
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
29431
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
29432
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
29433
|
+
}
|
|
29434
|
+
var typeMismatchError = function(param) {
|
|
29435
|
+
var path = param.path, property = param.property, typeName = param.typeName, value = param.value;
|
|
29436
|
+
return {
|
|
29437
|
+
details: 'The type of "'.concat(property, '" is incorrect, expected type: ').concat(typeName),
|
|
29438
|
+
name: 'type',
|
|
29439
|
+
path: path.toArray(),
|
|
29440
|
+
type: typeName,
|
|
29441
|
+
value: value
|
|
29442
|
+
};
|
|
29443
|
+
};
|
|
29444
|
+
var minSizeError = function(param) {
|
|
29445
|
+
var min = param.min, value = param.value, path = param.path;
|
|
29446
|
+
return {
|
|
29447
|
+
name: 'size',
|
|
29448
|
+
min: min,
|
|
29449
|
+
path: path.toArray(),
|
|
29450
|
+
details: "Size must be at least ".concat(min),
|
|
29451
|
+
value: value
|
|
29452
|
+
};
|
|
29453
|
+
};
|
|
29454
|
+
var maxSizeError = function(param) {
|
|
29455
|
+
var max = param.max, value = param.value, path = param.path;
|
|
29456
|
+
return {
|
|
29457
|
+
name: 'size',
|
|
29458
|
+
max: max,
|
|
29459
|
+
path: path.toArray(),
|
|
29460
|
+
details: "Size must be at most ".concat(max),
|
|
29461
|
+
value: value
|
|
29462
|
+
};
|
|
29463
|
+
};
|
|
29464
|
+
var enumError = function(param) {
|
|
29465
|
+
var expected = param.expected, value = param.value, path = param.path;
|
|
29466
|
+
return {
|
|
29467
|
+
details: "Value must be one of expected values",
|
|
29468
|
+
name: 'in',
|
|
29469
|
+
expected: _to_consumable_array$3(expected).sort(),
|
|
29470
|
+
path: path.toArray(),
|
|
29471
|
+
value: value
|
|
29472
|
+
};
|
|
29473
|
+
};
|
|
29474
|
+
var unknownPropertyError = function(param) {
|
|
29475
|
+
var property = param.property, path = param.path;
|
|
29476
|
+
return {
|
|
29477
|
+
details: 'The property "'.concat(property, '" is not expected'),
|
|
29478
|
+
name: 'unexpected',
|
|
29479
|
+
path: path.toArray()
|
|
29480
|
+
};
|
|
29481
|
+
};
|
|
29482
|
+
var requiredPropertyError = function(param) {
|
|
29483
|
+
var property = param.property, path = param.path;
|
|
29484
|
+
return {
|
|
29485
|
+
details: 'The property "'.concat(property, '" is required here'),
|
|
29486
|
+
name: 'required',
|
|
29487
|
+
path: path.toArray()
|
|
29488
|
+
};
|
|
29489
|
+
};
|
|
29409
29490
|
|
|
29410
|
-
|
|
29491
|
+
function _array_like_to_array$2(arr, len) {
|
|
29492
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
29493
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
29494
|
+
return arr2;
|
|
29495
|
+
}
|
|
29496
|
+
function _array_without_holes$2(arr) {
|
|
29497
|
+
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
|
|
29498
|
+
}
|
|
29499
|
+
function _class_call_check$1(instance, Constructor) {
|
|
29500
|
+
if (!(instance instanceof Constructor)) {
|
|
29501
|
+
throw new TypeError("Cannot call a class as a function");
|
|
29502
|
+
}
|
|
29503
|
+
}
|
|
29504
|
+
function _defineProperties$1(target, props) {
|
|
29505
|
+
for(var i = 0; i < props.length; i++){
|
|
29506
|
+
var descriptor = props[i];
|
|
29507
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
29508
|
+
descriptor.configurable = true;
|
|
29509
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
29510
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
29511
|
+
}
|
|
29512
|
+
}
|
|
29513
|
+
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
29514
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
29515
|
+
return Constructor;
|
|
29516
|
+
}
|
|
29517
|
+
function _define_property$2(obj, key, value) {
|
|
29518
|
+
if (key in obj) {
|
|
29519
|
+
Object.defineProperty(obj, key, {
|
|
29520
|
+
value: value,
|
|
29521
|
+
enumerable: true,
|
|
29522
|
+
configurable: true,
|
|
29523
|
+
writable: true
|
|
29524
|
+
});
|
|
29525
|
+
} else {
|
|
29526
|
+
obj[key] = value;
|
|
29527
|
+
}
|
|
29528
|
+
return obj;
|
|
29529
|
+
}
|
|
29530
|
+
function _iterable_to_array$2(iter) {
|
|
29531
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
29532
|
+
}
|
|
29533
|
+
function _non_iterable_spread$2() {
|
|
29534
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29535
|
+
}
|
|
29536
|
+
function _to_consumable_array$2(arr) {
|
|
29537
|
+
return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$2();
|
|
29538
|
+
}
|
|
29539
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
29540
|
+
if (!o) return;
|
|
29541
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
29542
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
29543
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
29544
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
29545
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
29546
|
+
}
|
|
29547
|
+
var ObjectAssertion = /*#__PURE__*/ function() {
|
|
29548
|
+
function ObjectAssertion(obj, path) {
|
|
29549
|
+
var _this = this;
|
|
29550
|
+
var _this1 = this;
|
|
29551
|
+
_class_call_check$1(this, ObjectAssertion);
|
|
29552
|
+
_define_property$2(this, "obj", void 0);
|
|
29553
|
+
_define_property$2(this, "path", void 0);
|
|
29554
|
+
_define_property$2(this, "_errors", void 0);
|
|
29555
|
+
_define_property$2(this, "catch", void 0);
|
|
29556
|
+
_define_property$2(this, "exists", void 0);
|
|
29557
|
+
_define_property$2(this, "object", void 0);
|
|
29558
|
+
_define_property$2(this, "string", void 0);
|
|
29559
|
+
_define_property$2(this, "number", void 0);
|
|
29560
|
+
_define_property$2(this, "array", void 0);
|
|
29561
|
+
_define_property$2(this, "enum", void 0);
|
|
29562
|
+
_define_property$2(this, "empty", void 0);
|
|
29563
|
+
_define_property$2(this, "minLength", void 0);
|
|
29564
|
+
_define_property$2(this, "noAdditionalProperties", void 0);
|
|
29565
|
+
_define_property$2(this, "each", void 0);
|
|
29566
|
+
this.obj = obj;
|
|
29567
|
+
this.path = path;
|
|
29568
|
+
this._errors = [];
|
|
29569
|
+
this.catch = function() {
|
|
29570
|
+
for(var _len = arguments.length, errors = new Array(_len), _key = 0; _key < _len; _key++){
|
|
29571
|
+
errors[_key] = arguments[_key];
|
|
29572
|
+
}
|
|
29573
|
+
var _this__errors;
|
|
29574
|
+
(_this__errors = _this1._errors).push.apply(_this__errors, _to_consumable_array$2(errors));
|
|
29575
|
+
};
|
|
29576
|
+
this.exists = function(key) {
|
|
29577
|
+
if (key in _this.obj) {
|
|
29578
|
+
return true;
|
|
29579
|
+
}
|
|
29580
|
+
_this.catch(requiredPropertyError({
|
|
29581
|
+
property: key,
|
|
29582
|
+
path: _this.path.of(key)
|
|
29583
|
+
}));
|
|
29584
|
+
return false;
|
|
29585
|
+
};
|
|
29586
|
+
this.object = function(key) {
|
|
29587
|
+
var value = key ? _this.obj[key] : _this.obj;
|
|
29588
|
+
if (key) {
|
|
29589
|
+
if (!_this.exists(key)) {
|
|
29590
|
+
return false;
|
|
29591
|
+
}
|
|
29592
|
+
}
|
|
29593
|
+
if (isPlainObject(value)) {
|
|
29594
|
+
return true;
|
|
29595
|
+
}
|
|
29596
|
+
var _$path = key ? _this.path.of(key) : _this.path;
|
|
29597
|
+
var _ref;
|
|
29598
|
+
var property = (_ref = key !== null && key !== void 0 ? key : _this.path.last()) !== null && _ref !== void 0 ? _ref : 'value';
|
|
29599
|
+
_this.catch(typeMismatchError({
|
|
29600
|
+
typeName: 'Object',
|
|
29601
|
+
property: property,
|
|
29602
|
+
path: _$path,
|
|
29603
|
+
value: value
|
|
29604
|
+
}));
|
|
29605
|
+
return false;
|
|
29606
|
+
};
|
|
29607
|
+
this.string = function(key) {
|
|
29608
|
+
var value = _this.obj[key];
|
|
29609
|
+
if (key && !_this.exists(key)) {
|
|
29610
|
+
return false;
|
|
29611
|
+
}
|
|
29612
|
+
if (typeof value === 'string') {
|
|
29613
|
+
return true;
|
|
29614
|
+
}
|
|
29615
|
+
_this.catch(typeMismatchError({
|
|
29616
|
+
typeName: 'String',
|
|
29617
|
+
property: key,
|
|
29618
|
+
path: _this.path.of(key),
|
|
29619
|
+
value: value
|
|
29620
|
+
}));
|
|
29621
|
+
return false;
|
|
29622
|
+
};
|
|
29623
|
+
this.number = function(key, optional) {
|
|
29624
|
+
var value = _this.obj[key];
|
|
29625
|
+
if (optional && !(key in _this.obj)) {
|
|
29626
|
+
return true;
|
|
29627
|
+
}
|
|
29628
|
+
if (!_this.exists(key)) {
|
|
29629
|
+
return false;
|
|
29630
|
+
}
|
|
29631
|
+
if (typeof value === 'number' && !Number.isNaN(value)) {
|
|
29632
|
+
return true;
|
|
29633
|
+
}
|
|
29634
|
+
_this.catch(typeMismatchError({
|
|
29635
|
+
typeName: 'Number',
|
|
29636
|
+
property: key,
|
|
29637
|
+
path: _this.path.of(key),
|
|
29638
|
+
value: value
|
|
29639
|
+
}));
|
|
29640
|
+
return false;
|
|
29641
|
+
};
|
|
29642
|
+
this.array = function(key) {
|
|
29643
|
+
var value = _this.obj[key];
|
|
29644
|
+
if (key && !_this.exists(key)) {
|
|
29645
|
+
return false;
|
|
29646
|
+
}
|
|
29647
|
+
if (Array.isArray(value)) {
|
|
29648
|
+
return true;
|
|
29649
|
+
}
|
|
29650
|
+
_this.catch(typeMismatchError({
|
|
29651
|
+
typeName: 'Array',
|
|
29652
|
+
property: key,
|
|
29653
|
+
path: _this.path.of(key),
|
|
29654
|
+
value: value
|
|
29655
|
+
}));
|
|
29656
|
+
return false;
|
|
29657
|
+
};
|
|
29658
|
+
this.enum = function(key, expected) {
|
|
29659
|
+
var value = _this.obj[key];
|
|
29660
|
+
if (typeof value === 'string' && expected.includes(value)) {
|
|
29661
|
+
return true;
|
|
29662
|
+
}
|
|
29663
|
+
_this.catch(enumError({
|
|
29664
|
+
expected: expected,
|
|
29665
|
+
value: value,
|
|
29666
|
+
path: _this.path.of(key)
|
|
29667
|
+
}));
|
|
29668
|
+
return false;
|
|
29669
|
+
};
|
|
29670
|
+
this.empty = function(key) {
|
|
29671
|
+
if (!_this.array(key)) {
|
|
29672
|
+
return false;
|
|
29673
|
+
}
|
|
29674
|
+
var value = _this.obj[key];
|
|
29675
|
+
if (value.length === 0) {
|
|
29676
|
+
return true;
|
|
29677
|
+
}
|
|
29678
|
+
_this.catch(maxSizeError({
|
|
29679
|
+
max: 0,
|
|
29680
|
+
value: value,
|
|
29681
|
+
path: _this.path.of(key)
|
|
29682
|
+
}));
|
|
29683
|
+
return false;
|
|
29684
|
+
};
|
|
29685
|
+
this.minLength = function(key, min) {
|
|
29686
|
+
if (!_this.array(key)) {
|
|
29687
|
+
return false;
|
|
29688
|
+
}
|
|
29689
|
+
var value = _this.obj[key];
|
|
29690
|
+
if (value.length >= min) {
|
|
29691
|
+
return true;
|
|
29692
|
+
}
|
|
29693
|
+
_this.catch(minSizeError({
|
|
29694
|
+
min: min,
|
|
29695
|
+
value: value,
|
|
29696
|
+
path: _this.path.of(key)
|
|
29697
|
+
}));
|
|
29698
|
+
return false;
|
|
29699
|
+
};
|
|
29700
|
+
this.noAdditionalProperties = function(properties) {
|
|
29701
|
+
var unknowns = Object.keys(_this.obj).sort().filter(function(key) {
|
|
29702
|
+
return !properties.includes(key);
|
|
29703
|
+
});
|
|
29704
|
+
unknowns.forEach(function(property) {
|
|
29705
|
+
return _this.catch(unknownPropertyError({
|
|
29706
|
+
property: property,
|
|
29707
|
+
path: _this.path.of(property)
|
|
29708
|
+
}));
|
|
29709
|
+
});
|
|
29710
|
+
return unknowns.length === 0;
|
|
29711
|
+
};
|
|
29712
|
+
this.each = function(key, assert) {
|
|
29713
|
+
if (!_this.array(key)) {
|
|
29714
|
+
return;
|
|
29715
|
+
}
|
|
29716
|
+
var value = _this.obj[key];
|
|
29717
|
+
var foundErrors = false;
|
|
29718
|
+
value.forEach(function(item, index) {
|
|
29719
|
+
if (foundErrors) {
|
|
29720
|
+
return;
|
|
29721
|
+
}
|
|
29722
|
+
var errors = assert(item, _this.path.of(key).of(index));
|
|
29723
|
+
if (errors.length > 0) {
|
|
29724
|
+
foundErrors = true;
|
|
29725
|
+
}
|
|
29726
|
+
_this.catch.apply(_this, _to_consumable_array$2(errors));
|
|
29727
|
+
});
|
|
29728
|
+
};
|
|
29729
|
+
}
|
|
29730
|
+
_create_class$1(ObjectAssertion, [
|
|
29731
|
+
{
|
|
29732
|
+
key: "errors",
|
|
29733
|
+
get: function get() {
|
|
29734
|
+
var _this = this;
|
|
29735
|
+
var serializeError = function(error) {
|
|
29736
|
+
return JSON.stringify({
|
|
29737
|
+
details: error.details,
|
|
29738
|
+
path: error.path
|
|
29739
|
+
});
|
|
29740
|
+
};
|
|
29741
|
+
return this._errors.filter(function(error, index) {
|
|
29742
|
+
return _this._errors.findIndex(function(step) {
|
|
29743
|
+
return serializeError(error) === serializeError(step);
|
|
29744
|
+
}) === index;
|
|
29745
|
+
});
|
|
29746
|
+
}
|
|
29747
|
+
}
|
|
29748
|
+
]);
|
|
29749
|
+
return ObjectAssertion;
|
|
29750
|
+
}();
|
|
29411
29751
|
|
|
29412
|
-
|
|
29752
|
+
function _array_like_to_array$1(arr, len) {
|
|
29753
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
29754
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
29755
|
+
return arr2;
|
|
29756
|
+
}
|
|
29757
|
+
function _array_without_holes$1(arr) {
|
|
29758
|
+
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
|
|
29759
|
+
}
|
|
29760
|
+
function _assert_this_initialized(self) {
|
|
29761
|
+
if (self === void 0) {
|
|
29762
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
29763
|
+
}
|
|
29764
|
+
return self;
|
|
29765
|
+
}
|
|
29766
|
+
function _call_super(_this, derived, args) {
|
|
29767
|
+
derived = _get_prototype_of(derived);
|
|
29768
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
29769
|
+
}
|
|
29770
|
+
function _class_call_check(instance, Constructor) {
|
|
29771
|
+
if (!(instance instanceof Constructor)) {
|
|
29772
|
+
throw new TypeError("Cannot call a class as a function");
|
|
29773
|
+
}
|
|
29774
|
+
}
|
|
29775
|
+
function _defineProperties(target, props) {
|
|
29776
|
+
for(var i = 0; i < props.length; i++){
|
|
29777
|
+
var descriptor = props[i];
|
|
29778
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
29779
|
+
descriptor.configurable = true;
|
|
29780
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
29781
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
29782
|
+
}
|
|
29783
|
+
}
|
|
29784
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
29785
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
29786
|
+
return Constructor;
|
|
29787
|
+
}
|
|
29788
|
+
function _define_property$1(obj, key, value) {
|
|
29789
|
+
if (key in obj) {
|
|
29790
|
+
Object.defineProperty(obj, key, {
|
|
29791
|
+
value: value,
|
|
29792
|
+
enumerable: true,
|
|
29793
|
+
configurable: true,
|
|
29794
|
+
writable: true
|
|
29795
|
+
});
|
|
29796
|
+
} else {
|
|
29797
|
+
obj[key] = value;
|
|
29798
|
+
}
|
|
29799
|
+
return obj;
|
|
29800
|
+
}
|
|
29801
|
+
function _get_prototype_of(o) {
|
|
29802
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
29803
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
29804
|
+
};
|
|
29805
|
+
return _get_prototype_of(o);
|
|
29806
|
+
}
|
|
29807
|
+
function _inherits(subClass, superClass) {
|
|
29808
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
29809
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
29810
|
+
}
|
|
29811
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
29812
|
+
constructor: {
|
|
29813
|
+
value: subClass,
|
|
29814
|
+
writable: true,
|
|
29815
|
+
configurable: true
|
|
29816
|
+
}
|
|
29817
|
+
});
|
|
29818
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
29819
|
+
}
|
|
29820
|
+
function _iterable_to_array$1(iter) {
|
|
29821
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
29822
|
+
}
|
|
29823
|
+
function _non_iterable_spread$1() {
|
|
29824
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29825
|
+
}
|
|
29826
|
+
function _possible_constructor_return(self, call) {
|
|
29827
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
29828
|
+
return call;
|
|
29829
|
+
}
|
|
29830
|
+
return _assert_this_initialized(self);
|
|
29831
|
+
}
|
|
29832
|
+
function _set_prototype_of(o, p) {
|
|
29833
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
29834
|
+
o.__proto__ = p;
|
|
29835
|
+
return o;
|
|
29836
|
+
};
|
|
29837
|
+
return _set_prototype_of(o, p);
|
|
29838
|
+
}
|
|
29839
|
+
function _to_consumable_array$1(arr) {
|
|
29840
|
+
return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread$1();
|
|
29841
|
+
}
|
|
29842
|
+
function _type_of(obj) {
|
|
29843
|
+
"@swc/helpers - typeof";
|
|
29844
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
29845
|
+
}
|
|
29846
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
29847
|
+
if (!o) return;
|
|
29848
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
29849
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
29850
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
29851
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
29852
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
29853
|
+
}
|
|
29854
|
+
function _is_native_reflect_construct() {
|
|
29855
|
+
try {
|
|
29856
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
29857
|
+
} catch (_) {}
|
|
29858
|
+
return (_is_native_reflect_construct = function() {
|
|
29859
|
+
return !!result;
|
|
29860
|
+
})();
|
|
29861
|
+
}
|
|
29862
|
+
var VOID_CONTENT = [];
|
|
29863
|
+
var NodeAssertion = /*#__PURE__*/ function() {
|
|
29864
|
+
function NodeAssertion(contentRule, validateData) {
|
|
29865
|
+
_class_call_check(this, NodeAssertion);
|
|
29866
|
+
_define_property$1(this, "contentRule", void 0);
|
|
29867
|
+
_define_property$1(this, "validateData", void 0);
|
|
29868
|
+
this.contentRule = contentRule;
|
|
29869
|
+
this.validateData = validateData;
|
|
29870
|
+
}
|
|
29871
|
+
_create_class(NodeAssertion, [
|
|
29872
|
+
{
|
|
29873
|
+
key: "assert",
|
|
29874
|
+
value: function assert(node, path) {
|
|
29875
|
+
var $ = new ObjectAssertion(node, path);
|
|
29876
|
+
if (!$.object()) {
|
|
29877
|
+
return $.errors;
|
|
29878
|
+
}
|
|
29879
|
+
$.noAdditionalProperties([
|
|
29880
|
+
'nodeType',
|
|
29881
|
+
'data',
|
|
29882
|
+
'content'
|
|
29883
|
+
]);
|
|
29884
|
+
var _ref = Array.isArray(this.contentRule) ? {
|
|
29885
|
+
nodeTypes: this.contentRule
|
|
29886
|
+
} : this.contentRule(node, path), nodeTypes = _ref.nodeTypes, _ref_min = _ref.min, min = _ref_min === void 0 ? 0 : _ref_min;
|
|
29887
|
+
if (nodeTypes.length === 0 && min > 0) {
|
|
29888
|
+
throw new Error("Invalid content rule. Cannot have enforce a 'min' of ".concat(min, " with no nodeTypes"));
|
|
29889
|
+
}
|
|
29890
|
+
$.minLength('content', min);
|
|
29891
|
+
if (nodeTypes.length === 0) {
|
|
29892
|
+
$.empty('content');
|
|
29893
|
+
} else {
|
|
29894
|
+
$.each('content', function(item, path) {
|
|
29895
|
+
var item$ = new ObjectAssertion(item, path);
|
|
29896
|
+
if (!item$.object()) {
|
|
29897
|
+
return item$.errors;
|
|
29898
|
+
}
|
|
29899
|
+
item$.enum('nodeType', nodeTypes);
|
|
29900
|
+
return item$.errors;
|
|
29901
|
+
});
|
|
29902
|
+
}
|
|
29903
|
+
if ($.object('data')) {
|
|
29904
|
+
var _$;
|
|
29905
|
+
var _this_validateData, _this;
|
|
29906
|
+
var _this_validateData1;
|
|
29907
|
+
var dataErrors = (_this_validateData1 = (_this_validateData = (_this = this).validateData) === null || _this_validateData === void 0 ? void 0 : _this_validateData.call(_this, node.data, path.of('data'))) !== null && _this_validateData1 !== void 0 ? _this_validateData1 : [];
|
|
29908
|
+
(_$ = $).catch.apply(_$, _to_consumable_array$1(dataErrors));
|
|
29909
|
+
}
|
|
29910
|
+
return $.errors;
|
|
29911
|
+
}
|
|
29912
|
+
}
|
|
29913
|
+
]);
|
|
29914
|
+
return NodeAssertion;
|
|
29915
|
+
}();
|
|
29916
|
+
var EntityLinkAssertion = /*#__PURE__*/ function(NodeAssertion) {
|
|
29917
|
+
_inherits(EntityLinkAssertion, NodeAssertion);
|
|
29918
|
+
function EntityLinkAssertion(linkType, contentNodeTypes) {
|
|
29919
|
+
_class_call_check(this, EntityLinkAssertion);
|
|
29920
|
+
var _this;
|
|
29921
|
+
_this = _call_super(this, EntityLinkAssertion, [
|
|
29922
|
+
contentNodeTypes,
|
|
29923
|
+
function(data, path) {
|
|
29924
|
+
return _assert_this_initialized(_this).assertLink(data, path);
|
|
29925
|
+
}
|
|
29926
|
+
]), _define_property$1(_this, "linkType", void 0), _define_property$1(_this, "type", void 0), _define_property$1(_this, "assertLink", void 0), _this.linkType = linkType, _this.assertLink = function(data, path) {
|
|
29927
|
+
var $ = new ObjectAssertion(data, path);
|
|
29928
|
+
if ($.object('target')) {
|
|
29929
|
+
var _$;
|
|
29930
|
+
var sys$ = new ObjectAssertion(data.target.sys, path.of('target').of('sys'));
|
|
29931
|
+
if (sys$.object()) {
|
|
29932
|
+
sys$.enum('type', [
|
|
29933
|
+
_this.type
|
|
29934
|
+
]);
|
|
29935
|
+
sys$.enum('linkType', [
|
|
29936
|
+
_this.linkType
|
|
29937
|
+
]);
|
|
29938
|
+
if (_this.type === 'Link') {
|
|
29939
|
+
sys$.string('id');
|
|
29940
|
+
sys$.noAdditionalProperties([
|
|
29941
|
+
'type',
|
|
29942
|
+
'linkType',
|
|
29943
|
+
'id'
|
|
29944
|
+
]);
|
|
29945
|
+
} else if (_this.type === 'ResourceLink') {
|
|
29946
|
+
sys$.string('urn');
|
|
29947
|
+
sys$.noAdditionalProperties([
|
|
29948
|
+
'type',
|
|
29949
|
+
'linkType',
|
|
29950
|
+
'urn'
|
|
29951
|
+
]);
|
|
29952
|
+
}
|
|
29953
|
+
}
|
|
29954
|
+
(_$ = $).catch.apply(_$, _to_consumable_array$1(sys$.errors));
|
|
29955
|
+
}
|
|
29956
|
+
$.noAdditionalProperties([
|
|
29957
|
+
'target'
|
|
29958
|
+
]);
|
|
29959
|
+
return $.errors;
|
|
29960
|
+
};
|
|
29961
|
+
_this.type = _this.linkType.startsWith('Contentful:') ? 'ResourceLink' : 'Link';
|
|
29962
|
+
return _this;
|
|
29963
|
+
}
|
|
29964
|
+
return EntityLinkAssertion;
|
|
29965
|
+
}(NodeAssertion);
|
|
29966
|
+
var HyperLinkAssertion = /*#__PURE__*/ function(NodeAssertion) {
|
|
29967
|
+
_inherits(HyperLinkAssertion, NodeAssertion);
|
|
29968
|
+
function HyperLinkAssertion() {
|
|
29969
|
+
_class_call_check(this, HyperLinkAssertion);
|
|
29970
|
+
var _this;
|
|
29971
|
+
_this = _call_super(this, HyperLinkAssertion, [
|
|
29972
|
+
[
|
|
29973
|
+
'text'
|
|
29974
|
+
],
|
|
29975
|
+
function(data, path) {
|
|
29976
|
+
return _assert_this_initialized(_this).assertLink(data, path);
|
|
29977
|
+
}
|
|
29978
|
+
]), _define_property$1(_this, "assertLink", function(data, path) {
|
|
29979
|
+
var $ = new ObjectAssertion(data, path);
|
|
29980
|
+
$.string('uri');
|
|
29981
|
+
$.noAdditionalProperties([
|
|
29982
|
+
'uri'
|
|
29983
|
+
]);
|
|
29984
|
+
return $.errors;
|
|
29985
|
+
});
|
|
29986
|
+
return _this;
|
|
29987
|
+
}
|
|
29988
|
+
return HyperLinkAssertion;
|
|
29989
|
+
}(NodeAssertion);
|
|
29990
|
+
var assert = function(contentRule, validateData) {
|
|
29991
|
+
return new NodeAssertion(contentRule, validateData);
|
|
29992
|
+
};
|
|
29993
|
+
var assertLink = function(linkType, contentRule) {
|
|
29994
|
+
return new EntityLinkAssertion(linkType, contentRule);
|
|
29995
|
+
};
|
|
29413
29996
|
|
|
29414
|
-
function
|
|
29415
|
-
|
|
29416
|
-
|
|
29417
|
-
|
|
29418
|
-
|
|
29419
|
-
|
|
29420
|
-
|
|
29421
|
-
|
|
29422
|
-
|
|
29423
|
-
|
|
29424
|
-
|
|
29425
|
-
|
|
29426
|
-
|
|
29427
|
-
|
|
29428
|
-
|
|
29429
|
-
}
|
|
29430
|
-
|
|
29431
|
-
|
|
29432
|
-
|
|
29433
|
-
|
|
29434
|
-
|
|
29435
|
-
|
|
29436
|
-
|
|
29437
|
-
|
|
29438
|
-
|
|
29439
|
-
|
|
29440
|
-
|
|
29441
|
-
|
|
29442
|
-
|
|
29443
|
-
|
|
29444
|
-
|
|
29445
|
-
|
|
29446
|
-
|
|
29447
|
-
|
|
29448
|
-
|
|
29449
|
-
|
|
29450
|
-
|
|
29451
|
-
|
|
29452
|
-
|
|
29453
|
-
|
|
29454
|
-
|
|
29455
|
-
|
|
29456
|
-
|
|
29457
|
-
|
|
29458
|
-
|
|
29459
|
-
|
|
29460
|
-
|
|
29461
|
-
|
|
29462
|
-
|
|
29463
|
-
|
|
29464
|
-
|
|
29465
|
-
|
|
29466
|
-
|
|
29467
|
-
|
|
29468
|
-
|
|
29469
|
-
|
|
29470
|
-
|
|
29471
|
-
|
|
29472
|
-
|
|
29473
|
-
|
|
29474
|
-
|
|
29475
|
-
|
|
29476
|
-
|
|
29477
|
-
|
|
29478
|
-
|
|
29479
|
-
|
|
29480
|
-
|
|
29481
|
-
|
|
29482
|
-
|
|
29483
|
-
}
|
|
29484
|
-
|
|
29485
|
-
|
|
29997
|
+
function _array_like_to_array(arr, len) {
|
|
29998
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
29999
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
30000
|
+
return arr2;
|
|
30001
|
+
}
|
|
30002
|
+
function _array_without_holes(arr) {
|
|
30003
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
30004
|
+
}
|
|
30005
|
+
function _define_property(obj, key, value) {
|
|
30006
|
+
if (key in obj) {
|
|
30007
|
+
Object.defineProperty(obj, key, {
|
|
30008
|
+
value: value,
|
|
30009
|
+
enumerable: true,
|
|
30010
|
+
configurable: true,
|
|
30011
|
+
writable: true
|
|
30012
|
+
});
|
|
30013
|
+
} else {
|
|
30014
|
+
obj[key] = value;
|
|
30015
|
+
}
|
|
30016
|
+
return obj;
|
|
30017
|
+
}
|
|
30018
|
+
function _iterable_to_array(iter) {
|
|
30019
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
30020
|
+
}
|
|
30021
|
+
function _non_iterable_spread() {
|
|
30022
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
30023
|
+
}
|
|
30024
|
+
function _to_consumable_array(arr) {
|
|
30025
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
30026
|
+
}
|
|
30027
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
30028
|
+
if (!o) return;
|
|
30029
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
30030
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
30031
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
30032
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
30033
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
30034
|
+
}
|
|
30035
|
+
var assertInlineOrText = assert(_to_consumable_array(Object.values(INLINES)).concat([
|
|
30036
|
+
'text'
|
|
30037
|
+
]).sort());
|
|
30038
|
+
var assertList = assert([
|
|
30039
|
+
BLOCKS.LIST_ITEM
|
|
30040
|
+
]);
|
|
30041
|
+
var assertVoidEntryLink = assertLink('Entry', VOID_CONTENT);
|
|
30042
|
+
var assertTableCell = assert(function() {
|
|
30043
|
+
return {
|
|
30044
|
+
nodeTypes: [
|
|
30045
|
+
BLOCKS.PARAGRAPH
|
|
30046
|
+
],
|
|
30047
|
+
min: 1
|
|
30048
|
+
};
|
|
30049
|
+
}, function(data, path) {
|
|
30050
|
+
var $ = new ObjectAssertion(data, path);
|
|
30051
|
+
$.noAdditionalProperties([
|
|
30052
|
+
'colspan',
|
|
30053
|
+
'rowspan'
|
|
30054
|
+
]);
|
|
30055
|
+
$.number('colspan', true);
|
|
30056
|
+
$.number('rowspan', true);
|
|
30057
|
+
return $.errors;
|
|
30058
|
+
});
|
|
30059
|
+
var _obj;
|
|
30060
|
+
(_obj = {}, _define_property(_obj, BLOCKS.DOCUMENT, assert(TOP_LEVEL_BLOCKS)), _define_property(_obj, BLOCKS.PARAGRAPH, assertInlineOrText), _define_property(_obj, BLOCKS.HEADING_1, assertInlineOrText), _define_property(_obj, BLOCKS.HEADING_2, assertInlineOrText), _define_property(_obj, BLOCKS.HEADING_3, assertInlineOrText), _define_property(_obj, BLOCKS.HEADING_4, assertInlineOrText), _define_property(_obj, BLOCKS.HEADING_5, assertInlineOrText), _define_property(_obj, BLOCKS.HEADING_6, assertInlineOrText), _define_property(_obj, BLOCKS.QUOTE, assert(CONTAINERS[BLOCKS.QUOTE])), _define_property(_obj, BLOCKS.EMBEDDED_ENTRY, assertVoidEntryLink), _define_property(_obj, BLOCKS.EMBEDDED_ASSET, assertLink('Asset', VOID_CONTENT)), _define_property(_obj, BLOCKS.EMBEDDED_RESOURCE, assertLink('Contentful:Entry', VOID_CONTENT)), _define_property(_obj, BLOCKS.HR, assert(VOID_CONTENT)), _define_property(_obj, BLOCKS.OL_LIST, assertList), _define_property(_obj, BLOCKS.UL_LIST, assertList), _define_property(_obj, BLOCKS.LIST_ITEM, assert(_to_consumable_array(LIST_ITEM_BLOCKS).sort())), _define_property(_obj, BLOCKS.TABLE, assert(function() {
|
|
30061
|
+
return {
|
|
30062
|
+
nodeTypes: [
|
|
30063
|
+
BLOCKS.TABLE_ROW
|
|
30064
|
+
],
|
|
30065
|
+
min: 1
|
|
30066
|
+
};
|
|
30067
|
+
})), _define_property(_obj, BLOCKS.TABLE_ROW, assert(function() {
|
|
30068
|
+
return {
|
|
30069
|
+
nodeTypes: [
|
|
30070
|
+
BLOCKS.TABLE_CELL,
|
|
30071
|
+
BLOCKS.TABLE_HEADER_CELL
|
|
30072
|
+
],
|
|
30073
|
+
min: 1
|
|
30074
|
+
};
|
|
30075
|
+
})), _define_property(_obj, BLOCKS.TABLE_CELL, assertTableCell), _define_property(_obj, BLOCKS.TABLE_HEADER_CELL, assertTableCell), _define_property(_obj, INLINES.HYPERLINK, new HyperLinkAssertion()), _define_property(_obj, INLINES.EMBEDDED_ENTRY, assertVoidEntryLink), _define_property(_obj, INLINES.EMBEDDED_RESOURCE, assertLink('Contentful:Entry', VOID_CONTENT)), _define_property(_obj, INLINES.ENTRY_HYPERLINK, assertLink('Entry', [
|
|
30076
|
+
'text'
|
|
30077
|
+
])), _define_property(_obj, INLINES.ASSET_HYPERLINK, assertLink('Asset', [
|
|
30078
|
+
'text'
|
|
30079
|
+
])), _define_property(_obj, INLINES.RESOURCE_HYPERLINK, assertLink('Contentful:Entry', [
|
|
30080
|
+
'text'
|
|
30081
|
+
])), _obj);
|
|
29486
30082
|
|
|
29487
30083
|
/**
|
|
29488
30084
|
* Converts a Contentful Rich Text Document to Tiptap JSON format
|
|
@@ -29491,97 +30087,97 @@ var contentfulToTiptap = function (document) {
|
|
|
29491
30087
|
var convertNode = function (node) {
|
|
29492
30088
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
29493
30089
|
switch (node.nodeType) {
|
|
29494
|
-
case
|
|
30090
|
+
case BLOCKS.DOCUMENT:
|
|
29495
30091
|
return {
|
|
29496
30092
|
type: 'doc',
|
|
29497
30093
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29498
30094
|
};
|
|
29499
|
-
case
|
|
30095
|
+
case BLOCKS.PARAGRAPH:
|
|
29500
30096
|
return {
|
|
29501
30097
|
type: 'paragraph',
|
|
29502
30098
|
content: node.content ? node.content.map(function (child) { return convertNode(child); }).flat() : [],
|
|
29503
30099
|
};
|
|
29504
|
-
case
|
|
30100
|
+
case BLOCKS.HEADING_1:
|
|
29505
30101
|
return {
|
|
29506
30102
|
type: 'heading',
|
|
29507
30103
|
attrs: { level: 1 },
|
|
29508
30104
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29509
30105
|
};
|
|
29510
|
-
case
|
|
30106
|
+
case BLOCKS.HEADING_2:
|
|
29511
30107
|
return {
|
|
29512
30108
|
type: 'heading',
|
|
29513
30109
|
attrs: { level: 2 },
|
|
29514
30110
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29515
30111
|
};
|
|
29516
|
-
case
|
|
30112
|
+
case BLOCKS.HEADING_3:
|
|
29517
30113
|
return {
|
|
29518
30114
|
type: 'heading',
|
|
29519
30115
|
attrs: { level: 3 },
|
|
29520
30116
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29521
30117
|
};
|
|
29522
|
-
case
|
|
30118
|
+
case BLOCKS.HEADING_4:
|
|
29523
30119
|
return {
|
|
29524
30120
|
type: 'heading',
|
|
29525
30121
|
attrs: { level: 4 },
|
|
29526
30122
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29527
30123
|
};
|
|
29528
|
-
case
|
|
30124
|
+
case BLOCKS.HEADING_5:
|
|
29529
30125
|
return {
|
|
29530
30126
|
type: 'heading',
|
|
29531
30127
|
attrs: { level: 5 },
|
|
29532
30128
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29533
30129
|
};
|
|
29534
|
-
case
|
|
30130
|
+
case BLOCKS.HEADING_6:
|
|
29535
30131
|
return {
|
|
29536
30132
|
type: 'heading',
|
|
29537
30133
|
attrs: { level: 6 },
|
|
29538
30134
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29539
30135
|
};
|
|
29540
|
-
case
|
|
30136
|
+
case BLOCKS.UL_LIST:
|
|
29541
30137
|
return {
|
|
29542
30138
|
type: 'bulletList',
|
|
29543
30139
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29544
30140
|
};
|
|
29545
|
-
case
|
|
30141
|
+
case BLOCKS.OL_LIST:
|
|
29546
30142
|
return {
|
|
29547
30143
|
type: 'orderedList',
|
|
29548
30144
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29549
30145
|
};
|
|
29550
|
-
case
|
|
30146
|
+
case BLOCKS.LIST_ITEM:
|
|
29551
30147
|
return {
|
|
29552
30148
|
type: 'listItem',
|
|
29553
30149
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29554
30150
|
};
|
|
29555
|
-
case
|
|
30151
|
+
case BLOCKS.QUOTE:
|
|
29556
30152
|
return {
|
|
29557
30153
|
type: 'blockquote',
|
|
29558
30154
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29559
30155
|
};
|
|
29560
|
-
case
|
|
30156
|
+
case BLOCKS.HR:
|
|
29561
30157
|
return {
|
|
29562
30158
|
type: 'horizontalRule',
|
|
29563
30159
|
};
|
|
29564
|
-
case
|
|
30160
|
+
case BLOCKS.TABLE:
|
|
29565
30161
|
return {
|
|
29566
30162
|
type: 'table',
|
|
29567
30163
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29568
30164
|
};
|
|
29569
|
-
case
|
|
30165
|
+
case BLOCKS.TABLE_ROW:
|
|
29570
30166
|
return {
|
|
29571
30167
|
type: 'tableRow',
|
|
29572
30168
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29573
30169
|
};
|
|
29574
|
-
case
|
|
30170
|
+
case BLOCKS.TABLE_CELL:
|
|
29575
30171
|
return {
|
|
29576
30172
|
type: 'tableCell',
|
|
29577
30173
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29578
30174
|
};
|
|
29579
|
-
case
|
|
30175
|
+
case BLOCKS.TABLE_HEADER_CELL:
|
|
29580
30176
|
return {
|
|
29581
30177
|
type: 'tableHeader',
|
|
29582
30178
|
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
29583
30179
|
};
|
|
29584
|
-
case
|
|
30180
|
+
case INLINES.HYPERLINK:
|
|
29585
30181
|
return {
|
|
29586
30182
|
type: 'text',
|
|
29587
30183
|
text: node.content.map(function (child) {
|
|
@@ -29594,14 +30190,14 @@ var contentfulToTiptap = function (document) {
|
|
|
29594
30190
|
},
|
|
29595
30191
|
],
|
|
29596
30192
|
};
|
|
29597
|
-
case
|
|
30193
|
+
case INLINES.EMBEDDED_ENTRY:
|
|
29598
30194
|
// Inline embedded entry
|
|
29599
30195
|
return {
|
|
29600
30196
|
type: 'text',
|
|
29601
30197
|
text: "[Inline Entry: ".concat(((_b = (_a = node.data.target) === null || _a === void 0 ? void 0 : _a.sys) === null || _b === void 0 ? void 0 : _b.id) || 'Unknown', "]"),
|
|
29602
30198
|
marks: [{ type: 'bold' }],
|
|
29603
30199
|
};
|
|
29604
|
-
case
|
|
30200
|
+
case BLOCKS.EMBEDDED_ENTRY:
|
|
29605
30201
|
return {
|
|
29606
30202
|
type: 'paragraph',
|
|
29607
30203
|
content: [
|
|
@@ -29612,7 +30208,7 @@ var contentfulToTiptap = function (document) {
|
|
|
29612
30208
|
},
|
|
29613
30209
|
],
|
|
29614
30210
|
};
|
|
29615
|
-
case
|
|
30211
|
+
case BLOCKS.EMBEDDED_ASSET:
|
|
29616
30212
|
return {
|
|
29617
30213
|
type: 'paragraph',
|
|
29618
30214
|
content: [
|
|
@@ -29627,13 +30223,13 @@ var contentfulToTiptap = function (document) {
|
|
|
29627
30223
|
var textNode = node;
|
|
29628
30224
|
var marks = ((_g = textNode.marks) === null || _g === void 0 ? void 0 : _g.map(function (mark) {
|
|
29629
30225
|
switch (mark.type) {
|
|
29630
|
-
case
|
|
30226
|
+
case MARKS.BOLD:
|
|
29631
30227
|
return { type: 'bold' };
|
|
29632
|
-
case
|
|
30228
|
+
case MARKS.ITALIC:
|
|
29633
30229
|
return { type: 'italic' };
|
|
29634
|
-
case
|
|
30230
|
+
case MARKS.UNDERLINE:
|
|
29635
30231
|
return { type: 'underline' };
|
|
29636
|
-
case
|
|
30232
|
+
case MARKS.CODE:
|
|
29637
30233
|
return { type: 'code' };
|
|
29638
30234
|
default:
|
|
29639
30235
|
return null;
|
|
@@ -29663,27 +30259,27 @@ var tiptapToContentful = function (tiptapDoc) {
|
|
|
29663
30259
|
switch (node.type) {
|
|
29664
30260
|
case 'doc':
|
|
29665
30261
|
return {
|
|
29666
|
-
nodeType:
|
|
30262
|
+
nodeType: BLOCKS.DOCUMENT,
|
|
29667
30263
|
data: {},
|
|
29668
30264
|
content: (_a = node.content) === null || _a === void 0 ? void 0 : _a.map(function (child) { return convertNode(child); }),
|
|
29669
30265
|
};
|
|
29670
30266
|
case 'paragraph':
|
|
29671
30267
|
return {
|
|
29672
|
-
nodeType:
|
|
30268
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
29673
30269
|
data: {},
|
|
29674
30270
|
content: (_b = node.content) === null || _b === void 0 ? void 0 : _b.map(function (child) { return convertNode(child); }),
|
|
29675
30271
|
};
|
|
29676
30272
|
case 'heading':
|
|
29677
30273
|
var level = ((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.level) || 1;
|
|
29678
30274
|
var headingTypes = {
|
|
29679
|
-
1:
|
|
29680
|
-
2:
|
|
29681
|
-
3:
|
|
29682
|
-
4:
|
|
29683
|
-
5:
|
|
29684
|
-
6:
|
|
30275
|
+
1: BLOCKS.HEADING_1,
|
|
30276
|
+
2: BLOCKS.HEADING_2,
|
|
30277
|
+
3: BLOCKS.HEADING_3,
|
|
30278
|
+
4: BLOCKS.HEADING_4,
|
|
30279
|
+
5: BLOCKS.HEADING_5,
|
|
30280
|
+
6: BLOCKS.HEADING_6,
|
|
29685
30281
|
};
|
|
29686
|
-
var headingType = headingTypes[level] ||
|
|
30282
|
+
var headingType = headingTypes[level] || BLOCKS.HEADING_1;
|
|
29687
30283
|
return {
|
|
29688
30284
|
nodeType: headingType,
|
|
29689
30285
|
data: {},
|
|
@@ -29691,55 +30287,55 @@ var tiptapToContentful = function (tiptapDoc) {
|
|
|
29691
30287
|
};
|
|
29692
30288
|
case 'bulletList':
|
|
29693
30289
|
return {
|
|
29694
|
-
nodeType:
|
|
30290
|
+
nodeType: BLOCKS.UL_LIST,
|
|
29695
30291
|
data: {},
|
|
29696
30292
|
content: (_e = node.content) === null || _e === void 0 ? void 0 : _e.map(function (child) { return convertNode(child); }),
|
|
29697
30293
|
};
|
|
29698
30294
|
case 'orderedList':
|
|
29699
30295
|
return {
|
|
29700
|
-
nodeType:
|
|
30296
|
+
nodeType: BLOCKS.OL_LIST,
|
|
29701
30297
|
data: {},
|
|
29702
30298
|
content: (_f = node.content) === null || _f === void 0 ? void 0 : _f.map(function (child) { return convertNode(child); }),
|
|
29703
30299
|
};
|
|
29704
30300
|
case 'listItem':
|
|
29705
30301
|
return {
|
|
29706
|
-
nodeType:
|
|
30302
|
+
nodeType: BLOCKS.LIST_ITEM,
|
|
29707
30303
|
data: {},
|
|
29708
30304
|
content: (_g = node.content) === null || _g === void 0 ? void 0 : _g.map(function (child) { return convertNode(child); }),
|
|
29709
30305
|
};
|
|
29710
30306
|
case 'blockquote':
|
|
29711
30307
|
return {
|
|
29712
|
-
nodeType:
|
|
30308
|
+
nodeType: BLOCKS.QUOTE,
|
|
29713
30309
|
data: {},
|
|
29714
30310
|
content: (_h = node.content) === null || _h === void 0 ? void 0 : _h.map(function (child) { return convertNode(child); }),
|
|
29715
30311
|
};
|
|
29716
30312
|
case 'horizontalRule':
|
|
29717
30313
|
return {
|
|
29718
|
-
nodeType:
|
|
30314
|
+
nodeType: BLOCKS.HR,
|
|
29719
30315
|
data: {},
|
|
29720
30316
|
content: [],
|
|
29721
30317
|
};
|
|
29722
30318
|
case 'table':
|
|
29723
30319
|
return {
|
|
29724
|
-
nodeType:
|
|
30320
|
+
nodeType: BLOCKS.TABLE,
|
|
29725
30321
|
data: {},
|
|
29726
30322
|
content: (_j = node.content) === null || _j === void 0 ? void 0 : _j.map(function (child) { return convertNode(child); }),
|
|
29727
30323
|
};
|
|
29728
30324
|
case 'tableRow':
|
|
29729
30325
|
return {
|
|
29730
|
-
nodeType:
|
|
30326
|
+
nodeType: BLOCKS.TABLE_ROW,
|
|
29731
30327
|
data: {},
|
|
29732
30328
|
content: (_k = node.content) === null || _k === void 0 ? void 0 : _k.map(function (child) { return convertNode(child); }),
|
|
29733
30329
|
};
|
|
29734
30330
|
case 'tableCell':
|
|
29735
30331
|
return {
|
|
29736
|
-
nodeType:
|
|
30332
|
+
nodeType: BLOCKS.TABLE_CELL,
|
|
29737
30333
|
data: {},
|
|
29738
30334
|
content: (_l = node.content) === null || _l === void 0 ? void 0 : _l.map(function (child) { return convertNode(child); }),
|
|
29739
30335
|
};
|
|
29740
30336
|
case 'tableHeader':
|
|
29741
30337
|
return {
|
|
29742
|
-
nodeType:
|
|
30338
|
+
nodeType: BLOCKS.TABLE_HEADER_CELL,
|
|
29743
30339
|
data: {},
|
|
29744
30340
|
content: (_m = node.content) === null || _m === void 0 ? void 0 : _m.map(function (child) { return convertNode(child); }),
|
|
29745
30341
|
};
|
|
@@ -29747,13 +30343,13 @@ var tiptapToContentful = function (tiptapDoc) {
|
|
|
29747
30343
|
var marks = ((_o = node.marks) === null || _o === void 0 ? void 0 : _o.map(function (mark) {
|
|
29748
30344
|
switch (mark.type) {
|
|
29749
30345
|
case 'bold':
|
|
29750
|
-
return { type:
|
|
30346
|
+
return { type: MARKS.BOLD };
|
|
29751
30347
|
case 'italic':
|
|
29752
|
-
return { type:
|
|
30348
|
+
return { type: MARKS.ITALIC };
|
|
29753
30349
|
case 'underline':
|
|
29754
|
-
return { type:
|
|
30350
|
+
return { type: MARKS.UNDERLINE };
|
|
29755
30351
|
case 'code':
|
|
29756
|
-
return { type:
|
|
30352
|
+
return { type: MARKS.CODE };
|
|
29757
30353
|
case 'link':
|
|
29758
30354
|
return null; // Links are handled separately
|
|
29759
30355
|
default:
|
|
@@ -29764,7 +30360,7 @@ var tiptapToContentful = function (tiptapDoc) {
|
|
|
29764
30360
|
var linkMark = (_p = node.marks) === null || _p === void 0 ? void 0 : _p.find(function (mark) { return mark.type === 'link'; });
|
|
29765
30361
|
if (linkMark) {
|
|
29766
30362
|
return {
|
|
29767
|
-
nodeType:
|
|
30363
|
+
nodeType: INLINES.HYPERLINK,
|
|
29768
30364
|
data: {
|
|
29769
30365
|
uri: ((_q = linkMark.attrs) === null || _q === void 0 ? void 0 : _q.href) || '',
|
|
29770
30366
|
},
|
|
@@ -29785,7 +30381,7 @@ var tiptapToContentful = function (tiptapDoc) {
|
|
|
29785
30381
|
var match = node.text.match(/\[Inline Entry:\s*([^\]]+)\]/);
|
|
29786
30382
|
var entryId = match ? match[1].trim() : 'Unknown';
|
|
29787
30383
|
return {
|
|
29788
|
-
nodeType:
|
|
30384
|
+
nodeType: INLINES.EMBEDDED_ENTRY,
|
|
29789
30385
|
data: {
|
|
29790
30386
|
target: {
|
|
29791
30387
|
sys: {
|
|
@@ -29807,7 +30403,7 @@ var tiptapToContentful = function (tiptapDoc) {
|
|
|
29807
30403
|
default:
|
|
29808
30404
|
console.warn("Unknown Tiptap node type: ".concat(node.type));
|
|
29809
30405
|
return {
|
|
29810
|
-
nodeType:
|
|
30406
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
29811
30407
|
data: {},
|
|
29812
30408
|
content: [],
|
|
29813
30409
|
};
|
|
@@ -29822,7 +30418,7 @@ var validateContentfulDocument = function (document) {
|
|
|
29822
30418
|
if (!document || typeof document !== 'object') {
|
|
29823
30419
|
return false;
|
|
29824
30420
|
}
|
|
29825
|
-
if (document.nodeType !==
|
|
30421
|
+
if (document.nodeType !== BLOCKS.DOCUMENT) {
|
|
29826
30422
|
return false;
|
|
29827
30423
|
}
|
|
29828
30424
|
if (!Array.isArray(document.content)) {
|
|
@@ -29834,11 +30430,11 @@ var validateContentfulDocument = function (document) {
|
|
|
29834
30430
|
* Creates an empty Contentful document
|
|
29835
30431
|
*/
|
|
29836
30432
|
var createEmptyDocument = function () { return ({
|
|
29837
|
-
nodeType:
|
|
30433
|
+
nodeType: BLOCKS.DOCUMENT,
|
|
29838
30434
|
data: {},
|
|
29839
30435
|
content: [
|
|
29840
30436
|
{
|
|
29841
|
-
nodeType:
|
|
30437
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
29842
30438
|
data: {},
|
|
29843
30439
|
content: [],
|
|
29844
30440
|
},
|
|
@@ -29854,11 +30450,11 @@ var sanitizeContentfulDocument = function (document, allowedNodeTypes, allowedMa
|
|
|
29854
30450
|
if (!allowedNodeTypes.includes(node.nodeType)) {
|
|
29855
30451
|
// Convert to paragraph if it's a block that's not allowed
|
|
29856
30452
|
if (node.nodeType.startsWith('heading-') ||
|
|
29857
|
-
node.nodeType ===
|
|
29858
|
-
node.nodeType ===
|
|
29859
|
-
node.nodeType ===
|
|
30453
|
+
node.nodeType === BLOCKS.QUOTE ||
|
|
30454
|
+
node.nodeType === BLOCKS.UL_LIST ||
|
|
30455
|
+
node.nodeType === BLOCKS.OL_LIST) {
|
|
29860
30456
|
return {
|
|
29861
|
-
nodeType:
|
|
30457
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
29862
30458
|
data: {},
|
|
29863
30459
|
content: (_a = node.content) === null || _a === void 0 ? void 0 : _a.map(function (child) { return sanitizeNode(child); }).filter(Boolean),
|
|
29864
30460
|
};
|
|
@@ -29911,17 +30507,17 @@ var findEmbeddedContent = function (document) {
|
|
|
29911
30507
|
var inlineEntries = [];
|
|
29912
30508
|
var searchNode = function (node) {
|
|
29913
30509
|
var _a, _b, _c, _d, _e, _f;
|
|
29914
|
-
if (node.nodeType ===
|
|
30510
|
+
if (node.nodeType === BLOCKS.EMBEDDED_ENTRY) {
|
|
29915
30511
|
var entryId = (_b = (_a = node.data.target) === null || _a === void 0 ? void 0 : _a.sys) === null || _b === void 0 ? void 0 : _b.id;
|
|
29916
30512
|
if (entryId)
|
|
29917
30513
|
entries.push(entryId);
|
|
29918
30514
|
}
|
|
29919
|
-
else if (node.nodeType ===
|
|
30515
|
+
else if (node.nodeType === BLOCKS.EMBEDDED_ASSET) {
|
|
29920
30516
|
var assetId = (_d = (_c = node.data.target) === null || _c === void 0 ? void 0 : _c.sys) === null || _d === void 0 ? void 0 : _d.id;
|
|
29921
30517
|
if (assetId)
|
|
29922
30518
|
assets.push(assetId);
|
|
29923
30519
|
}
|
|
29924
|
-
else if (node.nodeType ===
|
|
30520
|
+
else if (node.nodeType === INLINES.EMBEDDED_ENTRY) {
|
|
29925
30521
|
var entryId = (_f = (_e = node.data.target) === null || _e === void 0 ? void 0 : _e.sys) === null || _f === void 0 ? void 0 : _f.id;
|
|
29926
30522
|
if (entryId)
|
|
29927
30523
|
inlineEntries.push(entryId);
|
|
@@ -30314,8 +30910,5 @@ var ContentfulRichTextEditor = function (_a) {
|
|
|
30314
30910
|
return (jsxs("div", { className: editorClass, children: [!readonly && (jsx(ContentfulToolbar, { editor: editor, onEmbedEntry: onEmbedEntry && editorConfig.allowEmbeddedEntries ? handleEmbedEntry : undefined, onEmbedAsset: onEmbedAsset && editorConfig.allowEmbeddedAssets ? handleEmbedAsset : undefined, onEmbedInlineEntry: onEmbedInlineEntry && editorConfig.allowInlineEntries ? handleEmbedInlineEntry : undefined, disabledFeatures: editorConfig.disabledFeatures, availableHeadings: editorConfig.availableHeadings, availableMarks: editorConfig.availableMarks, allowHyperlinks: editorConfig.allowHyperlinks })), jsx("div", { className: "contentful-editor__content-wrapper", children: jsx(EditorContent, { editor: editor, className: "contentful-editor__content", "data-testid": "editor-content" }) })] }));
|
|
30315
30911
|
};
|
|
30316
30912
|
|
|
30317
|
-
var BLOCKS = distExports.BLOCKS;
|
|
30318
|
-
var INLINES = distExports.INLINES;
|
|
30319
|
-
var MARKS = distExports.MARKS;
|
|
30320
30913
|
export { BLOCKS, ContentfulRichTextEditor, ContentfulToolbar, INLINES, MARKS, contentfulToTiptap, countWords, createEmptyDocument, createMockFieldConfig, extractPlainText, fetchContentfulFieldConfig, findEmbeddedContent, parseContentfulFieldConfig, sanitizeContentfulDocument, tiptapToContentful, validateContentfulDocument };
|
|
30321
30914
|
//# sourceMappingURL=index.esm.js.map
|