@crashbytes/contentful-richtext-editor 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -472
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +353 -241
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +353 -241
- package/dist/index.js.map +1 -1
- package/package.json +32 -9
- package/dist/components/ContentfulDocument.d.ts +0 -2
- package/dist/components/ContentfulEditor.d.ts +0 -34
- package/dist/components/ContentfulEditor.stories.d.ts +0 -18
- package/dist/components/ContentfulEmbedded.d.ts +0 -15
- package/dist/components/Toolbar.d.ts +0 -14
- package/dist/components/Toolbar.stories.d.ts +0 -10
- package/dist/index.d.ts +0 -8
- package/dist/testData/samples.d.ts +0 -11
- package/dist/utils/configParser.d.ts +0 -37
- package/dist/utils/contentfulTransform.d.ts +0 -48
- package/dist/utils/contentfulTransform.stories.d.ts +0 -6
- package/dist/utils/types.d.ts +0 -141
package/dist/index.js
CHANGED
|
@@ -4,6 +4,77 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var ReactDOM = require('react-dom');
|
|
6
6
|
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var __assign = function() {
|
|
25
|
+
__assign = Object.assign || function __assign(t) {
|
|
26
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
+
s = arguments[i];
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
return __assign.apply(this, arguments);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function __generator(thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
47
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
74
|
+
var e = new Error(message);
|
|
75
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
76
|
+
};
|
|
77
|
+
|
|
7
78
|
// ::- Persistent data structure representing an ordered mapping from
|
|
8
79
|
// strings to values, with some convenient update methods.
|
|
9
80
|
function OrderedMap(content) {
|
|
@@ -26531,12 +26602,13 @@ const Underline = Mark.create({
|
|
|
26531
26602
|
},
|
|
26532
26603
|
});
|
|
26533
26604
|
|
|
26534
|
-
|
|
26535
|
-
|
|
26536
|
-
|
|
26537
|
-
|
|
26538
|
-
|
|
26539
|
-
|
|
26605
|
+
var ContentfulToolbar = function (_a) {
|
|
26606
|
+
var editor = _a.editor, onEmbedEntry = _a.onEmbedEntry, onEmbedAsset = _a.onEmbedAsset, onEmbedInlineEntry = _a.onEmbedInlineEntry, _b = _a.disabledFeatures, disabledFeatures = _b === void 0 ? [] : _b, _c = _a.availableHeadings, availableHeadings = _c === void 0 ? [1, 2, 3, 4, 5, 6] : _c, _d = _a.availableMarks, availableMarks = _d === void 0 ? ['bold', 'italic', 'underline'] : _d, _e = _a.allowHyperlinks, allowHyperlinks = _e === void 0 ? true : _e;
|
|
26607
|
+
var _f = React.useState(false), showLinkInput = _f[0], setShowLinkInput = _f[1];
|
|
26608
|
+
var _g = React.useState(''), linkUrl = _g[0], setLinkUrl = _g[1];
|
|
26609
|
+
var isDisabled = function (feature) { return disabledFeatures.includes(feature); };
|
|
26610
|
+
var isMarkAvailable = function (mark) { return availableMarks.includes(mark); };
|
|
26611
|
+
var handleHeadingChange = function (level) {
|
|
26540
26612
|
if (level === 0) {
|
|
26541
26613
|
editor.chain().focus().setParagraph().run();
|
|
26542
26614
|
}
|
|
@@ -26544,7 +26616,7 @@ const ContentfulToolbar = ({ editor, onEmbedEntry, onEmbedAsset, onEmbedInlineEn
|
|
|
26544
26616
|
editor.chain().focus().toggleHeading({ level: level }).run();
|
|
26545
26617
|
}
|
|
26546
26618
|
};
|
|
26547
|
-
|
|
26619
|
+
var handleLinkToggle = function () {
|
|
26548
26620
|
if (editor.isActive('link')) {
|
|
26549
26621
|
editor.chain().focus().unsetLink().run();
|
|
26550
26622
|
}
|
|
@@ -26553,41 +26625,42 @@ const ContentfulToolbar = ({ editor, onEmbedEntry, onEmbedAsset, onEmbedInlineEn
|
|
|
26553
26625
|
setLinkUrl(editor.getAttributes('link').href || '');
|
|
26554
26626
|
}
|
|
26555
26627
|
};
|
|
26556
|
-
|
|
26628
|
+
var handleLinkSubmit = function () {
|
|
26557
26629
|
if (linkUrl) {
|
|
26558
26630
|
editor.chain().focus().setLink({ href: linkUrl }).run();
|
|
26559
26631
|
}
|
|
26560
26632
|
setShowLinkInput(false);
|
|
26561
26633
|
setLinkUrl('');
|
|
26562
26634
|
};
|
|
26563
|
-
|
|
26635
|
+
var handleLinkCancel = function () {
|
|
26564
26636
|
setShowLinkInput(false);
|
|
26565
26637
|
setLinkUrl('');
|
|
26566
26638
|
};
|
|
26567
|
-
|
|
26639
|
+
var insertTable = function () {
|
|
26568
26640
|
editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run();
|
|
26569
26641
|
};
|
|
26570
|
-
|
|
26571
|
-
for (
|
|
26572
|
-
|
|
26573
|
-
|
|
26642
|
+
var getActiveHeading = function () {
|
|
26643
|
+
for (var _i = 0, availableHeadings_1 = availableHeadings; _i < availableHeadings_1.length; _i++) {
|
|
26644
|
+
var level = availableHeadings_1[_i];
|
|
26645
|
+
if (editor.isActive('heading', { level: level })) {
|
|
26646
|
+
return "Heading ".concat(level);
|
|
26574
26647
|
}
|
|
26575
26648
|
}
|
|
26576
26649
|
return 'Normal text';
|
|
26577
26650
|
};
|
|
26578
|
-
|
|
26579
|
-
|
|
26580
|
-
|
|
26581
|
-
return (jsxRuntime.jsxs("div", { className: "contentful-toolbar", children: [jsxRuntime.jsxs("div", { className: "contentful-toolbar__group", children: [hasHeadings && (jsxRuntime.jsxs("select", { className: "contentful-toolbar__select", value: getActiveHeading(), onChange: (e)
|
|
26582
|
-
|
|
26651
|
+
var hasHeadings = !isDisabled('headings') && availableHeadings.length > 0;
|
|
26652
|
+
var hasAnyEmbedOptions = onEmbedEntry || onEmbedAsset || onEmbedInlineEntry;
|
|
26653
|
+
var hasAnyTextFormatting = availableMarks.some(function (mark) { return !isDisabled(mark) && isMarkAvailable(mark); });
|
|
26654
|
+
return (jsxRuntime.jsxs("div", { className: "contentful-toolbar", children: [jsxRuntime.jsxs("div", { className: "contentful-toolbar__group", children: [hasHeadings && (jsxRuntime.jsxs("select", { className: "contentful-toolbar__select", value: getActiveHeading(), onChange: function (e) {
|
|
26655
|
+
var value = e.target.value;
|
|
26583
26656
|
if (value === 'Normal text') {
|
|
26584
26657
|
handleHeadingChange(0);
|
|
26585
26658
|
}
|
|
26586
26659
|
else {
|
|
26587
|
-
|
|
26660
|
+
var level = parseInt(value.replace('Heading ', ''));
|
|
26588
26661
|
handleHeadingChange(level);
|
|
26589
26662
|
}
|
|
26590
|
-
}, children: [jsxRuntime.jsx("option", { value: "Normal text", children: "Normal text" }), availableHeadings.map(level
|
|
26663
|
+
}, children: [jsxRuntime.jsx("option", { value: "Normal text", children: "Normal text" }), availableHeadings.map(function (level) { return (jsxRuntime.jsxs("option", { value: "Heading ".concat(level), children: ["Heading ", level] }, level)); })] })), jsxRuntime.jsx("button", { className: "contentful-toolbar__button", onClick: function () { return editor.chain().focus().undo().run(); }, disabled: !editor.can().undo(), title: "Undo", children: "\u21B6" }), jsxRuntime.jsx("button", { className: "contentful-toolbar__button", onClick: function () { return editor.chain().focus().redo().run(); }, disabled: !editor.can().redo(), title: "Redo", children: "\u21B7" })] }), (hasAnyTextFormatting || allowHyperlinks) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "contentful-toolbar__separator" }), jsxRuntime.jsxs("div", { className: "contentful-toolbar__group", children: [!isDisabled('bold') && isMarkAvailable('bold') && (jsxRuntime.jsx("button", { className: "contentful-toolbar__button ".concat(editor.isActive('bold') ? 'contentful-toolbar__button--active' : ''), onClick: function () { return editor.chain().focus().toggleBold().run(); }, title: "Bold", children: jsxRuntime.jsx("strong", { children: "B" }) })), !isDisabled('italic') && isMarkAvailable('italic') && (jsxRuntime.jsx("button", { className: "contentful-toolbar__button ".concat(editor.isActive('italic') ? 'contentful-toolbar__button--active' : ''), onClick: function () { return editor.chain().focus().toggleItalic().run(); }, title: "Italic", children: jsxRuntime.jsx("em", { children: "I" }) })), !isDisabled('underline') && isMarkAvailable('underline') && (jsxRuntime.jsx("button", { className: "contentful-toolbar__button ".concat(editor.isActive('underline') ? 'contentful-toolbar__button--active' : ''), onClick: function () { return editor.chain().focus().toggleUnderline().run(); }, title: "Underline", children: jsxRuntime.jsx("u", { children: "U" }) })), jsxRuntime.jsx("button", { className: "contentful-toolbar__button", title: "More formatting options", children: "\u22EF" }), !isDisabled('link') && allowHyperlinks && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: "contentful-toolbar__button ".concat(editor.isActive('link') ? 'contentful-toolbar__button--active' : ''), onClick: handleLinkToggle, title: "Link", children: "\uD83D\uDD17" }), showLinkInput && (jsxRuntime.jsxs("div", { className: "contentful-toolbar__link-input", children: [jsxRuntime.jsx("input", { type: "url", value: linkUrl, onChange: function (e) { return setLinkUrl(e.target.value); }, placeholder: "Enter URL", onKeyDown: function (e) {
|
|
26591
26664
|
if (e.key === 'Enter') {
|
|
26592
26665
|
e.preventDefault();
|
|
26593
26666
|
handleLinkSubmit();
|
|
@@ -26596,7 +26669,7 @@ const ContentfulToolbar = ({ editor, onEmbedEntry, onEmbedAsset, onEmbedInlineEn
|
|
|
26596
26669
|
e.preventDefault();
|
|
26597
26670
|
handleLinkCancel();
|
|
26598
26671
|
}
|
|
26599
|
-
}, autoFocus: true }), jsxRuntime.jsx("button", { onClick: handleLinkSubmit, title: "Apply link", children: "\u2713" }), jsxRuntime.jsx("button", { onClick: handleLinkCancel, title: "Cancel", children: "\u2717" })] }))] }))] })] })), (!isDisabled('lists') || !isDisabled('quote') || !isDisabled('table')) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "contentful-toolbar__separator" }), jsxRuntime.jsxs("div", { className: "contentful-toolbar__group", children: [!isDisabled('lists') && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className:
|
|
26672
|
+
}, autoFocus: true }), jsxRuntime.jsx("button", { onClick: handleLinkSubmit, title: "Apply link", children: "\u2713" }), jsxRuntime.jsx("button", { onClick: handleLinkCancel, title: "Cancel", children: "\u2717" })] }))] }))] })] })), (!isDisabled('lists') || !isDisabled('quote') || !isDisabled('table')) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "contentful-toolbar__separator" }), jsxRuntime.jsxs("div", { className: "contentful-toolbar__group", children: [!isDisabled('lists') && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.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" }), jsxRuntime.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') && (jsxRuntime.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: "\"" })), jsxRuntime.jsx("button", { className: "contentful-toolbar__button", onClick: function () { return editor.chain().focus().setHorizontalRule().run(); }, title: "Horizontal Rule", children: "\u2014" }), !isDisabled('table') && (jsxRuntime.jsx("button", { className: "contentful-toolbar__button", onClick: insertTable, title: "Insert Table", children: "\u229E" }))] })] })), hasAnyEmbedOptions && !isDisabled('embed') && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "contentful-toolbar__separator" }), jsxRuntime.jsx("div", { className: "contentful-toolbar__group contentful-toolbar__group--right", children: jsxRuntime.jsxs("div", { className: "contentful-toolbar__embed-dropdown", children: [jsxRuntime.jsx("button", { className: "contentful-toolbar__embed-button", children: "+ Embed \u25BC" }), jsxRuntime.jsxs("div", { className: "contentful-toolbar__embed-menu", children: [onEmbedEntry && (jsxRuntime.jsx("button", { className: "contentful-toolbar__embed-option", onClick: onEmbedEntry, children: "\uD83D\uDCC4 Entry" })), onEmbedInlineEntry && (jsxRuntime.jsx("button", { className: "contentful-toolbar__embed-option", onClick: onEmbedInlineEntry, children: "\uD83D\uDCDD Inline Entry" })), onEmbedAsset && (jsxRuntime.jsx("button", { className: "contentful-toolbar__embed-option", onClick: onEmbedAsset, children: "\uD83D\uDDBC\uFE0F Media" }))] })] }) })] }))] }));
|
|
26600
26673
|
};
|
|
26601
26674
|
|
|
26602
26675
|
var dist = {};
|
|
@@ -27029,75 +27102,75 @@ var distExports = requireDist();
|
|
|
27029
27102
|
/**
|
|
27030
27103
|
* Converts a Contentful Rich Text Document to Tiptap JSON format
|
|
27031
27104
|
*/
|
|
27032
|
-
|
|
27033
|
-
|
|
27105
|
+
var contentfulToTiptap = function (document) {
|
|
27106
|
+
var convertNode = function (node) {
|
|
27034
27107
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
27035
27108
|
switch (node.nodeType) {
|
|
27036
27109
|
case distExports.BLOCKS.DOCUMENT:
|
|
27037
27110
|
return {
|
|
27038
27111
|
type: 'doc',
|
|
27039
|
-
content: node.content.map(child
|
|
27112
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27040
27113
|
};
|
|
27041
27114
|
case distExports.BLOCKS.PARAGRAPH:
|
|
27042
27115
|
return {
|
|
27043
27116
|
type: 'paragraph',
|
|
27044
|
-
content: node.content ? node.content.map(child
|
|
27117
|
+
content: node.content ? node.content.map(function (child) { return convertNode(child); }).flat() : [],
|
|
27045
27118
|
};
|
|
27046
27119
|
case distExports.BLOCKS.HEADING_1:
|
|
27047
27120
|
return {
|
|
27048
27121
|
type: 'heading',
|
|
27049
27122
|
attrs: { level: 1 },
|
|
27050
|
-
content: node.content.map(child
|
|
27123
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27051
27124
|
};
|
|
27052
27125
|
case distExports.BLOCKS.HEADING_2:
|
|
27053
27126
|
return {
|
|
27054
27127
|
type: 'heading',
|
|
27055
27128
|
attrs: { level: 2 },
|
|
27056
|
-
content: node.content.map(child
|
|
27129
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27057
27130
|
};
|
|
27058
27131
|
case distExports.BLOCKS.HEADING_3:
|
|
27059
27132
|
return {
|
|
27060
27133
|
type: 'heading',
|
|
27061
27134
|
attrs: { level: 3 },
|
|
27062
|
-
content: node.content.map(child
|
|
27135
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27063
27136
|
};
|
|
27064
27137
|
case distExports.BLOCKS.HEADING_4:
|
|
27065
27138
|
return {
|
|
27066
27139
|
type: 'heading',
|
|
27067
27140
|
attrs: { level: 4 },
|
|
27068
|
-
content: node.content.map(child
|
|
27141
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27069
27142
|
};
|
|
27070
27143
|
case distExports.BLOCKS.HEADING_5:
|
|
27071
27144
|
return {
|
|
27072
27145
|
type: 'heading',
|
|
27073
27146
|
attrs: { level: 5 },
|
|
27074
|
-
content: node.content.map(child
|
|
27147
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27075
27148
|
};
|
|
27076
27149
|
case distExports.BLOCKS.HEADING_6:
|
|
27077
27150
|
return {
|
|
27078
27151
|
type: 'heading',
|
|
27079
27152
|
attrs: { level: 6 },
|
|
27080
|
-
content: node.content.map(child
|
|
27153
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27081
27154
|
};
|
|
27082
27155
|
case distExports.BLOCKS.UL_LIST:
|
|
27083
27156
|
return {
|
|
27084
27157
|
type: 'bulletList',
|
|
27085
|
-
content: node.content.map(child
|
|
27158
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27086
27159
|
};
|
|
27087
27160
|
case distExports.BLOCKS.OL_LIST:
|
|
27088
27161
|
return {
|
|
27089
27162
|
type: 'orderedList',
|
|
27090
|
-
content: node.content.map(child
|
|
27163
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27091
27164
|
};
|
|
27092
27165
|
case distExports.BLOCKS.LIST_ITEM:
|
|
27093
27166
|
return {
|
|
27094
27167
|
type: 'listItem',
|
|
27095
|
-
content: node.content.map(child
|
|
27168
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27096
27169
|
};
|
|
27097
27170
|
case distExports.BLOCKS.QUOTE:
|
|
27098
27171
|
return {
|
|
27099
27172
|
type: 'blockquote',
|
|
27100
|
-
content: node.content.map(child
|
|
27173
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27101
27174
|
};
|
|
27102
27175
|
case distExports.BLOCKS.HR:
|
|
27103
27176
|
return {
|
|
@@ -27106,27 +27179,29 @@ const contentfulToTiptap = (document) => {
|
|
|
27106
27179
|
case distExports.BLOCKS.TABLE:
|
|
27107
27180
|
return {
|
|
27108
27181
|
type: 'table',
|
|
27109
|
-
content: node.content.map(child
|
|
27182
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27110
27183
|
};
|
|
27111
27184
|
case distExports.BLOCKS.TABLE_ROW:
|
|
27112
27185
|
return {
|
|
27113
27186
|
type: 'tableRow',
|
|
27114
|
-
content: node.content.map(child
|
|
27187
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27115
27188
|
};
|
|
27116
27189
|
case distExports.BLOCKS.TABLE_CELL:
|
|
27117
27190
|
return {
|
|
27118
27191
|
type: 'tableCell',
|
|
27119
|
-
content: node.content.map(child
|
|
27192
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27120
27193
|
};
|
|
27121
27194
|
case distExports.BLOCKS.TABLE_HEADER_CELL:
|
|
27122
27195
|
return {
|
|
27123
27196
|
type: 'tableHeader',
|
|
27124
|
-
content: node.content.map(child
|
|
27197
|
+
content: node.content.map(function (child) { return convertNode(child); }).flat(),
|
|
27125
27198
|
};
|
|
27126
27199
|
case distExports.INLINES.HYPERLINK:
|
|
27127
27200
|
return {
|
|
27128
27201
|
type: 'text',
|
|
27129
|
-
text: node.content.map(
|
|
27202
|
+
text: node.content.map(function (child) {
|
|
27203
|
+
return child.nodeType === 'text' ? child.value : '';
|
|
27204
|
+
}).join(''),
|
|
27130
27205
|
marks: [
|
|
27131
27206
|
{
|
|
27132
27207
|
type: 'link',
|
|
@@ -27138,7 +27213,7 @@ const contentfulToTiptap = (document) => {
|
|
|
27138
27213
|
// Inline embedded entry
|
|
27139
27214
|
return {
|
|
27140
27215
|
type: 'text',
|
|
27141
|
-
text:
|
|
27216
|
+
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', "]"),
|
|
27142
27217
|
marks: [{ type: 'bold' }],
|
|
27143
27218
|
};
|
|
27144
27219
|
case distExports.BLOCKS.EMBEDDED_ENTRY:
|
|
@@ -27147,7 +27222,7 @@ const contentfulToTiptap = (document) => {
|
|
|
27147
27222
|
content: [
|
|
27148
27223
|
{
|
|
27149
27224
|
type: 'text',
|
|
27150
|
-
text:
|
|
27225
|
+
text: "[Embedded Entry: ".concat(((_d = (_c = node.data.target) === null || _c === void 0 ? void 0 : _c.sys) === null || _d === void 0 ? void 0 : _d.id) || 'Unknown', "]"),
|
|
27151
27226
|
marks: [{ type: 'bold' }],
|
|
27152
27227
|
},
|
|
27153
27228
|
],
|
|
@@ -27158,14 +27233,14 @@ const contentfulToTiptap = (document) => {
|
|
|
27158
27233
|
content: [
|
|
27159
27234
|
{
|
|
27160
27235
|
type: 'text',
|
|
27161
|
-
text:
|
|
27236
|
+
text: "[Embedded Asset: ".concat(((_f = (_e = node.data.target) === null || _e === void 0 ? void 0 : _e.sys) === null || _f === void 0 ? void 0 : _f.id) || 'Unknown', "]"),
|
|
27162
27237
|
marks: [{ type: 'bold' }],
|
|
27163
27238
|
},
|
|
27164
27239
|
],
|
|
27165
27240
|
};
|
|
27166
27241
|
case 'text':
|
|
27167
|
-
|
|
27168
|
-
|
|
27242
|
+
var textNode = node;
|
|
27243
|
+
var marks = ((_g = textNode.marks) === null || _g === void 0 ? void 0 : _g.map(function (mark) {
|
|
27169
27244
|
switch (mark.type) {
|
|
27170
27245
|
case distExports.MARKS.BOLD:
|
|
27171
27246
|
return { type: 'bold' };
|
|
@@ -27178,14 +27253,14 @@ const contentfulToTiptap = (document) => {
|
|
|
27178
27253
|
default:
|
|
27179
27254
|
return null;
|
|
27180
27255
|
}
|
|
27181
|
-
}).filter((mark)
|
|
27256
|
+
}).filter(function (mark) { return mark !== null; })) || [];
|
|
27182
27257
|
return {
|
|
27183
27258
|
type: 'text',
|
|
27184
27259
|
text: textNode.value,
|
|
27185
27260
|
marks: marks.length > 0 ? marks : undefined,
|
|
27186
27261
|
};
|
|
27187
27262
|
default:
|
|
27188
|
-
console.warn(
|
|
27263
|
+
console.warn("Unknown Contentful node type: ".concat(node.nodeType));
|
|
27189
27264
|
return {
|
|
27190
27265
|
type: 'paragraph',
|
|
27191
27266
|
content: [],
|
|
@@ -27197,25 +27272,25 @@ const contentfulToTiptap = (document) => {
|
|
|
27197
27272
|
/**
|
|
27198
27273
|
* Converts Tiptap JSON format to Contentful Rich Text Document
|
|
27199
27274
|
*/
|
|
27200
|
-
|
|
27201
|
-
|
|
27275
|
+
var tiptapToContentful = function (tiptapDoc) {
|
|
27276
|
+
var convertNode = function (node) {
|
|
27202
27277
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
27203
27278
|
switch (node.type) {
|
|
27204
27279
|
case 'doc':
|
|
27205
27280
|
return {
|
|
27206
27281
|
nodeType: distExports.BLOCKS.DOCUMENT,
|
|
27207
27282
|
data: {},
|
|
27208
|
-
content: (_a = node.content) === null || _a === void 0 ? void 0 : _a.map((child)
|
|
27283
|
+
content: (_a = node.content) === null || _a === void 0 ? void 0 : _a.map(function (child) { return convertNode(child); }),
|
|
27209
27284
|
};
|
|
27210
27285
|
case 'paragraph':
|
|
27211
27286
|
return {
|
|
27212
27287
|
nodeType: distExports.BLOCKS.PARAGRAPH,
|
|
27213
27288
|
data: {},
|
|
27214
|
-
content: (_b = node.content) === null || _b === void 0 ? void 0 : _b.map((child)
|
|
27289
|
+
content: (_b = node.content) === null || _b === void 0 ? void 0 : _b.map(function (child) { return convertNode(child); }),
|
|
27215
27290
|
};
|
|
27216
27291
|
case 'heading':
|
|
27217
|
-
|
|
27218
|
-
|
|
27292
|
+
var level = ((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.level) || 1;
|
|
27293
|
+
var headingTypes = {
|
|
27219
27294
|
1: distExports.BLOCKS.HEADING_1,
|
|
27220
27295
|
2: distExports.BLOCKS.HEADING_2,
|
|
27221
27296
|
3: distExports.BLOCKS.HEADING_3,
|
|
@@ -27223,35 +27298,35 @@ const tiptapToContentful = (tiptapDoc) => {
|
|
|
27223
27298
|
5: distExports.BLOCKS.HEADING_5,
|
|
27224
27299
|
6: distExports.BLOCKS.HEADING_6,
|
|
27225
27300
|
};
|
|
27226
|
-
|
|
27301
|
+
var headingType = headingTypes[level] || distExports.BLOCKS.HEADING_1;
|
|
27227
27302
|
return {
|
|
27228
27303
|
nodeType: headingType,
|
|
27229
27304
|
data: {},
|
|
27230
|
-
content: (_d = node.content) === null || _d === void 0 ? void 0 : _d.map((child)
|
|
27305
|
+
content: (_d = node.content) === null || _d === void 0 ? void 0 : _d.map(function (child) { return convertNode(child); }),
|
|
27231
27306
|
};
|
|
27232
27307
|
case 'bulletList':
|
|
27233
27308
|
return {
|
|
27234
27309
|
nodeType: distExports.BLOCKS.UL_LIST,
|
|
27235
27310
|
data: {},
|
|
27236
|
-
content: (_e = node.content) === null || _e === void 0 ? void 0 : _e.map((child)
|
|
27311
|
+
content: (_e = node.content) === null || _e === void 0 ? void 0 : _e.map(function (child) { return convertNode(child); }),
|
|
27237
27312
|
};
|
|
27238
27313
|
case 'orderedList':
|
|
27239
27314
|
return {
|
|
27240
27315
|
nodeType: distExports.BLOCKS.OL_LIST,
|
|
27241
27316
|
data: {},
|
|
27242
|
-
content: (_f = node.content) === null || _f === void 0 ? void 0 : _f.map((child)
|
|
27317
|
+
content: (_f = node.content) === null || _f === void 0 ? void 0 : _f.map(function (child) { return convertNode(child); }),
|
|
27243
27318
|
};
|
|
27244
27319
|
case 'listItem':
|
|
27245
27320
|
return {
|
|
27246
27321
|
nodeType: distExports.BLOCKS.LIST_ITEM,
|
|
27247
27322
|
data: {},
|
|
27248
|
-
content: (_g = node.content) === null || _g === void 0 ? void 0 : _g.map((child)
|
|
27323
|
+
content: (_g = node.content) === null || _g === void 0 ? void 0 : _g.map(function (child) { return convertNode(child); }),
|
|
27249
27324
|
};
|
|
27250
27325
|
case 'blockquote':
|
|
27251
27326
|
return {
|
|
27252
27327
|
nodeType: distExports.BLOCKS.QUOTE,
|
|
27253
27328
|
data: {},
|
|
27254
|
-
content: (_h = node.content) === null || _h === void 0 ? void 0 : _h.map((child)
|
|
27329
|
+
content: (_h = node.content) === null || _h === void 0 ? void 0 : _h.map(function (child) { return convertNode(child); }),
|
|
27255
27330
|
};
|
|
27256
27331
|
case 'horizontalRule':
|
|
27257
27332
|
return {
|
|
@@ -27263,28 +27338,28 @@ const tiptapToContentful = (tiptapDoc) => {
|
|
|
27263
27338
|
return {
|
|
27264
27339
|
nodeType: distExports.BLOCKS.TABLE,
|
|
27265
27340
|
data: {},
|
|
27266
|
-
content: (_j = node.content) === null || _j === void 0 ? void 0 : _j.map((child)
|
|
27341
|
+
content: (_j = node.content) === null || _j === void 0 ? void 0 : _j.map(function (child) { return convertNode(child); }),
|
|
27267
27342
|
};
|
|
27268
27343
|
case 'tableRow':
|
|
27269
27344
|
return {
|
|
27270
27345
|
nodeType: distExports.BLOCKS.TABLE_ROW,
|
|
27271
27346
|
data: {},
|
|
27272
|
-
content: (_k = node.content) === null || _k === void 0 ? void 0 : _k.map((child)
|
|
27347
|
+
content: (_k = node.content) === null || _k === void 0 ? void 0 : _k.map(function (child) { return convertNode(child); }),
|
|
27273
27348
|
};
|
|
27274
27349
|
case 'tableCell':
|
|
27275
27350
|
return {
|
|
27276
27351
|
nodeType: distExports.BLOCKS.TABLE_CELL,
|
|
27277
27352
|
data: {},
|
|
27278
|
-
content: (_l = node.content) === null || _l === void 0 ? void 0 : _l.map((child)
|
|
27353
|
+
content: (_l = node.content) === null || _l === void 0 ? void 0 : _l.map(function (child) { return convertNode(child); }),
|
|
27279
27354
|
};
|
|
27280
27355
|
case 'tableHeader':
|
|
27281
27356
|
return {
|
|
27282
27357
|
nodeType: distExports.BLOCKS.TABLE_HEADER_CELL,
|
|
27283
27358
|
data: {},
|
|
27284
|
-
content: (_m = node.content) === null || _m === void 0 ? void 0 : _m.map((child)
|
|
27359
|
+
content: (_m = node.content) === null || _m === void 0 ? void 0 : _m.map(function (child) { return convertNode(child); }),
|
|
27285
27360
|
};
|
|
27286
27361
|
case 'text':
|
|
27287
|
-
|
|
27362
|
+
var marks = ((_o = node.marks) === null || _o === void 0 ? void 0 : _o.map(function (mark) {
|
|
27288
27363
|
switch (mark.type) {
|
|
27289
27364
|
case 'bold':
|
|
27290
27365
|
return { type: distExports.MARKS.BOLD };
|
|
@@ -27301,7 +27376,7 @@ const tiptapToContentful = (tiptapDoc) => {
|
|
|
27301
27376
|
}
|
|
27302
27377
|
}).filter(Boolean)) || [];
|
|
27303
27378
|
// Check if this text has a link mark
|
|
27304
|
-
|
|
27379
|
+
var linkMark = (_p = node.marks) === null || _p === void 0 ? void 0 : _p.find(function (mark) { return mark.type === 'link'; });
|
|
27305
27380
|
if (linkMark) {
|
|
27306
27381
|
return {
|
|
27307
27382
|
nodeType: distExports.INLINES.HYPERLINK,
|
|
@@ -27319,11 +27394,11 @@ const tiptapToContentful = (tiptapDoc) => {
|
|
|
27319
27394
|
};
|
|
27320
27395
|
}
|
|
27321
27396
|
// Check if this is an inline entry (by looking for specific patterns)
|
|
27322
|
-
|
|
27323
|
-
if (isInlineEntry && ((_r = node.marks) === null || _r === void 0 ? void 0 : _r.some((mark)
|
|
27397
|
+
var isInlineEntry = node.text && node.text.startsWith('[Inline Entry:');
|
|
27398
|
+
if (isInlineEntry && ((_r = node.marks) === null || _r === void 0 ? void 0 : _r.some(function (mark) { return mark.type === 'bold'; }))) {
|
|
27324
27399
|
// Extract entry ID from the text
|
|
27325
|
-
|
|
27326
|
-
|
|
27400
|
+
var match = node.text.match(/\[Inline Entry:\s*([^\]]+)\]/);
|
|
27401
|
+
var entryId = match ? match[1].trim() : 'Unknown';
|
|
27327
27402
|
return {
|
|
27328
27403
|
nodeType: distExports.INLINES.EMBEDDED_ENTRY,
|
|
27329
27404
|
data: {
|
|
@@ -27345,7 +27420,7 @@ const tiptapToContentful = (tiptapDoc) => {
|
|
|
27345
27420
|
data: {},
|
|
27346
27421
|
};
|
|
27347
27422
|
default:
|
|
27348
|
-
console.warn(
|
|
27423
|
+
console.warn("Unknown Tiptap node type: ".concat(node.type));
|
|
27349
27424
|
return {
|
|
27350
27425
|
nodeType: distExports.BLOCKS.PARAGRAPH,
|
|
27351
27426
|
data: {},
|
|
@@ -27358,7 +27433,7 @@ const tiptapToContentful = (tiptapDoc) => {
|
|
|
27358
27433
|
/**
|
|
27359
27434
|
* Validates if a Contentful document is properly formatted
|
|
27360
27435
|
*/
|
|
27361
|
-
|
|
27436
|
+
var validateContentfulDocument = function (document) {
|
|
27362
27437
|
if (!document || typeof document !== 'object') {
|
|
27363
27438
|
return false;
|
|
27364
27439
|
}
|
|
@@ -27373,7 +27448,7 @@ const validateContentfulDocument = (document) => {
|
|
|
27373
27448
|
/**
|
|
27374
27449
|
* Creates an empty Contentful document
|
|
27375
27450
|
*/
|
|
27376
|
-
|
|
27451
|
+
var createEmptyDocument = function () { return ({
|
|
27377
27452
|
nodeType: distExports.BLOCKS.DOCUMENT,
|
|
27378
27453
|
data: {},
|
|
27379
27454
|
content: [
|
|
@@ -27383,12 +27458,12 @@ const createEmptyDocument = () => ({
|
|
|
27383
27458
|
content: [],
|
|
27384
27459
|
},
|
|
27385
27460
|
],
|
|
27386
|
-
});
|
|
27461
|
+
}); };
|
|
27387
27462
|
/**
|
|
27388
27463
|
* Sanitizes a Contentful document by removing invalid nodes/marks based on configuration
|
|
27389
27464
|
*/
|
|
27390
|
-
|
|
27391
|
-
|
|
27465
|
+
var sanitizeContentfulDocument = function (document, allowedNodeTypes, allowedMarks) {
|
|
27466
|
+
var sanitizeNode = function (node) {
|
|
27392
27467
|
var _a, _b;
|
|
27393
27468
|
// Check if node type is allowed
|
|
27394
27469
|
if (!allowedNodeTypes.includes(node.nodeType)) {
|
|
@@ -27400,41 +27475,35 @@ const sanitizeContentfulDocument = (document, allowedNodeTypes, allowedMarks) =>
|
|
|
27400
27475
|
return {
|
|
27401
27476
|
nodeType: distExports.BLOCKS.PARAGRAPH,
|
|
27402
27477
|
data: {},
|
|
27403
|
-
content: (_a = node.content) === null || _a === void 0 ? void 0 : _a.map(child
|
|
27478
|
+
content: (_a = node.content) === null || _a === void 0 ? void 0 : _a.map(function (child) { return sanitizeNode(child); }).filter(Boolean),
|
|
27404
27479
|
};
|
|
27405
27480
|
}
|
|
27406
27481
|
return null;
|
|
27407
27482
|
}
|
|
27408
27483
|
if (node.nodeType === 'text') {
|
|
27409
|
-
|
|
27410
|
-
|
|
27411
|
-
return {
|
|
27412
|
-
...textNode,
|
|
27413
|
-
marks: sanitizedMarks,
|
|
27414
|
-
};
|
|
27484
|
+
var textNode = node;
|
|
27485
|
+
var sanitizedMarks = ((_b = textNode.marks) === null || _b === void 0 ? void 0 : _b.filter(function (mark) { return allowedMarks.includes(mark.type); })) || [];
|
|
27486
|
+
return __assign(__assign({}, textNode), { marks: sanitizedMarks });
|
|
27415
27487
|
}
|
|
27416
27488
|
if ('content' in node && node.content) {
|
|
27417
|
-
|
|
27418
|
-
return {
|
|
27419
|
-
...node,
|
|
27420
|
-
content: sanitizedContent,
|
|
27421
|
-
};
|
|
27489
|
+
var sanitizedContent = node.content.map(function (child) { return sanitizeNode(child); }).filter(Boolean);
|
|
27490
|
+
return __assign(__assign({}, node), { content: sanitizedContent });
|
|
27422
27491
|
}
|
|
27423
27492
|
return node;
|
|
27424
27493
|
};
|
|
27425
|
-
|
|
27494
|
+
var sanitized = sanitizeNode(document);
|
|
27426
27495
|
return sanitized;
|
|
27427
27496
|
};
|
|
27428
27497
|
/**
|
|
27429
27498
|
* Extracts plain text from a Contentful document
|
|
27430
27499
|
*/
|
|
27431
|
-
|
|
27432
|
-
|
|
27500
|
+
var extractPlainText = function (document) {
|
|
27501
|
+
var extractFromNode = function (node) {
|
|
27433
27502
|
if (node.nodeType === 'text') {
|
|
27434
27503
|
return node.value;
|
|
27435
27504
|
}
|
|
27436
27505
|
if ('content' in node && node.content) {
|
|
27437
|
-
return node.content.map(child
|
|
27506
|
+
return node.content.map(function (child) { return extractFromNode(child); }).join('');
|
|
27438
27507
|
}
|
|
27439
27508
|
return '';
|
|
27440
27509
|
};
|
|
@@ -27443,44 +27512,44 @@ const extractPlainText = (document) => {
|
|
|
27443
27512
|
/**
|
|
27444
27513
|
* Counts words in a Contentful document
|
|
27445
27514
|
*/
|
|
27446
|
-
|
|
27447
|
-
|
|
27448
|
-
|
|
27515
|
+
var countWords = function (document) {
|
|
27516
|
+
var plainText = extractPlainText(document);
|
|
27517
|
+
var words = plainText.trim().split(/\s+/).filter(function (word) { return word.length > 0; });
|
|
27449
27518
|
return words.length;
|
|
27450
27519
|
};
|
|
27451
27520
|
/**
|
|
27452
27521
|
* Finds all embedded entries/assets in a document
|
|
27453
27522
|
*/
|
|
27454
|
-
|
|
27455
|
-
|
|
27456
|
-
|
|
27457
|
-
|
|
27458
|
-
|
|
27523
|
+
var findEmbeddedContent = function (document) {
|
|
27524
|
+
var entries = [];
|
|
27525
|
+
var assets = [];
|
|
27526
|
+
var inlineEntries = [];
|
|
27527
|
+
var searchNode = function (node) {
|
|
27459
27528
|
var _a, _b, _c, _d, _e, _f;
|
|
27460
27529
|
if (node.nodeType === distExports.BLOCKS.EMBEDDED_ENTRY) {
|
|
27461
|
-
|
|
27530
|
+
var entryId = (_b = (_a = node.data.target) === null || _a === void 0 ? void 0 : _a.sys) === null || _b === void 0 ? void 0 : _b.id;
|
|
27462
27531
|
if (entryId)
|
|
27463
27532
|
entries.push(entryId);
|
|
27464
27533
|
}
|
|
27465
27534
|
else if (node.nodeType === distExports.BLOCKS.EMBEDDED_ASSET) {
|
|
27466
|
-
|
|
27535
|
+
var assetId = (_d = (_c = node.data.target) === null || _c === void 0 ? void 0 : _c.sys) === null || _d === void 0 ? void 0 : _d.id;
|
|
27467
27536
|
if (assetId)
|
|
27468
27537
|
assets.push(assetId);
|
|
27469
27538
|
}
|
|
27470
27539
|
else if (node.nodeType === distExports.INLINES.EMBEDDED_ENTRY) {
|
|
27471
|
-
|
|
27540
|
+
var entryId = (_f = (_e = node.data.target) === null || _e === void 0 ? void 0 : _e.sys) === null || _f === void 0 ? void 0 : _f.id;
|
|
27472
27541
|
if (entryId)
|
|
27473
27542
|
inlineEntries.push(entryId);
|
|
27474
27543
|
}
|
|
27475
27544
|
if ('content' in node && node.content) {
|
|
27476
|
-
node.content.forEach(child
|
|
27545
|
+
node.content.forEach(function (child) { return searchNode(child); });
|
|
27477
27546
|
}
|
|
27478
27547
|
};
|
|
27479
27548
|
searchNode(document);
|
|
27480
27549
|
return {
|
|
27481
|
-
entries:
|
|
27482
|
-
assets:
|
|
27483
|
-
inlineEntries:
|
|
27550
|
+
entries: Array.from(new Set(entries)), // Remove duplicates
|
|
27551
|
+
assets: Array.from(new Set(assets)),
|
|
27552
|
+
inlineEntries: Array.from(new Set(inlineEntries)),
|
|
27484
27553
|
};
|
|
27485
27554
|
};
|
|
27486
27555
|
|
|
@@ -27488,10 +27557,10 @@ const findEmbeddedContent = (document) => {
|
|
|
27488
27557
|
/**
|
|
27489
27558
|
* Parses Contentful field configuration to determine editor capabilities
|
|
27490
27559
|
*/
|
|
27491
|
-
|
|
27560
|
+
var parseContentfulFieldConfig = function (fieldConfiguration) {
|
|
27492
27561
|
var _a;
|
|
27493
27562
|
// Default configuration when no field config is provided
|
|
27494
|
-
|
|
27563
|
+
var defaultConfig = {
|
|
27495
27564
|
availableHeadings: [1, 2, 3, 4, 5, 6],
|
|
27496
27565
|
availableMarks: ['bold', 'italic', 'underline'],
|
|
27497
27566
|
disabledFeatures: [],
|
|
@@ -27506,11 +27575,11 @@ const parseContentfulFieldConfig = (fieldConfiguration) => {
|
|
|
27506
27575
|
if (!((_a = fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.validations) === null || _a === void 0 ? void 0 : _a[0])) {
|
|
27507
27576
|
return defaultConfig;
|
|
27508
27577
|
}
|
|
27509
|
-
|
|
27510
|
-
|
|
27511
|
-
|
|
27578
|
+
var validation = fieldConfiguration.validations[0];
|
|
27579
|
+
var enabledMarks = validation.enabledMarks || [];
|
|
27580
|
+
var enabledNodeTypes = validation.enabledNodeTypes || [];
|
|
27512
27581
|
// Parse available text marks
|
|
27513
|
-
|
|
27582
|
+
var marks = [];
|
|
27514
27583
|
if (enabledMarks.includes('bold'))
|
|
27515
27584
|
marks.push('bold');
|
|
27516
27585
|
if (enabledMarks.includes('italic'))
|
|
@@ -27518,7 +27587,7 @@ const parseContentfulFieldConfig = (fieldConfiguration) => {
|
|
|
27518
27587
|
if (enabledMarks.includes('underline'))
|
|
27519
27588
|
marks.push('underline');
|
|
27520
27589
|
// Parse available heading levels
|
|
27521
|
-
|
|
27590
|
+
var headings = [];
|
|
27522
27591
|
if (enabledNodeTypes.includes('heading-1'))
|
|
27523
27592
|
headings.push(1);
|
|
27524
27593
|
if (enabledNodeTypes.includes('heading-2'))
|
|
@@ -27532,15 +27601,15 @@ const parseContentfulFieldConfig = (fieldConfiguration) => {
|
|
|
27532
27601
|
if (enabledNodeTypes.includes('heading-6'))
|
|
27533
27602
|
headings.push(6);
|
|
27534
27603
|
// Parse other features
|
|
27535
|
-
|
|
27536
|
-
|
|
27537
|
-
|
|
27538
|
-
|
|
27539
|
-
|
|
27540
|
-
|
|
27541
|
-
|
|
27604
|
+
var allowHyperlinks = enabledNodeTypes.includes('hyperlink');
|
|
27605
|
+
var allowEmbeddedEntries = enabledNodeTypes.includes('embedded-entry-block');
|
|
27606
|
+
var allowEmbeddedAssets = enabledNodeTypes.includes('embedded-asset-block');
|
|
27607
|
+
var allowInlineEntries = enabledNodeTypes.includes('embedded-entry-inline');
|
|
27608
|
+
var allowTables = enabledNodeTypes.includes('table');
|
|
27609
|
+
var allowQuotes = enabledNodeTypes.includes('blockquote') || enabledNodeTypes.includes('quote');
|
|
27610
|
+
var allowLists = enabledNodeTypes.includes('unordered-list') || enabledNodeTypes.includes('ordered-list');
|
|
27542
27611
|
// Build disabled features array
|
|
27543
|
-
|
|
27612
|
+
var disabled = [];
|
|
27544
27613
|
if (!marks.includes('bold'))
|
|
27545
27614
|
disabled.push('bold');
|
|
27546
27615
|
if (!marks.includes('italic'))
|
|
@@ -27563,51 +27632,61 @@ const parseContentfulFieldConfig = (fieldConfiguration) => {
|
|
|
27563
27632
|
availableHeadings: headings,
|
|
27564
27633
|
availableMarks: marks,
|
|
27565
27634
|
disabledFeatures: disabled,
|
|
27566
|
-
allowHyperlinks,
|
|
27567
|
-
allowEmbeddedEntries,
|
|
27568
|
-
allowEmbeddedAssets,
|
|
27569
|
-
allowInlineEntries,
|
|
27570
|
-
allowTables,
|
|
27571
|
-
allowQuotes,
|
|
27572
|
-
allowLists,
|
|
27635
|
+
allowHyperlinks: allowHyperlinks,
|
|
27636
|
+
allowEmbeddedEntries: allowEmbeddedEntries,
|
|
27637
|
+
allowEmbeddedAssets: allowEmbeddedAssets,
|
|
27638
|
+
allowInlineEntries: allowInlineEntries,
|
|
27639
|
+
allowTables: allowTables,
|
|
27640
|
+
allowQuotes: allowQuotes,
|
|
27641
|
+
allowLists: allowLists,
|
|
27573
27642
|
};
|
|
27574
27643
|
};
|
|
27575
27644
|
/**
|
|
27576
27645
|
* Helper function to fetch Contentful field configuration from Management API
|
|
27577
27646
|
*/
|
|
27578
|
-
|
|
27579
|
-
|
|
27580
|
-
|
|
27581
|
-
|
|
27582
|
-
|
|
27583
|
-
|
|
27584
|
-
|
|
27585
|
-
|
|
27586
|
-
|
|
27587
|
-
|
|
27588
|
-
|
|
27589
|
-
|
|
27590
|
-
|
|
27591
|
-
|
|
27592
|
-
|
|
27593
|
-
|
|
27647
|
+
var fetchContentfulFieldConfig = function (spaceId, contentTypeId, fieldId, accessToken) { return __awaiter(void 0, void 0, void 0, function () {
|
|
27648
|
+
var response, contentType, field, error_1;
|
|
27649
|
+
return __generator(this, function (_a) {
|
|
27650
|
+
switch (_a.label) {
|
|
27651
|
+
case 0:
|
|
27652
|
+
_a.trys.push([0, 3, , 4]);
|
|
27653
|
+
return [4 /*yield*/, fetch("https://api.contentful.com/spaces/".concat(spaceId, "/content_types/").concat(contentTypeId), {
|
|
27654
|
+
headers: {
|
|
27655
|
+
'Authorization': "Bearer ".concat(accessToken),
|
|
27656
|
+
'Content-Type': 'application/vnd.contentful.management.v1+json',
|
|
27657
|
+
},
|
|
27658
|
+
})];
|
|
27659
|
+
case 1:
|
|
27660
|
+
response = _a.sent();
|
|
27661
|
+
if (!response.ok) {
|
|
27662
|
+
throw new Error("Failed to fetch content type: ".concat(response.status, " ").concat(response.statusText));
|
|
27663
|
+
}
|
|
27664
|
+
return [4 /*yield*/, response.json()];
|
|
27665
|
+
case 2:
|
|
27666
|
+
contentType = _a.sent();
|
|
27667
|
+
field = contentType.fields.find(function (f) { return f.id === fieldId; });
|
|
27668
|
+
if (!field || field.type !== 'RichText') {
|
|
27669
|
+
console.warn("Field \"".concat(fieldId, "\" not found or is not a RichText field"));
|
|
27670
|
+
return [2 /*return*/, null];
|
|
27671
|
+
}
|
|
27672
|
+
return [2 /*return*/, {
|
|
27673
|
+
validations: field.validations || [],
|
|
27674
|
+
settings: {
|
|
27675
|
+
helpText: field.helpText,
|
|
27676
|
+
},
|
|
27677
|
+
}];
|
|
27678
|
+
case 3:
|
|
27679
|
+
error_1 = _a.sent();
|
|
27680
|
+
console.error('Error fetching Contentful field configuration:', error_1);
|
|
27681
|
+
return [2 /*return*/, null];
|
|
27682
|
+
case 4: return [2 /*return*/];
|
|
27594
27683
|
}
|
|
27595
|
-
|
|
27596
|
-
|
|
27597
|
-
settings: {
|
|
27598
|
-
helpText: field.helpText,
|
|
27599
|
-
},
|
|
27600
|
-
};
|
|
27601
|
-
}
|
|
27602
|
-
catch (error) {
|
|
27603
|
-
console.error('Error fetching Contentful field configuration:', error);
|
|
27604
|
-
return null;
|
|
27605
|
-
}
|
|
27606
|
-
};
|
|
27684
|
+
});
|
|
27685
|
+
}); };
|
|
27607
27686
|
/**
|
|
27608
27687
|
* Creates a mock field configuration for testing purposes
|
|
27609
27688
|
*/
|
|
27610
|
-
|
|
27689
|
+
var createMockFieldConfig = function (options) {
|
|
27611
27690
|
return {
|
|
27612
27691
|
validations: [{
|
|
27613
27692
|
enabledMarks: options.enabledMarks || ['bold', 'italic'],
|
|
@@ -27625,24 +27704,23 @@ const createMockFieldConfig = (options) => {
|
|
|
27625
27704
|
};
|
|
27626
27705
|
};
|
|
27627
27706
|
|
|
27628
|
-
|
|
27629
|
-
|
|
27630
|
-
|
|
27707
|
+
var ContentfulRichTextEditor = function (_a) {
|
|
27708
|
+
var initialValue = _a.initialValue, onChange = _a.onChange, onEmbedEntry = _a.onEmbedEntry, onEmbedAsset = _a.onEmbedAsset, onEmbedInlineEntry = _a.onEmbedInlineEntry, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.readonly, readonly = _c === void 0 ? false : _c, _d = _a.placeholder, placeholder = _d === void 0 ? 'Start writing...' : _d, fieldConfiguration = _a.fieldConfiguration, _e = _a.disabledFeatures, disabledFeatures = _e === void 0 ? [] : _e, _f = _a.theme, theme = _f === void 0 ? 'contentful' : _f, _g = _a.availableHeadings, availableHeadings = _g === void 0 ? [1, 2, 3, 4, 5, 6] : _g, _h = _a.availableMarks, availableMarks = _h === void 0 ? ['bold', 'italic', 'underline'] : _h, _j = _a.showBorder, showBorder = _j === void 0 ? true : _j;
|
|
27709
|
+
var editorConfig = React.useMemo(function () {
|
|
27631
27710
|
if (fieldConfiguration) {
|
|
27632
27711
|
return parseContentfulFieldConfig(fieldConfiguration);
|
|
27633
27712
|
}
|
|
27634
|
-
|
|
27635
|
-
const disabled = [];
|
|
27713
|
+
var disabled = [];
|
|
27636
27714
|
if (!availableMarks.includes('bold'))
|
|
27637
27715
|
disabled.push('bold');
|
|
27638
27716
|
if (!availableMarks.includes('italic'))
|
|
27639
27717
|
disabled.push('italic');
|
|
27640
27718
|
if (!availableMarks.includes('underline'))
|
|
27641
27719
|
disabled.push('underline');
|
|
27642
|
-
disabled.push(
|
|
27720
|
+
disabled.push.apply(disabled, disabledFeatures);
|
|
27643
27721
|
return {
|
|
27644
|
-
availableHeadings,
|
|
27645
|
-
availableMarks,
|
|
27722
|
+
availableHeadings: availableHeadings,
|
|
27723
|
+
availableMarks: availableMarks,
|
|
27646
27724
|
disabledFeatures: disabled,
|
|
27647
27725
|
allowHyperlinks: !disabledFeatures.includes('link'),
|
|
27648
27726
|
allowEmbeddedEntries: !disabledFeatures.includes('embed'),
|
|
@@ -27653,10 +27731,8 @@ const ContentfulRichTextEditor = ({ initialValue, onChange, onEmbedEntry, onEmbe
|
|
|
27653
27731
|
allowLists: !disabledFeatures.includes('lists'),
|
|
27654
27732
|
};
|
|
27655
27733
|
}, [fieldConfiguration, disabledFeatures, availableHeadings, availableMarks]);
|
|
27656
|
-
|
|
27657
|
-
|
|
27658
|
-
const exts = [];
|
|
27659
|
-
// Add StarterKit with configuration
|
|
27734
|
+
var extensions = React.useMemo(function () {
|
|
27735
|
+
var exts = [];
|
|
27660
27736
|
exts.push(StarterKit.configure({
|
|
27661
27737
|
heading: editorConfig.availableHeadings.length > 0 ? {
|
|
27662
27738
|
levels: editorConfig.availableHeadings,
|
|
@@ -27679,11 +27755,9 @@ const ContentfulRichTextEditor = ({ initialValue, onChange, onEmbedEntry, onEmbe
|
|
|
27679
27755
|
},
|
|
27680
27756
|
} : false,
|
|
27681
27757
|
}));
|
|
27682
|
-
// Add underline extension only if it's in availableMarks
|
|
27683
27758
|
if (editorConfig.availableMarks.includes('underline')) {
|
|
27684
27759
|
exts.push(Underline);
|
|
27685
27760
|
}
|
|
27686
|
-
// Add link extension only if hyperlinks are allowed
|
|
27687
27761
|
if (editorConfig.allowHyperlinks) {
|
|
27688
27762
|
exts.push(Link.configure({
|
|
27689
27763
|
openOnClick: false,
|
|
@@ -27693,7 +27767,6 @@ const ContentfulRichTextEditor = ({ initialValue, onChange, onEmbedEntry, onEmbe
|
|
|
27693
27767
|
},
|
|
27694
27768
|
}));
|
|
27695
27769
|
}
|
|
27696
|
-
// Add table extensions only if tables are allowed
|
|
27697
27770
|
if (editorConfig.allowTables) {
|
|
27698
27771
|
exts.push(Table.configure({
|
|
27699
27772
|
resizable: true,
|
|
@@ -27716,20 +27789,21 @@ const ContentfulRichTextEditor = ({ initialValue, onChange, onEmbedEntry, onEmbe
|
|
|
27716
27789
|
}
|
|
27717
27790
|
return exts;
|
|
27718
27791
|
}, [editorConfig]);
|
|
27719
|
-
|
|
27720
|
-
extensions,
|
|
27792
|
+
var editor = useEditor({
|
|
27793
|
+
extensions: extensions,
|
|
27721
27794
|
content: initialValue ? contentfulToTiptap(initialValue) : '',
|
|
27722
27795
|
editable: !readonly,
|
|
27723
27796
|
editorProps: {
|
|
27724
27797
|
attributes: {
|
|
27725
|
-
class:
|
|
27798
|
+
class: "contentful-editor-content contentful-editor-content--".concat(theme),
|
|
27726
27799
|
'data-placeholder': placeholder,
|
|
27727
27800
|
},
|
|
27728
27801
|
},
|
|
27729
|
-
onUpdate: (
|
|
27802
|
+
onUpdate: function (_a) {
|
|
27803
|
+
var editor = _a.editor;
|
|
27730
27804
|
if (onChange) {
|
|
27731
27805
|
try {
|
|
27732
|
-
|
|
27806
|
+
var contentfulDoc = tiptapToContentful(editor.getJSON());
|
|
27733
27807
|
onChange(contentfulDoc);
|
|
27734
27808
|
}
|
|
27735
27809
|
catch (error) {
|
|
@@ -27738,81 +27812,119 @@ const ContentfulRichTextEditor = ({ initialValue, onChange, onEmbedEntry, onEmbe
|
|
|
27738
27812
|
}
|
|
27739
27813
|
},
|
|
27740
27814
|
});
|
|
27741
|
-
|
|
27742
|
-
React.useEffect(() => {
|
|
27815
|
+
React.useEffect(function () {
|
|
27743
27816
|
if (editor && initialValue) {
|
|
27744
|
-
|
|
27817
|
+
var tiptapContent = contentfulToTiptap(initialValue);
|
|
27745
27818
|
editor.commands.setContent(tiptapContent, false);
|
|
27746
27819
|
}
|
|
27747
27820
|
}, [editor, initialValue]);
|
|
27748
|
-
|
|
27821
|
+
var handleEmbedEntry = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
27822
|
+
var entry, error_1;
|
|
27749
27823
|
var _a, _b;
|
|
27750
|
-
|
|
27751
|
-
|
|
27752
|
-
|
|
27753
|
-
|
|
27754
|
-
|
|
27755
|
-
|
|
27756
|
-
|
|
27757
|
-
|
|
27758
|
-
|
|
27759
|
-
|
|
27760
|
-
|
|
27761
|
-
|
|
27762
|
-
|
|
27763
|
-
|
|
27764
|
-
|
|
27765
|
-
|
|
27766
|
-
|
|
27767
|
-
|
|
27824
|
+
return __generator(this, function (_c) {
|
|
27825
|
+
switch (_c.label) {
|
|
27826
|
+
case 0:
|
|
27827
|
+
if (!(onEmbedEntry && editor && editorConfig.allowEmbeddedEntries)) return [3 /*break*/, 4];
|
|
27828
|
+
_c.label = 1;
|
|
27829
|
+
case 1:
|
|
27830
|
+
_c.trys.push([1, 3, , 4]);
|
|
27831
|
+
return [4 /*yield*/, onEmbedEntry()];
|
|
27832
|
+
case 2:
|
|
27833
|
+
entry = _c.sent();
|
|
27834
|
+
if (entry) {
|
|
27835
|
+
editor.chain().focus().insertContent({
|
|
27836
|
+
type: 'paragraph',
|
|
27837
|
+
content: [
|
|
27838
|
+
{
|
|
27839
|
+
type: 'text',
|
|
27840
|
+
text: "[Embedded Entry: ".concat(((_a = entry.sys) === null || _a === void 0 ? void 0 : _a.id) || ((_b = entry.fields) === null || _b === void 0 ? void 0 : _b.title) || 'Unknown', "]"),
|
|
27841
|
+
marks: [{ type: 'bold' }],
|
|
27842
|
+
},
|
|
27843
|
+
],
|
|
27844
|
+
}).run();
|
|
27845
|
+
}
|
|
27846
|
+
return [3 /*break*/, 4];
|
|
27847
|
+
case 3:
|
|
27848
|
+
error_1 = _c.sent();
|
|
27849
|
+
console.error('Error embedding entry:', error_1);
|
|
27850
|
+
return [3 /*break*/, 4];
|
|
27851
|
+
case 4: return [2 /*return*/];
|
|
27768
27852
|
}
|
|
27769
|
-
}
|
|
27770
|
-
}, [onEmbedEntry, editor, editorConfig.allowEmbeddedEntries]);
|
|
27771
|
-
|
|
27853
|
+
});
|
|
27854
|
+
}); }, [onEmbedEntry, editor, editorConfig.allowEmbeddedEntries]);
|
|
27855
|
+
var handleEmbedAsset = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
27856
|
+
var asset, error_2;
|
|
27772
27857
|
var _a, _b;
|
|
27773
|
-
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27778
|
-
|
|
27779
|
-
|
|
27780
|
-
|
|
27781
|
-
|
|
27782
|
-
|
|
27783
|
-
|
|
27784
|
-
|
|
27785
|
-
|
|
27786
|
-
|
|
27787
|
-
|
|
27788
|
-
|
|
27789
|
-
|
|
27790
|
-
|
|
27858
|
+
return __generator(this, function (_c) {
|
|
27859
|
+
switch (_c.label) {
|
|
27860
|
+
case 0:
|
|
27861
|
+
if (!(onEmbedAsset && editor && editorConfig.allowEmbeddedAssets)) return [3 /*break*/, 4];
|
|
27862
|
+
_c.label = 1;
|
|
27863
|
+
case 1:
|
|
27864
|
+
_c.trys.push([1, 3, , 4]);
|
|
27865
|
+
return [4 /*yield*/, onEmbedAsset()];
|
|
27866
|
+
case 2:
|
|
27867
|
+
asset = _c.sent();
|
|
27868
|
+
if (asset) {
|
|
27869
|
+
editor.chain().focus().insertContent({
|
|
27870
|
+
type: 'paragraph',
|
|
27871
|
+
content: [
|
|
27872
|
+
{
|
|
27873
|
+
type: 'text',
|
|
27874
|
+
text: "[Embedded Asset: ".concat(((_a = asset.sys) === null || _a === void 0 ? void 0 : _a.id) || ((_b = asset.fields) === null || _b === void 0 ? void 0 : _b.title) || 'Unknown', "]"),
|
|
27875
|
+
marks: [{ type: 'bold' }],
|
|
27876
|
+
},
|
|
27877
|
+
],
|
|
27878
|
+
}).run();
|
|
27879
|
+
}
|
|
27880
|
+
return [3 /*break*/, 4];
|
|
27881
|
+
case 3:
|
|
27882
|
+
error_2 = _c.sent();
|
|
27883
|
+
console.error('Error embedding asset:', error_2);
|
|
27884
|
+
return [3 /*break*/, 4];
|
|
27885
|
+
case 4: return [2 /*return*/];
|
|
27791
27886
|
}
|
|
27792
|
-
}
|
|
27793
|
-
}, [onEmbedAsset, editor, editorConfig.allowEmbeddedAssets]);
|
|
27794
|
-
|
|
27887
|
+
});
|
|
27888
|
+
}); }, [onEmbedAsset, editor, editorConfig.allowEmbeddedAssets]);
|
|
27889
|
+
var handleEmbedInlineEntry = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
27890
|
+
var entry, error_3;
|
|
27795
27891
|
var _a, _b;
|
|
27796
|
-
|
|
27797
|
-
|
|
27798
|
-
|
|
27799
|
-
|
|
27800
|
-
|
|
27801
|
-
|
|
27802
|
-
|
|
27803
|
-
|
|
27804
|
-
|
|
27805
|
-
|
|
27806
|
-
|
|
27807
|
-
|
|
27808
|
-
|
|
27892
|
+
return __generator(this, function (_c) {
|
|
27893
|
+
switch (_c.label) {
|
|
27894
|
+
case 0:
|
|
27895
|
+
if (!(onEmbedInlineEntry && editor && editorConfig.allowInlineEntries)) return [3 /*break*/, 4];
|
|
27896
|
+
_c.label = 1;
|
|
27897
|
+
case 1:
|
|
27898
|
+
_c.trys.push([1, 3, , 4]);
|
|
27899
|
+
return [4 /*yield*/, onEmbedInlineEntry()];
|
|
27900
|
+
case 2:
|
|
27901
|
+
entry = _c.sent();
|
|
27902
|
+
if (entry) {
|
|
27903
|
+
editor.chain().focus().insertContent({
|
|
27904
|
+
type: 'text',
|
|
27905
|
+
text: "[Inline Entry: ".concat(((_a = entry.sys) === null || _a === void 0 ? void 0 : _a.id) || ((_b = entry.fields) === null || _b === void 0 ? void 0 : _b.title) || 'Unknown', "]"),
|
|
27906
|
+
marks: [{ type: 'bold' }],
|
|
27907
|
+
}).run();
|
|
27908
|
+
}
|
|
27909
|
+
return [3 /*break*/, 4];
|
|
27910
|
+
case 3:
|
|
27911
|
+
error_3 = _c.sent();
|
|
27912
|
+
console.error('Error embedding inline entry:', error_3);
|
|
27913
|
+
return [3 /*break*/, 4];
|
|
27914
|
+
case 4: return [2 /*return*/];
|
|
27809
27915
|
}
|
|
27810
|
-
}
|
|
27811
|
-
}, [onEmbedInlineEntry, editor, editorConfig.allowInlineEntries]);
|
|
27916
|
+
});
|
|
27917
|
+
}); }, [onEmbedInlineEntry, editor, editorConfig.allowInlineEntries]);
|
|
27918
|
+
var editorClass = [
|
|
27919
|
+
'contentful-editor',
|
|
27920
|
+
"contentful-editor--".concat(theme),
|
|
27921
|
+
!showBorder ? 'contentful-editor--borderless' : '',
|
|
27922
|
+
className,
|
|
27923
|
+
].filter(Boolean).join(' ');
|
|
27812
27924
|
if (!editor) {
|
|
27813
|
-
return (jsxRuntime.jsx("div", { className:
|
|
27925
|
+
return (jsxRuntime.jsx("div", { className: "contentful-editor contentful-editor--loading ".concat(className), children: jsxRuntime.jsx("div", { className: "contentful-editor__loading", children: "Loading editor..." }) }));
|
|
27814
27926
|
}
|
|
27815
|
-
return (jsxRuntime.jsxs("div", { className:
|
|
27927
|
+
return (jsxRuntime.jsxs("div", { className: editorClass, children: [!readonly && (jsxRuntime.jsx(ContentfulToolbar, { editor: editor, onEmbedEntry: editorConfig.allowEmbeddedEntries ? handleEmbedEntry : undefined, onEmbedAsset: editorConfig.allowEmbeddedAssets ? handleEmbedAsset : undefined, onEmbedInlineEntry: editorConfig.allowInlineEntries ? handleEmbedInlineEntry : undefined, disabledFeatures: editorConfig.disabledFeatures, availableHeadings: editorConfig.availableHeadings, availableMarks: editorConfig.availableMarks, allowHyperlinks: editorConfig.allowHyperlinks })), jsxRuntime.jsx("div", { className: "contentful-editor__content-wrapper", children: jsxRuntime.jsx(EditorContent, { editor: editor, className: "contentful-editor__content", "data-testid": "editor-content" }) })] }));
|
|
27816
27928
|
};
|
|
27817
27929
|
|
|
27818
27930
|
exports.BLOCKS = distExports.BLOCKS;
|