@vonaffenfels/slate-editor 1.1.71 → 1.2.10

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.
Files changed (96) hide show
  1. package/.babelrc +43 -43
  2. package/README.md +5 -5
  3. package/componentLoader.js +93 -93
  4. package/dist/BlockEditor.css +4 -1871
  5. package/dist/BlockEditor.js +336 -3960
  6. package/dist/BlockEditor.js.LICENSE.txt +61 -0
  7. package/dist/Renderer.js +2 -2081
  8. package/dist/Renderer.js.LICENSE.txt +15 -0
  9. package/dist/fromHTML.js +1 -78
  10. package/dist/index.css +4 -1871
  11. package/dist/index.js +336 -4037
  12. package/dist/index.js.LICENSE.txt +69 -0
  13. package/dist/toHTML.js +2 -1689
  14. package/dist/toHTML.js.LICENSE.txt +23 -0
  15. package/dist/toText.js +2 -1689
  16. package/dist/toText.js.LICENSE.txt +23 -0
  17. package/package.json +2 -2
  18. package/postcss.config.js +6 -6
  19. package/scss/demo.scss +148 -148
  20. package/scss/editor.scss +17 -5
  21. package/scss/sidebarEditor.scss +185 -181
  22. package/scss/toolbar.scss +161 -161
  23. package/src/BlockEditor.js +6 -3
  24. package/src/Blocks/EmptyBlock.js +11 -11
  25. package/src/Blocks/EmptyWrapper.js +4 -4
  26. package/src/Blocks/ErrorBoundary.js +40 -40
  27. package/src/Blocks/LayoutBlock.js +274 -274
  28. package/src/Blocks/LayoutSlot.js +90 -90
  29. package/src/CollapsableMenu/CollapsableMenu.js +48 -48
  30. package/src/Context/StorybookContext.js +6 -6
  31. package/src/ElementAutocomplete.js +133 -133
  32. package/src/Loader.js +137 -137
  33. package/src/Nodes/Default.js +158 -158
  34. package/src/Nodes/Leaf.js +54 -54
  35. package/src/Nodes/Text.js +97 -97
  36. package/src/ObjectId.js +3 -3
  37. package/src/Renderer.js +73 -73
  38. package/src/Serializer/Html.js +42 -42
  39. package/src/Serializer/Serializer.js +371 -371
  40. package/src/Serializer/Text.js +17 -17
  41. package/src/Serializer/ads.js +174 -174
  42. package/src/Serializer/index.js +3 -3
  43. package/src/SidebarEditor/AssetList.js +181 -181
  44. package/src/SidebarEditor/Fields/CloudinaryContentSelect.js +89 -89
  45. package/src/SidebarEditor/Fields/ColorPicker.js +89 -89
  46. package/src/SidebarEditor/Fields/ContentfulContentSelect.js +62 -62
  47. package/src/SidebarEditor/Fields/DateTime.js +55 -55
  48. package/src/SidebarEditor/Fields/MVP.js +66 -66
  49. package/src/SidebarEditor/Fields/MultiSelect.js +13 -13
  50. package/src/SidebarEditor/Fields/RemoteMultiSelect.js +40 -40
  51. package/src/SidebarEditor/Fields/RemoteSelect.js +39 -39
  52. package/src/SidebarEditor/Fields/Select.js +47 -47
  53. package/src/SidebarEditor/Fields/StreamSelect.js +15 -15
  54. package/src/SidebarEditor/Fields/Switch.js +34 -34
  55. package/src/SidebarEditor/Fields/Textarea.js +21 -21
  56. package/src/SidebarEditor/Resizable.js +85 -85
  57. package/src/Storybook.js +151 -151
  58. package/src/Toolbar/Align.js +64 -64
  59. package/src/Toolbar/Anchor.js +94 -94
  60. package/src/Toolbar/Block.js +135 -135
  61. package/src/Toolbar/Element.js +44 -44
  62. package/src/Toolbar/Formats.js +71 -71
  63. package/src/Toolbar/Insert.js +28 -28
  64. package/src/Toolbar/Layout.js +399 -399
  65. package/src/Toolbar/Link.js +164 -164
  66. package/src/Toolbar/Toolbar.js +235 -235
  67. package/src/Tools/Margin.js +51 -51
  68. package/src/Translation/TranslationToolbarButton.js +119 -115
  69. package/src/dev/draftToSlate.json +3147 -3147
  70. package/src/dev/index.css +2 -2
  71. package/src/dev/index.html +10 -10
  72. package/src/dev/index.js +4 -4
  73. package/src/dev/sampleValue1.json +4294 -4294
  74. package/src/dev/sampleValueValid.json +410 -410
  75. package/src/dev/testComponents/TestStory.js +74 -74
  76. package/src/dev/testComponents/TestStory.stories.js +216 -216
  77. package/src/dev/testComponents/TestStory2.js +74 -74
  78. package/src/dev/testComponents/TestStory2.stories.js +197 -197
  79. package/src/dev/testComponents/TestStory3.js +74 -74
  80. package/src/dev/testComponents/TestStory3.stories.js +197 -197
  81. package/src/dev/testSampleValue.json +746 -746
  82. package/src/fromHTML.js +4 -4
  83. package/src/helper/array.js +8 -8
  84. package/src/index.js +10 -10
  85. package/src/plugins/ListItem.js +48 -48
  86. package/src/plugins/SoftBreak.js +23 -23
  87. package/src/toHTML.js +6 -6
  88. package/src/toText.js +6 -6
  89. package/src/util/reduceContentfulResponse.js +64 -64
  90. package/src/util.js +19 -19
  91. package/storyLoader.js +47 -47
  92. package/tailwind.config.js +4 -4
  93. package/webpack.config.build.js +55 -55
  94. package/webpack.config.dev.js +60 -60
  95. package/webpack.config.js +130 -130
  96. package/webpack.config.watch.js +4 -4
package/src/Loader.js CHANGED
@@ -1,138 +1,138 @@
1
- export const Loader = ({
2
- width = "240px",
3
- height = "240px",
4
- }) => {
5
- return <svg
6
- style={{
7
- margin: "auto",
8
- background: "none",
9
- display: "block",
10
- shapeRendering: "auto",
11
- }}
12
- width={width}
13
- height={height}
14
- viewBox="0 0 100 100"
15
- preserveAspectRatio="xMidYMid">
16
- <g transform="rotate(0 50 50)">
17
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
18
- <animate
19
- attributeName="opacity"
20
- values="1;0"
21
- keyTimes="0;1"
22
- dur="0.9174311926605504s"
23
- begin="-0.8340283569641368s"
24
- repeatCount="indefinite" />
25
- </rect>
26
- </g>
27
- <g transform="rotate(32.72727272727273 50 50)">
28
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
29
- <animate
30
- attributeName="opacity"
31
- values="1;0"
32
- keyTimes="0;1"
33
- dur="0.9174311926605504s"
34
- begin="-0.7506255212677231s"
35
- repeatCount="indefinite" />
36
- </rect>
37
- </g>
38
- <g transform="rotate(65.45454545454545 50 50)">
39
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
40
- <animate
41
- attributeName="opacity"
42
- values="1;0"
43
- keyTimes="0;1"
44
- dur="0.9174311926605504s"
45
- begin="-0.6672226855713094s"
46
- repeatCount="indefinite" />
47
- </rect>
48
- </g>
49
- <g transform="rotate(98.18181818181819 50 50)">
50
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
51
- <animate
52
- attributeName="opacity"
53
- values="1;0"
54
- keyTimes="0;1"
55
- dur="0.9174311926605504s"
56
- begin="-0.5838198498748958s"
57
- repeatCount="indefinite" />
58
- </rect>
59
- </g>
60
- <g transform="rotate(130.9090909090909 50 50)">
61
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
62
- <animate
63
- attributeName="opacity"
64
- values="1;0"
65
- keyTimes="0;1"
66
- dur="0.9174311926605504s"
67
- begin="-0.5004170141784821s"
68
- repeatCount="indefinite" />
69
- </rect>
70
- </g>
71
- <g transform="rotate(163.63636363636363 50 50)">
72
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
73
- <animate
74
- attributeName="opacity"
75
- values="1;0"
76
- keyTimes="0;1"
77
- dur="0.9174311926605504s"
78
- begin="-0.4170141784820684s"
79
- repeatCount="indefinite" />
80
- </rect>
81
- </g>
82
- <g transform="rotate(196.36363636363637 50 50)">
83
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
84
- <animate
85
- attributeName="opacity"
86
- values="1;0"
87
- keyTimes="0;1"
88
- dur="0.9174311926605504s"
89
- begin="-0.3336113427856547s"
90
- repeatCount="indefinite" />
91
- </rect>
92
- </g>
93
- <g transform="rotate(229.0909090909091 50 50)">
94
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
95
- <animate
96
- attributeName="opacity"
97
- values="1;0"
98
- keyTimes="0;1"
99
- dur="0.9174311926605504s"
100
- begin="-0.25020850708924103s"
101
- repeatCount="indefinite" />
102
- </rect>
103
- </g>
104
- <g transform="rotate(261.8181818181818 50 50)">
105
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
106
- <animate
107
- attributeName="opacity"
108
- values="1;0"
109
- keyTimes="0;1"
110
- dur="0.9174311926605504s"
111
- begin="-0.16680567139282734s"
112
- repeatCount="indefinite" />
113
- </rect>
114
- </g>
115
- <g transform="rotate(294.54545454545456 50 50)">
116
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
117
- <animate
118
- attributeName="opacity"
119
- values="1;0"
120
- keyTimes="0;1"
121
- dur="0.9174311926605504s"
122
- begin="-0.08340283569641367s"
123
- repeatCount="indefinite" />
124
- </rect>
125
- </g>
126
- <g transform="rotate(327.27272727272725 50 50)">
127
- <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
128
- <animate
129
- attributeName="opacity"
130
- values="1;0"
131
- keyTimes="0;1"
132
- dur="0.9174311926605504s"
133
- begin="0s"
134
- repeatCount="indefinite" />
135
- </rect>
136
- </g>
137
- </svg>;
1
+ export const Loader = ({
2
+ width = "240px",
3
+ height = "240px",
4
+ }) => {
5
+ return <svg
6
+ style={{
7
+ margin: "auto",
8
+ background: "none",
9
+ display: "block",
10
+ shapeRendering: "auto",
11
+ }}
12
+ width={width}
13
+ height={height}
14
+ viewBox="0 0 100 100"
15
+ preserveAspectRatio="xMidYMid">
16
+ <g transform="rotate(0 50 50)">
17
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
18
+ <animate
19
+ attributeName="opacity"
20
+ values="1;0"
21
+ keyTimes="0;1"
22
+ dur="0.9174311926605504s"
23
+ begin="-0.8340283569641368s"
24
+ repeatCount="indefinite" />
25
+ </rect>
26
+ </g>
27
+ <g transform="rotate(32.72727272727273 50 50)">
28
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
29
+ <animate
30
+ attributeName="opacity"
31
+ values="1;0"
32
+ keyTimes="0;1"
33
+ dur="0.9174311926605504s"
34
+ begin="-0.7506255212677231s"
35
+ repeatCount="indefinite" />
36
+ </rect>
37
+ </g>
38
+ <g transform="rotate(65.45454545454545 50 50)">
39
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
40
+ <animate
41
+ attributeName="opacity"
42
+ values="1;0"
43
+ keyTimes="0;1"
44
+ dur="0.9174311926605504s"
45
+ begin="-0.6672226855713094s"
46
+ repeatCount="indefinite" />
47
+ </rect>
48
+ </g>
49
+ <g transform="rotate(98.18181818181819 50 50)">
50
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
51
+ <animate
52
+ attributeName="opacity"
53
+ values="1;0"
54
+ keyTimes="0;1"
55
+ dur="0.9174311926605504s"
56
+ begin="-0.5838198498748958s"
57
+ repeatCount="indefinite" />
58
+ </rect>
59
+ </g>
60
+ <g transform="rotate(130.9090909090909 50 50)">
61
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
62
+ <animate
63
+ attributeName="opacity"
64
+ values="1;0"
65
+ keyTimes="0;1"
66
+ dur="0.9174311926605504s"
67
+ begin="-0.5004170141784821s"
68
+ repeatCount="indefinite" />
69
+ </rect>
70
+ </g>
71
+ <g transform="rotate(163.63636363636363 50 50)">
72
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
73
+ <animate
74
+ attributeName="opacity"
75
+ values="1;0"
76
+ keyTimes="0;1"
77
+ dur="0.9174311926605504s"
78
+ begin="-0.4170141784820684s"
79
+ repeatCount="indefinite" />
80
+ </rect>
81
+ </g>
82
+ <g transform="rotate(196.36363636363637 50 50)">
83
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
84
+ <animate
85
+ attributeName="opacity"
86
+ values="1;0"
87
+ keyTimes="0;1"
88
+ dur="0.9174311926605504s"
89
+ begin="-0.3336113427856547s"
90
+ repeatCount="indefinite" />
91
+ </rect>
92
+ </g>
93
+ <g transform="rotate(229.0909090909091 50 50)">
94
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
95
+ <animate
96
+ attributeName="opacity"
97
+ values="1;0"
98
+ keyTimes="0;1"
99
+ dur="0.9174311926605504s"
100
+ begin="-0.25020850708924103s"
101
+ repeatCount="indefinite" />
102
+ </rect>
103
+ </g>
104
+ <g transform="rotate(261.8181818181818 50 50)">
105
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
106
+ <animate
107
+ attributeName="opacity"
108
+ values="1;0"
109
+ keyTimes="0;1"
110
+ dur="0.9174311926605504s"
111
+ begin="-0.16680567139282734s"
112
+ repeatCount="indefinite" />
113
+ </rect>
114
+ </g>
115
+ <g transform="rotate(294.54545454545456 50 50)">
116
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
117
+ <animate
118
+ attributeName="opacity"
119
+ values="1;0"
120
+ keyTimes="0;1"
121
+ dur="0.9174311926605504s"
122
+ begin="-0.08340283569641367s"
123
+ repeatCount="indefinite" />
124
+ </rect>
125
+ </g>
126
+ <g transform="rotate(327.27272727272725 50 50)">
127
+ <rect x="46.5" y="17.5" rx="3.5" ry="1.5" width="7" height="3" fill="#000000">
128
+ <animate
129
+ attributeName="opacity"
130
+ values="1;0"
131
+ keyTimes="0;1"
132
+ dur="0.9174311926605504s"
133
+ begin="0s"
134
+ repeatCount="indefinite" />
135
+ </rect>
136
+ </g>
137
+ </svg>;
138
138
  };
@@ -1,159 +1,159 @@
1
- import classNames from "classnames";
2
- import React from "react";
3
-
4
- export const Default = ({
5
- attributes,
6
- elementPropsMap,
7
- specialClassMap,
8
- transformAttributes,
9
- children,
10
- element,
11
- isRenderer,
12
- isInSlot = false,
13
- defaultComponentReplacement,
14
- onElementClick = () => {
15
- },
16
- ...props
17
- }) => {
18
- const getPropsForType = (type) => {
19
- if (!elementPropsMap) {
20
- return {};
21
- }
22
-
23
- if (isInSlot) {
24
- if (elementPropsMap[type + "-in-slot"]) {
25
- return elementPropsMap[type + "-in-slot"];
26
- }
27
- }
28
-
29
- return elementPropsMap[type] || {};
30
- };
31
- const {
32
- type,
33
- align,
34
- } = element;
35
- let elementAttributes = {
36
- ...(element.attributes || {}),
37
- ...getPropsForType(type),
38
- };
39
-
40
- if (typeof transformAttributes === "function") {
41
- elementAttributes = transformAttributes(type, elementAttributes);
42
- }
43
-
44
- let alignedClassname = attributes.className || elementAttributes.className || "";
45
- let Wrapper = elementAttributes.wrapper || function ({children}) {
46
- return <>{children}</>;
47
- };
48
-
49
- if (align) {
50
- if (specialClassMap && specialClassMap[align]) {
51
- alignedClassname += specialClassMap[align];
52
- } else {
53
- alignedClassname += "align-" + align;
54
- }
55
- }
56
-
57
- attributes.onClick = () => onElementClick(element);
58
- attributes.className = alignedClassname.trim() || undefined;
59
-
60
- switch (type) {
61
- case "blockquote":
62
- return <Wrapper type={type}>
63
- <blockquote {...attributes}>{children}</blockquote>
64
- </Wrapper>;
65
- case "list-item":
66
- return <Wrapper type={type}>
67
- <li {...attributes}>{children}</li>
68
- </Wrapper>;
69
- case "unordered-list":
70
- return <Wrapper type={type}>
71
- <ul {...attributes}>{children}</ul>
72
- </Wrapper>;
73
- case "ordered-list":
74
- return <Wrapper type={type}>
75
- <ol {...attributes}>{children}</ol>
76
- </Wrapper>;
77
- case "arrow-list":
78
- return <Wrapper type={type}>
79
- <ul
80
- {...attributes}
81
- className={classNames("arrow-list", attributes.className)}>{children}</ul>
82
- </Wrapper>;
83
- case "code":
84
- if (isRenderer) {
85
- return <Wrapper code={element?.attributes?.code} type={type}/>;
86
- } else {
87
- return <Wrapper type={type}>
88
- <div {...attributes} >
89
- <div dangerouslySetInnerHTML={{__html: element?.attributes?.code}}/>
90
- </div>
91
- </Wrapper>;
92
- }
93
- case "heading": {
94
- const HeadingTag = `h${element.attributes.level || 1}`;
95
- return <Wrapper level={element.attributes.level} type={type}>
96
- <HeadingTag
97
- {...attributes}
98
- id={element?.attributes?.id || undefined}
99
- >
100
- {children}
101
- </HeadingTag>
102
- </Wrapper>;
103
- }
104
- case "link": {
105
- let relProp = `noopener noreferrer`;
106
- let {
107
- noFollow,
108
- nofollow,
109
- ...linkAttributes
110
- } = elementAttributes;
111
-
112
- const nofollowProp = noFollow || nofollow;
113
-
114
- if (nofollowProp) {
115
- relProp += " nofollow";
116
- }
117
-
118
- let CustomLink = typeof defaultComponentReplacement === "function" ? defaultComponentReplacement(type) : null;
119
-
120
- if (CustomLink) {
121
- return <Wrapper type={type}><CustomLink
122
- {...linkAttributes}
123
- {...attributes}
124
- rel={relProp}
125
- className={alignedClassname.trim()}>{children}</CustomLink></Wrapper>;
126
- } else {
127
- return <Wrapper type={type}><a
128
- {...linkAttributes}
129
- {...attributes}
130
- rel={relProp}
131
- className={alignedClassname.trim()}>{children}</a></Wrapper>;
132
- }
133
- }
134
- case "paragraph":
135
- return <Wrapper type={type}><p
136
- {...element.attributes}
137
- {...attributes}
138
- className={alignedClassname.trim()}>{children}</p></Wrapper>;
139
- case "divider":
140
- return <Wrapper type={type}>
141
- <hr {...attributes} />
142
- {children}
143
- </Wrapper>;
144
- case "div":
145
- return <Wrapper type={type}>
146
- <div {...element.attributes} {...attributes}>{children}</div>
147
- </Wrapper>;
148
- case "span":
149
- return <Wrapper type={type}>
150
- <span {...element.attributes} {...attributes}>{children}</span>
151
- </Wrapper>;
152
- default:
153
- if (isRenderer) {
154
- return <Wrapper type={type}>{children}</Wrapper>;
155
- } else {
156
- return <span {...attributes} className={alignedClassname.trim()}>{children}</span>;
157
- }
158
- }
1
+ import classNames from "classnames";
2
+ import React from "react";
3
+
4
+ export const Default = ({
5
+ attributes,
6
+ elementPropsMap,
7
+ specialClassMap,
8
+ transformAttributes,
9
+ children,
10
+ element,
11
+ isRenderer,
12
+ isInSlot = false,
13
+ defaultComponentReplacement,
14
+ onElementClick = () => {
15
+ },
16
+ ...props
17
+ }) => {
18
+ const getPropsForType = (type) => {
19
+ if (!elementPropsMap) {
20
+ return {};
21
+ }
22
+
23
+ if (isInSlot) {
24
+ if (elementPropsMap[type + "-in-slot"]) {
25
+ return elementPropsMap[type + "-in-slot"];
26
+ }
27
+ }
28
+
29
+ return elementPropsMap[type] || {};
30
+ };
31
+ const {
32
+ type,
33
+ align,
34
+ } = element;
35
+ let elementAttributes = {
36
+ ...(element.attributes || {}),
37
+ ...getPropsForType(type),
38
+ };
39
+
40
+ if (typeof transformAttributes === "function") {
41
+ elementAttributes = transformAttributes(type, elementAttributes);
42
+ }
43
+
44
+ let alignedClassname = attributes.className || elementAttributes.className || "";
45
+ let Wrapper = elementAttributes.wrapper || function ({children}) {
46
+ return <>{children}</>;
47
+ };
48
+
49
+ if (align) {
50
+ if (specialClassMap && specialClassMap[align]) {
51
+ alignedClassname += specialClassMap[align];
52
+ } else {
53
+ alignedClassname += "align-" + align;
54
+ }
55
+ }
56
+
57
+ attributes.onClick = () => onElementClick(element);
58
+ attributes.className = alignedClassname.trim() || undefined;
59
+
60
+ switch (type) {
61
+ case "blockquote":
62
+ return <Wrapper type={type}>
63
+ <blockquote {...attributes}>{children}</blockquote>
64
+ </Wrapper>;
65
+ case "list-item":
66
+ return <Wrapper type={type}>
67
+ <li {...attributes}>{children}</li>
68
+ </Wrapper>;
69
+ case "unordered-list":
70
+ return <Wrapper type={type}>
71
+ <ul {...attributes}>{children}</ul>
72
+ </Wrapper>;
73
+ case "ordered-list":
74
+ return <Wrapper type={type}>
75
+ <ol {...attributes}>{children}</ol>
76
+ </Wrapper>;
77
+ case "arrow-list":
78
+ return <Wrapper type={type}>
79
+ <ul
80
+ {...attributes}
81
+ className={classNames("arrow-list", attributes.className)}>{children}</ul>
82
+ </Wrapper>;
83
+ case "code":
84
+ if (isRenderer) {
85
+ return <Wrapper code={element?.attributes?.code} type={type}/>;
86
+ } else {
87
+ return <Wrapper type={type}>
88
+ <div {...attributes} >
89
+ <div dangerouslySetInnerHTML={{__html: element?.attributes?.code}}/>
90
+ </div>
91
+ </Wrapper>;
92
+ }
93
+ case "heading": {
94
+ const HeadingTag = `h${element.attributes.level || 1}`;
95
+ return <Wrapper level={element.attributes.level} type={type}>
96
+ <HeadingTag
97
+ {...attributes}
98
+ id={element?.attributes?.id || undefined}
99
+ >
100
+ {children}
101
+ </HeadingTag>
102
+ </Wrapper>;
103
+ }
104
+ case "link": {
105
+ let relProp = `noopener noreferrer`;
106
+ let {
107
+ noFollow,
108
+ nofollow,
109
+ ...linkAttributes
110
+ } = elementAttributes;
111
+
112
+ const nofollowProp = noFollow || nofollow;
113
+
114
+ if (nofollowProp) {
115
+ relProp += " nofollow";
116
+ }
117
+
118
+ let CustomLink = typeof defaultComponentReplacement === "function" ? defaultComponentReplacement(type) : null;
119
+
120
+ if (CustomLink) {
121
+ return <Wrapper type={type}><CustomLink
122
+ {...linkAttributes}
123
+ {...attributes}
124
+ rel={relProp}
125
+ className={alignedClassname.trim()}>{children}</CustomLink></Wrapper>;
126
+ } else {
127
+ return <Wrapper type={type}><a
128
+ {...linkAttributes}
129
+ {...attributes}
130
+ rel={relProp}
131
+ className={alignedClassname.trim()}>{children}</a></Wrapper>;
132
+ }
133
+ }
134
+ case "paragraph":
135
+ return <Wrapper type={type}><p
136
+ {...element.attributes}
137
+ {...attributes}
138
+ className={alignedClassname.trim()}>{children}</p></Wrapper>;
139
+ case "divider":
140
+ return <Wrapper type={type}>
141
+ <hr {...attributes} />
142
+ {children}
143
+ </Wrapper>;
144
+ case "div":
145
+ return <Wrapper type={type}>
146
+ <div {...element.attributes} {...attributes}>{children}</div>
147
+ </Wrapper>;
148
+ case "span":
149
+ return <Wrapper type={type}>
150
+ <span {...element.attributes} {...attributes}>{children}</span>
151
+ </Wrapper>;
152
+ default:
153
+ if (isRenderer) {
154
+ return <Wrapper type={type}>{children}</Wrapper>;
155
+ } else {
156
+ return <span {...attributes} className={alignedClassname.trim()}>{children}</span>;
157
+ }
158
+ }
159
159
  };