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