@contentful/field-editor-markdown 1.9.6 → 1.10.0
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/cjs/MarkdownEditor.js +12 -12
- package/dist/cjs/components/HeadingSelector.js +3 -3
- package/dist/cjs/components/InsertLinkSelector.js +9 -9
- package/dist/cjs/components/MarkdownBottomBar.js +10 -10
- package/dist/cjs/components/MarkdownConstraints.js +3 -3
- package/dist/cjs/components/MarkdownPreview.js +6 -6
- package/dist/cjs/components/MarkdownPreviewSkeleton.js +2 -2
- package/dist/cjs/components/MarkdownTabs.js +4 -4
- package/dist/cjs/components/MarkdownTextarea/MarkdownTextarea.js +2 -2
- package/dist/cjs/components/MarkdownToolbar.js +59 -59
- package/dist/cjs/components/icons.js +30 -30
- package/dist/cjs/dialogs/CheatsheetModalDialog.js +45 -45
- package/dist/cjs/dialogs/ConfirmInsertAssetModalDialog.js +4 -4
- package/dist/cjs/dialogs/EmdebExternalContentDialog.js +15 -15
- package/dist/cjs/dialogs/InsertLinkModalDialog.js +10 -10
- package/dist/cjs/dialogs/InsertTableModalDialog.js +7 -7
- package/dist/cjs/dialogs/SpecialCharacterModalDialog.js +10 -10
- package/dist/cjs/dialogs/ZenModeModalDialog.js +17 -17
- package/dist/cjs/dialogs/openMarkdownDialog.js +7 -7
- package/dist/cjs/dialogs/renderMarkdownDialog.js +8 -8
- package/dist/cjs/types.js +3 -3
- package/dist/esm/MarkdownEditor.js +12 -12
- package/dist/esm/components/HeadingSelector.js +3 -3
- package/dist/esm/components/InsertLinkSelector.js +9 -9
- package/dist/esm/components/MarkdownBottomBar.js +10 -10
- package/dist/esm/components/MarkdownConstraints.js +3 -3
- package/dist/esm/components/MarkdownPreview.js +6 -6
- package/dist/esm/components/MarkdownPreviewSkeleton.js +2 -2
- package/dist/esm/components/MarkdownTabs.js +4 -4
- package/dist/esm/components/MarkdownTextarea/MarkdownTextarea.js +2 -2
- package/dist/esm/components/MarkdownToolbar.js +59 -59
- package/dist/esm/components/icons.js +30 -30
- package/dist/esm/dialogs/CheatsheetModalDialog.js +45 -45
- package/dist/esm/dialogs/ConfirmInsertAssetModalDialog.js +4 -4
- package/dist/esm/dialogs/EmdebExternalContentDialog.js +15 -15
- package/dist/esm/dialogs/InsertLinkModalDialog.js +10 -10
- package/dist/esm/dialogs/InsertTableModalDialog.js +7 -7
- package/dist/esm/dialogs/SpecialCharacterModalDialog.js +10 -10
- package/dist/esm/dialogs/ZenModeModalDialog.js +17 -17
- package/dist/esm/dialogs/openMarkdownDialog.js +7 -7
- package/dist/esm/dialogs/renderMarkdownDialog.js +8 -8
- package/dist/esm/types.js +3 -3
- package/package.json +6 -4
|
@@ -74,7 +74,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
74
74
|
}
|
|
75
75
|
return newObj;
|
|
76
76
|
}
|
|
77
|
-
const MarkdownPreview = _react.lazy(()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./components/MarkdownPreview"))));
|
|
77
|
+
const MarkdownPreview = /*#__PURE__*/ _react.lazy(()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./components/MarkdownPreview"))));
|
|
78
78
|
const styles = {
|
|
79
79
|
container: (0, _emotion.css)({
|
|
80
80
|
display: 'flex',
|
|
@@ -142,22 +142,22 @@ function MarkdownEditor(props) {
|
|
|
142
142
|
const openMarkdownHelp = _react.useCallback(()=>{
|
|
143
143
|
(0, _CheatsheetModalDialog.openCheatsheetModal)(props.sdk.dialogs);
|
|
144
144
|
}, []);
|
|
145
|
-
return _react.createElement("div", {
|
|
145
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
146
146
|
className: styles.container,
|
|
147
147
|
"data-test-id": "markdown-editor"
|
|
148
|
-
}, _react.createElement(_MarkdownTabs.MarkdownTabs, {
|
|
148
|
+
}, /*#__PURE__*/ _react.createElement(_MarkdownTabs.MarkdownTabs, {
|
|
149
149
|
active: selectedTab,
|
|
150
150
|
onSelect: (tab)=>{
|
|
151
151
|
if (props.enableTab) return;
|
|
152
152
|
setSelectedTab(tab);
|
|
153
153
|
},
|
|
154
154
|
enableTab: props.enableTab
|
|
155
|
-
}), _react.createElement(_MarkdownToolbar.MarkdownToolbar, {
|
|
155
|
+
}), /*#__PURE__*/ _react.createElement(_MarkdownToolbar.MarkdownToolbar, {
|
|
156
156
|
mode: "default",
|
|
157
157
|
disabled: isActionDisabled,
|
|
158
158
|
canUploadAssets: canUploadAssets,
|
|
159
159
|
actions: actions
|
|
160
|
-
}), _react.createElement(_MarkdownTextarea.MarkdownTextarea, {
|
|
160
|
+
}), /*#__PURE__*/ _react.createElement(_MarkdownTextarea.MarkdownTextarea, {
|
|
161
161
|
minHeight: props.minHeight,
|
|
162
162
|
mode: "default",
|
|
163
163
|
visible: selectedTab === 'editor',
|
|
@@ -173,29 +173,29 @@ function MarkdownEditor(props) {
|
|
|
173
173
|
setCurrentValue(value);
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
-
}), selectedTab === 'preview' && _react.createElement(_react.Suspense, {
|
|
177
|
-
fallback: _react.createElement(_MarkdownPreviewSkeleton.default, null)
|
|
178
|
-
}, _react.createElement(MarkdownPreview, {
|
|
176
|
+
}), selectedTab === 'preview' && /*#__PURE__*/ _react.createElement(_react.Suspense, {
|
|
177
|
+
fallback: /*#__PURE__*/ _react.createElement(_MarkdownPreviewSkeleton.default, null)
|
|
178
|
+
}, /*#__PURE__*/ _react.createElement(MarkdownPreview, {
|
|
179
179
|
direction: direction,
|
|
180
180
|
minHeight: props.minHeight,
|
|
181
181
|
mode: "default",
|
|
182
182
|
value: currentValue,
|
|
183
183
|
previewComponents: props.previewComponents
|
|
184
|
-
})), _react.createElement(_MarkdownBottomBar.MarkdownBottomBar, null, _react.createElement(_MarkdownBottomBar.MarkdownHelp, {
|
|
184
|
+
})), /*#__PURE__*/ _react.createElement(_MarkdownBottomBar.MarkdownBottomBar, null, /*#__PURE__*/ _react.createElement(_MarkdownBottomBar.MarkdownHelp, {
|
|
185
185
|
mode: selectedTab,
|
|
186
186
|
onClick: openMarkdownHelp
|
|
187
|
-
})), _react.createElement(_MarkdownConstraints.MarkdownConstraints, {
|
|
187
|
+
})), /*#__PURE__*/ _react.createElement(_MarkdownConstraints.MarkdownConstraints, {
|
|
188
188
|
sdk: props.sdk,
|
|
189
189
|
value: currentValue
|
|
190
190
|
}));
|
|
191
191
|
}
|
|
192
192
|
function MarkdownEditorConnected(props) {
|
|
193
|
-
return _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
193
|
+
return /*#__PURE__*/ _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
194
194
|
debounce: 300,
|
|
195
195
|
field: props.sdk.field,
|
|
196
196
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
197
197
|
isDisabled: props.isDisabled
|
|
198
|
-
}, ({ value, disabled, setValue, externalReset })
|
|
198
|
+
}, ({ value, disabled, setValue, externalReset })=>/*#__PURE__*/ _react.createElement(MarkdownEditor, {
|
|
199
199
|
...props,
|
|
200
200
|
value: value,
|
|
201
201
|
isDisabled: disabled,
|
|
@@ -55,13 +55,13 @@ const HeadingSelector = (props)=>{
|
|
|
55
55
|
const handleMenuClick = (heading)=>{
|
|
56
56
|
props.onSelect(heading);
|
|
57
57
|
};
|
|
58
|
-
return _react.createElement(_f36components.Menu, null, _react.createElement(_f36components.Menu.Trigger, null, props.children), _react.createElement(_f36components.Menu.List, null, _react.createElement(_f36components.Menu.Item, {
|
|
58
|
+
return /*#__PURE__*/ _react.createElement(_f36components.Menu, null, /*#__PURE__*/ _react.createElement(_f36components.Menu.Trigger, null, props.children), /*#__PURE__*/ _react.createElement(_f36components.Menu.List, null, /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
59
59
|
testId: "markdown-action-button-heading-h1",
|
|
60
60
|
onClick: ()=>handleMenuClick('h1')
|
|
61
|
-
}, "Heading 1"), _react.createElement(_f36components.Menu.Item, {
|
|
61
|
+
}, "Heading 1"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
62
62
|
testId: "markdown-action-button-heading-h2",
|
|
63
63
|
onClick: ()=>handleMenuClick('h2')
|
|
64
|
-
}, "Heading 2"), _react.createElement(_f36components.Menu.Item, {
|
|
64
|
+
}, "Heading 2"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
65
65
|
testId: "markdown-action-button-heading-h3",
|
|
66
66
|
onClick: ()=>handleMenuClick('h3')
|
|
67
67
|
}, "Heading 3")));
|
|
@@ -54,11 +54,11 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
54
54
|
}
|
|
55
55
|
const InsertLinkSelector = (props)=>{
|
|
56
56
|
if (props.canAddNew) {
|
|
57
|
-
return _react.createElement(MultipleMediaContextMenu, props);
|
|
57
|
+
return /*#__PURE__*/ _react.createElement(MultipleMediaContextMenu, props);
|
|
58
58
|
} else {
|
|
59
|
-
return _react.createElement(_f36components.Button, {
|
|
59
|
+
return /*#__PURE__*/ _react.createElement(_f36components.Button, {
|
|
60
60
|
isDisabled: props.disabled,
|
|
61
|
-
startIcon: _react.createElement(_f36icons.AssetIcon, null),
|
|
61
|
+
startIcon: /*#__PURE__*/ _react.createElement(_f36icons.AssetIcon, null),
|
|
62
62
|
testId: "markdownEditor.linkExistingAssets",
|
|
63
63
|
size: "small",
|
|
64
64
|
variant: "secondary",
|
|
@@ -69,19 +69,19 @@ const InsertLinkSelector = (props)=>{
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
const MultipleMediaContextMenu = (props)=>{
|
|
72
|
-
return _react.createElement(_f36components.Menu, {
|
|
72
|
+
return /*#__PURE__*/ _react.createElement(_f36components.Menu, {
|
|
73
73
|
placement: "bottom-end"
|
|
74
|
-
}, _react.createElement(_f36components.Menu.Trigger, null, _react.createElement(_f36components.Button, {
|
|
75
|
-
endIcon: _react.createElement(_f36icons.ChevronDownIcon, null),
|
|
74
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Menu.Trigger, null, /*#__PURE__*/ _react.createElement(_f36components.Button, {
|
|
75
|
+
endIcon: /*#__PURE__*/ _react.createElement(_f36icons.ChevronDownIcon, null),
|
|
76
76
|
isDisabled: props.disabled,
|
|
77
|
-
startIcon: _react.createElement(_f36icons.AssetIcon, null),
|
|
77
|
+
startIcon: /*#__PURE__*/ _react.createElement(_f36icons.AssetIcon, null),
|
|
78
78
|
testId: "markdownEditor.insertMediaDropdownTrigger",
|
|
79
79
|
size: "small",
|
|
80
80
|
variant: "secondary"
|
|
81
|
-
}, "Insert media")), _react.createElement(_f36components.Menu.List, null, _react.createElement(_f36components.Menu.Item, {
|
|
81
|
+
}, "Insert media")), /*#__PURE__*/ _react.createElement(_f36components.Menu.List, null, /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
82
82
|
testId: "markdownEditor.uploadAssetsAndLink",
|
|
83
83
|
onClick: ()=>props.onAddNew()
|
|
84
|
-
}, "Add new media and link"), _react.createElement(_f36components.Menu.Item, {
|
|
84
|
+
}, "Add new media and link"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
85
85
|
testId: "markdownEditor.linkExistingAssets",
|
|
86
86
|
onClick: ()=>props.onSelectExisting()
|
|
87
87
|
}, "Link existing media")));
|
|
@@ -90,13 +90,13 @@ const styles = {
|
|
|
90
90
|
})
|
|
91
91
|
};
|
|
92
92
|
function MarkdownCounter(props) {
|
|
93
|
-
return _react.createElement(_f36components.Paragraph, {
|
|
93
|
+
return /*#__PURE__*/ _react.createElement(_f36components.Paragraph, {
|
|
94
94
|
marginBottom: "none",
|
|
95
95
|
className: styles.help
|
|
96
96
|
}, props.words, " ", props.words !== 1 ? 'words' : 'word', ", ", props.characters, ' ', props.characters !== 1 ? 'characters' : 'character');
|
|
97
97
|
}
|
|
98
98
|
function SanitizeMessage() {
|
|
99
|
-
return _react.createElement("span", null, "The preview of the content in this field will be sanitized.", ' ', _react.createElement(_f36components.TextLink, {
|
|
99
|
+
return /*#__PURE__*/ _react.createElement("span", null, "The preview of the content in this field will be sanitized.", ' ', /*#__PURE__*/ _react.createElement(_f36components.TextLink, {
|
|
100
100
|
as: "a",
|
|
101
101
|
target: "_blank",
|
|
102
102
|
rel: "noopener noreferrer",
|
|
@@ -104,7 +104,7 @@ function SanitizeMessage() {
|
|
|
104
104
|
}, "Learn more."));
|
|
105
105
|
}
|
|
106
106
|
function CheatSheetMessage({ onClick }) {
|
|
107
|
-
return _react.createElement("span", null, "Format your text like a pro with the", ' ', _react.createElement(_f36components.TextLink, {
|
|
107
|
+
return /*#__PURE__*/ _react.createElement("span", null, "Format your text like a pro with the", ' ', /*#__PURE__*/ _react.createElement(_f36components.TextLink, {
|
|
108
108
|
as: "button",
|
|
109
109
|
testId: "open-markdown-cheatsheet-button",
|
|
110
110
|
onClick: onClick
|
|
@@ -114,33 +114,33 @@ function MarkdownHelp(props) {
|
|
|
114
114
|
let content;
|
|
115
115
|
switch(props.mode){
|
|
116
116
|
case 'preview':
|
|
117
|
-
content = _react.createElement(SanitizeMessage, null);
|
|
117
|
+
content = /*#__PURE__*/ _react.createElement(SanitizeMessage, null);
|
|
118
118
|
break;
|
|
119
119
|
case 'editor':
|
|
120
|
-
content = _react.createElement(CheatSheetMessage, {
|
|
120
|
+
content = /*#__PURE__*/ _react.createElement(CheatSheetMessage, {
|
|
121
121
|
onClick: props.onClick
|
|
122
122
|
});
|
|
123
123
|
break;
|
|
124
124
|
case 'zen':
|
|
125
|
-
content = _react.createElement(_f36components.Stack, {
|
|
125
|
+
content = /*#__PURE__*/ _react.createElement(_f36components.Stack, {
|
|
126
126
|
flexDirection: "column",
|
|
127
127
|
spacing: "spacing2Xs",
|
|
128
128
|
alignItems: "flex-start"
|
|
129
|
-
}, _react.createElement(CheatSheetMessage, {
|
|
129
|
+
}, /*#__PURE__*/ _react.createElement(CheatSheetMessage, {
|
|
130
130
|
onClick: props.onClick
|
|
131
|
-
}), _react.createElement(SanitizeMessage, null));
|
|
131
|
+
}), /*#__PURE__*/ _react.createElement(SanitizeMessage, null));
|
|
132
132
|
break;
|
|
133
133
|
default:
|
|
134
134
|
content = null;
|
|
135
135
|
throw new Error(`Invalid HelpMode provided in MarkdownHelp: ${props.mode}`);
|
|
136
136
|
}
|
|
137
|
-
return _react.createElement(_f36components.Paragraph, {
|
|
137
|
+
return /*#__PURE__*/ _react.createElement(_f36components.Paragraph, {
|
|
138
138
|
marginBottom: "none",
|
|
139
139
|
className: styles.help
|
|
140
140
|
}, content);
|
|
141
141
|
}
|
|
142
142
|
function MarkdownBottomBar(props) {
|
|
143
|
-
return _react.createElement("div", {
|
|
143
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
144
144
|
className: styles.root
|
|
145
145
|
}, props.children);
|
|
146
146
|
}
|
|
@@ -70,12 +70,12 @@ const styles = {
|
|
|
70
70
|
function MarkdownConstraints(props) {
|
|
71
71
|
const constraints = _fieldeditorshared.ConstraintsUtils.fromFieldValidations(props.sdk.field.validations, props.sdk.field.type);
|
|
72
72
|
const checkConstraint = _fieldeditorshared.ConstraintsUtils.makeChecker(constraints);
|
|
73
|
-
return _react.createElement("div", {
|
|
73
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
74
74
|
className: styles.root
|
|
75
|
-
}, _react.createElement(_fieldeditorshared.CharCounter, {
|
|
75
|
+
}, /*#__PURE__*/ _react.createElement(_fieldeditorshared.CharCounter, {
|
|
76
76
|
value: props.value,
|
|
77
77
|
checkConstraint: checkConstraint
|
|
78
|
-
}), _react.createElement(_fieldeditorshared.CharValidation, {
|
|
78
|
+
}), /*#__PURE__*/ _react.createElement(_fieldeditorshared.CharValidation, {
|
|
79
79
|
constraints: constraints
|
|
80
80
|
}));
|
|
81
81
|
}
|
|
@@ -215,24 +215,24 @@ const styles = {
|
|
|
215
215
|
function MarkdownLink(props) {
|
|
216
216
|
const { Embedly, children, ...rest } = props;
|
|
217
217
|
if (props.className === 'embedly-card' && Embedly) {
|
|
218
|
-
return _react.createElement(Embedly, {
|
|
218
|
+
return /*#__PURE__*/ _react.createElement(Embedly, {
|
|
219
219
|
url: props.href ?? ''
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
-
return _react.createElement("a", {
|
|
222
|
+
return /*#__PURE__*/ _react.createElement("a", {
|
|
223
223
|
...rest,
|
|
224
224
|
target: "_blank",
|
|
225
225
|
rel: "noopener noreferrer"
|
|
226
226
|
}, children);
|
|
227
227
|
}
|
|
228
|
-
const MarkdownPreview = _react.memo((props)=>{
|
|
228
|
+
const MarkdownPreview = /*#__PURE__*/ _react.memo((props)=>{
|
|
229
229
|
const className = (0, _emotion.cx)(props.minHeight !== undefined ? (0, _emotion.css)({
|
|
230
230
|
minHeight: props.minHeight
|
|
231
231
|
}) : undefined, props.mode === 'default' ? styles.framed : styles.zen, props.direction === 'rtl' ? styles.rtl : undefined);
|
|
232
|
-
return _react.createElement("div", {
|
|
232
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
233
233
|
className: className,
|
|
234
234
|
"data-test-id": "markdown-preview"
|
|
235
|
-
}, _react.createElement(_reactmarkdown.default, {
|
|
235
|
+
}, /*#__PURE__*/ _react.createElement(_reactmarkdown.default, {
|
|
236
236
|
className: styles.root,
|
|
237
237
|
rehypePlugins: [
|
|
238
238
|
_rehyperaw.default,
|
|
@@ -245,7 +245,7 @@ const MarkdownPreview = _react.memo((props)=>{
|
|
|
245
245
|
allowDangerousHtml: true
|
|
246
246
|
},
|
|
247
247
|
components: {
|
|
248
|
-
a: (markdownProps)
|
|
248
|
+
a: (markdownProps)=>/*#__PURE__*/ _react.createElement(MarkdownLink, {
|
|
249
249
|
...markdownProps,
|
|
250
250
|
Embedly: props.previewComponents?.embedly
|
|
251
251
|
})
|
|
@@ -26,9 +26,9 @@ const styles = {
|
|
|
26
26
|
})
|
|
27
27
|
};
|
|
28
28
|
function MarkdownPreviewSkeleton() {
|
|
29
|
-
return _react.default.createElement(_f36components.Skeleton.Container, {
|
|
29
|
+
return /*#__PURE__*/ _react.default.createElement(_f36components.Skeleton.Container, {
|
|
30
30
|
className: styles.root
|
|
31
|
-
}, _react.default.createElement(_f36components.Skeleton.DisplayText, null), _react.default.createElement(_f36components.Skeleton.BodyText, {
|
|
31
|
+
}, /*#__PURE__*/ _react.default.createElement(_f36components.Skeleton.DisplayText, null), /*#__PURE__*/ _react.default.createElement(_f36components.Skeleton.BodyText, {
|
|
32
32
|
offsetTop: 37,
|
|
33
33
|
numberOfLines: 5
|
|
34
34
|
}));
|
|
@@ -101,7 +101,7 @@ const styles = {
|
|
|
101
101
|
})
|
|
102
102
|
};
|
|
103
103
|
function MarkdownTabItem(props) {
|
|
104
|
-
return _react.createElement("div", {
|
|
104
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
105
105
|
className: (0, _emotion.cx)(styles.tab, {
|
|
106
106
|
[styles.inactiveTab]: props.isActive === false,
|
|
107
107
|
[styles.disabledTab]: props.isDisabled === true
|
|
@@ -122,15 +122,15 @@ function MarkdownTabItem(props) {
|
|
|
122
122
|
}, props.children);
|
|
123
123
|
}
|
|
124
124
|
function MarkdownTabs(props) {
|
|
125
|
-
return _react.createElement("div", {
|
|
125
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
126
126
|
className: styles.root
|
|
127
|
-
}, _react.createElement(MarkdownTabItem, {
|
|
127
|
+
}, /*#__PURE__*/ _react.createElement(MarkdownTabItem, {
|
|
128
128
|
name: "editor",
|
|
129
129
|
onSelect: props.onSelect,
|
|
130
130
|
isActive: props.active === 'editor',
|
|
131
131
|
testId: "markdown-tab-md",
|
|
132
132
|
isDisabled: props.enableTab && props.enableTab !== 'editor'
|
|
133
|
-
}, "Editor"), _react.createElement(MarkdownTabItem, {
|
|
133
|
+
}, "Editor"), /*#__PURE__*/ _react.createElement(MarkdownTabItem, {
|
|
134
134
|
name: "preview",
|
|
135
135
|
onSelect: props.onSelect,
|
|
136
136
|
isActive: props.active === 'preview',
|
|
@@ -154,7 +154,7 @@ const styles = {
|
|
|
154
154
|
}
|
|
155
155
|
`
|
|
156
156
|
};
|
|
157
|
-
const MarkdownTextarea = _react.default.memo((props)=>{
|
|
157
|
+
const MarkdownTextarea = /*#__PURE__*/ _react.default.memo((props)=>{
|
|
158
158
|
const hostRef = (0, _react.useRef)(null);
|
|
159
159
|
const [editor, setEditor] = (0, _react.useState)(null);
|
|
160
160
|
(0, _react.useEffect)(()=>{
|
|
@@ -180,7 +180,7 @@ const MarkdownTextarea = _react.default.memo((props)=>{
|
|
|
180
180
|
const className = (0, _emotion.cx)(styles.root, props.minHeight !== undefined ? (0, _emotion.css)({
|
|
181
181
|
minHeight: props.minHeight
|
|
182
182
|
}) : undefined, props.mode === 'default' ? styles.framed : styles.zen, props.disabled && styles.disabled);
|
|
183
|
-
return _react.default.createElement("div", {
|
|
183
|
+
return /*#__PURE__*/ _react.default.createElement("div", {
|
|
184
184
|
className: className,
|
|
185
185
|
ref: hostRef,
|
|
186
186
|
"data-test-id": "markdown-textarea",
|
|
@@ -103,14 +103,14 @@ const styles = {
|
|
|
103
103
|
zIndex: Number(_f36tokens.default.zIndexTooltip)
|
|
104
104
|
})
|
|
105
105
|
};
|
|
106
|
-
const ToolbarButton = _react.forwardRef((props, ref)=>{
|
|
106
|
+
const ToolbarButton = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
107
107
|
const { tooltip, onClick, children, className, variant = 'transparent', tooltipPlace = 'top', isDisabled = false, ...otherProps } = props;
|
|
108
|
-
return _react.createElement(_f36components.Tooltip, {
|
|
108
|
+
return /*#__PURE__*/ _react.createElement(_f36components.Tooltip, {
|
|
109
109
|
className: styles.tooltip,
|
|
110
110
|
usePortal: true,
|
|
111
111
|
placement: tooltipPlace,
|
|
112
112
|
content: tooltip
|
|
113
|
-
}, _react.createElement(_f36components.IconButton, {
|
|
113
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.IconButton, {
|
|
114
114
|
...otherProps,
|
|
115
115
|
ref: ref,
|
|
116
116
|
className: (0, _emotion.cx)(styles.button, className),
|
|
@@ -125,231 +125,231 @@ const ToolbarButton = _react.forwardRef((props, ref)=>{
|
|
|
125
125
|
ToolbarButton.displayName = 'ToolbarButton';
|
|
126
126
|
function MainButtons(props) {
|
|
127
127
|
const tooltipPlace = props.mode === 'zen' ? 'bottom' : 'top';
|
|
128
|
-
return _react.createElement(_react.Fragment, null, _react.createElement(_HeadingSelector.HeadingSelector, {
|
|
128
|
+
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement(_HeadingSelector.HeadingSelector, {
|
|
129
129
|
onSelect: (heading)=>{
|
|
130
130
|
if (heading && props.actions.headings[heading]) {
|
|
131
131
|
props.actions.headings[heading]();
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
}, _react.createElement(ToolbarButton, {
|
|
134
|
+
}, /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
135
135
|
isDisabled: props.disabled,
|
|
136
136
|
testId: "markdown-action-button-heading",
|
|
137
137
|
tooltip: "Headings",
|
|
138
138
|
tooltipPlace: tooltipPlace
|
|
139
|
-
}, _react.createElement(_f36icons.HeadingIcon, {
|
|
139
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.HeadingIcon, {
|
|
140
140
|
"aria-label": "Headings",
|
|
141
141
|
className: styles.icon
|
|
142
|
-
}))), _react.createElement(ToolbarButton, {
|
|
142
|
+
}))), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
143
143
|
isDisabled: props.disabled,
|
|
144
144
|
testId: "markdown-action-button-bold",
|
|
145
145
|
tooltip: "Bold",
|
|
146
146
|
tooltipPlace: tooltipPlace,
|
|
147
147
|
onClick: props.actions.simple.bold
|
|
148
|
-
}, _react.createElement(_f36icons.FormatBoldIcon, {
|
|
148
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.FormatBoldIcon, {
|
|
149
149
|
"aria-label": "Bold",
|
|
150
150
|
className: styles.icon
|
|
151
|
-
})), _react.createElement(ToolbarButton, {
|
|
151
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
152
152
|
isDisabled: props.disabled,
|
|
153
153
|
testId: "markdown-action-button-italic",
|
|
154
154
|
tooltip: "Italic",
|
|
155
155
|
tooltipPlace: tooltipPlace,
|
|
156
156
|
onClick: props.actions.simple.italic
|
|
157
|
-
}, _react.createElement(_f36icons.FormatItalicIcon, {
|
|
157
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.FormatItalicIcon, {
|
|
158
158
|
"aria-label": "Italic",
|
|
159
159
|
className: styles.icon
|
|
160
|
-
})), _react.createElement(ToolbarButton, {
|
|
160
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
161
161
|
isDisabled: props.disabled,
|
|
162
162
|
testId: "markdown-action-button-quote",
|
|
163
163
|
tooltip: "Quote",
|
|
164
164
|
tooltipPlace: tooltipPlace,
|
|
165
165
|
onClick: props.actions.simple.quote
|
|
166
|
-
}, _react.createElement(_f36icons.QuoteIcon, {
|
|
166
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.QuoteIcon, {
|
|
167
167
|
"aria-label": "Quote",
|
|
168
168
|
className: styles.icon
|
|
169
|
-
})), _react.createElement(ToolbarButton, {
|
|
169
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
170
170
|
isDisabled: props.disabled,
|
|
171
171
|
testId: "markdown-action-button-ul",
|
|
172
172
|
tooltip: "Unordered list",
|
|
173
173
|
tooltipPlace: tooltipPlace,
|
|
174
174
|
onClick: props.actions.simple.ul
|
|
175
|
-
}, _react.createElement(_f36icons.ListBulletedIcon, {
|
|
175
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.ListBulletedIcon, {
|
|
176
176
|
"aria-label": "Unordered list",
|
|
177
177
|
className: styles.icon
|
|
178
|
-
})), _react.createElement(ToolbarButton, {
|
|
178
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
179
179
|
isDisabled: props.disabled,
|
|
180
180
|
testId: "markdown-action-button-ol",
|
|
181
181
|
tooltip: "Ordered list",
|
|
182
182
|
tooltipPlace: tooltipPlace,
|
|
183
183
|
onClick: props.actions.simple.ol
|
|
184
|
-
}, _react.createElement(_f36icons.ListNumberedIcon, {
|
|
184
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.ListNumberedIcon, {
|
|
185
185
|
"aria-label": "Ordered list",
|
|
186
186
|
className: styles.icon
|
|
187
|
-
})), _react.createElement(ToolbarButton, {
|
|
187
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
188
188
|
isDisabled: props.disabled,
|
|
189
189
|
testId: "markdown-action-button-link",
|
|
190
190
|
tooltip: "Link",
|
|
191
191
|
tooltipPlace: tooltipPlace,
|
|
192
192
|
onClick: props.actions.insertLink
|
|
193
|
-
}, _react.createElement(_f36icons.LinkIcon, {
|
|
193
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.LinkIcon, {
|
|
194
194
|
"aria-label": "Link",
|
|
195
195
|
className: styles.icon
|
|
196
196
|
})));
|
|
197
197
|
}
|
|
198
198
|
function AdditionalButtons(props) {
|
|
199
199
|
const tooltipPlace = props.mode === 'zen' ? 'bottom' : 'top';
|
|
200
|
-
return _react.createElement(_react.Fragment, null, _react.createElement(ToolbarButton, {
|
|
200
|
+
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
201
201
|
isDisabled: props.disabled,
|
|
202
202
|
testId: "markdown-action-button-strike",
|
|
203
203
|
tooltip: "Strike out",
|
|
204
204
|
tooltipPlace: tooltipPlace,
|
|
205
205
|
onClick: props.actions.simple.strike
|
|
206
|
-
}, _react.createElement(_icons.Strikethrough, {
|
|
206
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Strikethrough, {
|
|
207
207
|
label: "Strike out",
|
|
208
208
|
className: styles.icon
|
|
209
|
-
})), _react.createElement(ToolbarButton, {
|
|
209
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
210
210
|
isDisabled: props.disabled,
|
|
211
211
|
testId: "markdown-action-button-code",
|
|
212
212
|
tooltip: "Code block",
|
|
213
213
|
tooltipPlace: tooltipPlace,
|
|
214
214
|
onClick: props.actions.simple.code
|
|
215
|
-
}, _react.createElement(_f36icons.CodeIcon, {
|
|
215
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.CodeIcon, {
|
|
216
216
|
"aria-label": "Code block",
|
|
217
217
|
className: styles.icon
|
|
218
|
-
})), _react.createElement(ToolbarButton, {
|
|
218
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
219
219
|
isDisabled: props.disabled,
|
|
220
220
|
testId: "markdown-action-button-hr",
|
|
221
221
|
tooltip: "Horizontal rule",
|
|
222
222
|
tooltipPlace: tooltipPlace,
|
|
223
223
|
onClick: props.actions.simple.hr
|
|
224
|
-
}, _react.createElement(_f36icons.HorizontalRuleIcon, {
|
|
224
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.HorizontalRuleIcon, {
|
|
225
225
|
"aria-label": "Horizontal rule",
|
|
226
226
|
className: styles.icon
|
|
227
|
-
})), _react.createElement(ToolbarButton, {
|
|
227
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
228
228
|
isDisabled: props.disabled,
|
|
229
229
|
testId: "markdown-action-button-indent",
|
|
230
230
|
tooltip: "Increase indentation",
|
|
231
231
|
tooltipPlace: tooltipPlace,
|
|
232
232
|
onClick: props.actions.simple.indent
|
|
233
|
-
}, _react.createElement(_icons.Indent, {
|
|
233
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Indent, {
|
|
234
234
|
label: "Increase indentation",
|
|
235
235
|
className: styles.icon
|
|
236
|
-
})), _react.createElement(ToolbarButton, {
|
|
236
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
237
237
|
isDisabled: props.disabled,
|
|
238
238
|
testId: "markdown-action-button-dedent",
|
|
239
239
|
tooltip: "Decrease indentation",
|
|
240
240
|
tooltipPlace: tooltipPlace,
|
|
241
241
|
onClick: props.actions.simple.dedent
|
|
242
|
-
}, _react.createElement(_icons.Dedent, {
|
|
242
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Dedent, {
|
|
243
243
|
label: "Decrease indentation",
|
|
244
244
|
className: styles.icon
|
|
245
|
-
})), _react.createElement(ToolbarButton, {
|
|
245
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
246
246
|
isDisabled: props.disabled,
|
|
247
247
|
testId: "markdown-action-button-embed",
|
|
248
248
|
tooltip: "Embed external content",
|
|
249
249
|
tooltipPlace: tooltipPlace,
|
|
250
250
|
onClick: props.actions.embedExternalContent
|
|
251
|
-
}, _react.createElement(_icons.Cubes, {
|
|
251
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Cubes, {
|
|
252
252
|
label: "Embed external content",
|
|
253
253
|
className: styles.icon
|
|
254
|
-
})), _react.createElement(ToolbarButton, {
|
|
254
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
255
255
|
isDisabled: props.disabled,
|
|
256
256
|
testId: "markdown-action-button-table",
|
|
257
257
|
tooltip: "Insert table",
|
|
258
258
|
tooltipPlace: tooltipPlace,
|
|
259
259
|
onClick: props.actions.insertTable
|
|
260
|
-
}, _react.createElement(_icons.Table, {
|
|
260
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Table, {
|
|
261
261
|
label: "Insert table",
|
|
262
262
|
className: styles.icon
|
|
263
|
-
})), _react.createElement(ToolbarButton, {
|
|
263
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
264
264
|
isDisabled: props.disabled,
|
|
265
265
|
testId: "markdown-action-button-special",
|
|
266
266
|
tooltip: "Insert special character",
|
|
267
267
|
tooltipPlace: tooltipPlace,
|
|
268
268
|
onClick: props.actions.insertSpecialCharacter
|
|
269
|
-
}, _react.createElement(_icons.SpecialChar, {
|
|
269
|
+
}, /*#__PURE__*/ _react.createElement(_icons.SpecialChar, {
|
|
270
270
|
label: "Insert special character",
|
|
271
271
|
className: styles.icon
|
|
272
|
-
})), _react.createElement(ToolbarButton, {
|
|
272
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
273
273
|
isDisabled: props.disabled,
|
|
274
274
|
testId: "markdown-action-button-organizeLinks",
|
|
275
275
|
tooltip: "Organize links",
|
|
276
276
|
tooltipPlace: tooltipPlace,
|
|
277
277
|
onClick: props.actions.organizeLinks
|
|
278
|
-
}, _react.createElement(_icons.OrgLinks, {
|
|
278
|
+
}, /*#__PURE__*/ _react.createElement(_icons.OrgLinks, {
|
|
279
279
|
label: "Organize links",
|
|
280
280
|
className: styles.icon
|
|
281
|
-
})), _react.createElement(ToolbarButton, {
|
|
281
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
282
282
|
isDisabled: props.disabled,
|
|
283
283
|
testId: "markdown-action-button-undo",
|
|
284
284
|
tooltip: "Undo",
|
|
285
285
|
tooltipPlace: tooltipPlace,
|
|
286
286
|
onClick: props.actions.history.undo
|
|
287
|
-
}, _react.createElement(_icons.Undo, {
|
|
287
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Undo, {
|
|
288
288
|
label: "Undo",
|
|
289
289
|
className: styles.icon
|
|
290
|
-
})), _react.createElement(ToolbarButton, {
|
|
290
|
+
})), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
291
291
|
isDisabled: props.disabled,
|
|
292
292
|
testId: "markdown-action-button-redo",
|
|
293
293
|
tooltip: "Redo",
|
|
294
294
|
tooltipPlace: tooltipPlace,
|
|
295
295
|
onClick: props.actions.history.redo
|
|
296
|
-
}, _react.createElement(_icons.Redo, {
|
|
296
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Redo, {
|
|
297
297
|
label: "Redo",
|
|
298
298
|
className: styles.icon
|
|
299
299
|
})));
|
|
300
300
|
}
|
|
301
301
|
function DefaultMarkdownToolbar(props) {
|
|
302
302
|
const [showAdditional, setShowAdditional] = _react.useState(false);
|
|
303
|
-
return _react.createElement("div", {
|
|
303
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
304
304
|
className: styles.root
|
|
305
|
-
}, _react.createElement(_f36components.Flex, {
|
|
305
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Flex, {
|
|
306
306
|
justifyContent: "space-between",
|
|
307
307
|
flexWrap: "wrap"
|
|
308
|
-
}, _react.createElement(_f36components.Flex, {
|
|
308
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Flex, {
|
|
309
309
|
flexWrap: "wrap"
|
|
310
|
-
}, _react.createElement(MainButtons, props), _react.createElement(ToolbarButton, {
|
|
310
|
+
}, /*#__PURE__*/ _react.createElement(MainButtons, props), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
311
311
|
isDisabled: props.disabled,
|
|
312
312
|
testId: "markdown-action-button-toggle-additional",
|
|
313
313
|
tooltip: showAdditional ? 'Hide additional actions' : 'More actions',
|
|
314
314
|
onClick: ()=>{
|
|
315
315
|
setShowAdditional(!showAdditional);
|
|
316
316
|
}
|
|
317
|
-
}, _react.createElement(_f36icons.MoreHorizontalIcon, {
|
|
317
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.MoreHorizontalIcon, {
|
|
318
318
|
className: styles.icon
|
|
319
|
-
}))), _react.createElement(_f36components.Flex, null, _react.createElement(_InsertLinkSelector.InsertLinkSelector, {
|
|
319
|
+
}))), /*#__PURE__*/ _react.createElement(_f36components.Flex, null, /*#__PURE__*/ _react.createElement(_InsertLinkSelector.InsertLinkSelector, {
|
|
320
320
|
disabled: props.disabled,
|
|
321
321
|
onSelectExisting: props.actions.linkExistingMedia,
|
|
322
322
|
onAddNew: props.actions.addNewMedia,
|
|
323
323
|
canAddNew: props.canUploadAssets
|
|
324
|
-
}), _react.createElement(ToolbarButton, {
|
|
324
|
+
}), /*#__PURE__*/ _react.createElement(ToolbarButton, {
|
|
325
325
|
isDisabled: props.disabled,
|
|
326
326
|
testId: "markdown-action-button-zen",
|
|
327
327
|
variant: "secondary",
|
|
328
328
|
onClick: props.actions.openZenMode,
|
|
329
329
|
className: styles.zenButton,
|
|
330
330
|
tooltip: "Expand"
|
|
331
|
-
}, _react.createElement(_icons.Zen, {
|
|
331
|
+
}, /*#__PURE__*/ _react.createElement(_icons.Zen, {
|
|
332
332
|
label: "Expand",
|
|
333
333
|
className: styles.icon
|
|
334
|
-
})))), showAdditional && _react.createElement(_f36components.Flex, {
|
|
334
|
+
})))), showAdditional && /*#__PURE__*/ _react.createElement(_f36components.Flex, {
|
|
335
335
|
justifyContent: "space-between",
|
|
336
336
|
marginTop: "spacingXs"
|
|
337
|
-
}, _react.createElement(_f36components.Flex, null, _react.createElement(AdditionalButtons, props))));
|
|
337
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Flex, null, /*#__PURE__*/ _react.createElement(AdditionalButtons, props))));
|
|
338
338
|
}
|
|
339
339
|
function ZenMarkdownToolbar(props) {
|
|
340
|
-
return _react.createElement("div", {
|
|
340
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
341
341
|
className: styles.root
|
|
342
|
-
}, _react.createElement(_f36components.Flex, {
|
|
342
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Flex, {
|
|
343
343
|
justifyContent: "space-between",
|
|
344
344
|
alignItems: "flex-start"
|
|
345
|
-
}, _react.createElement(_f36components.Flex, {
|
|
345
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Flex, {
|
|
346
346
|
flexWrap: "wrap"
|
|
347
|
-
}, _react.createElement(MainButtons, props), _react.createElement(AdditionalButtons, props)), _react.createElement(_f36components.Flex, null, _react.createElement(_InsertLinkSelector.InsertLinkSelector, {
|
|
347
|
+
}, /*#__PURE__*/ _react.createElement(MainButtons, props), /*#__PURE__*/ _react.createElement(AdditionalButtons, props)), /*#__PURE__*/ _react.createElement(_f36components.Flex, null, /*#__PURE__*/ _react.createElement(_InsertLinkSelector.InsertLinkSelector, {
|
|
348
348
|
disabled: props.disabled,
|
|
349
349
|
onSelectExisting: props.actions.linkExistingMedia,
|
|
350
350
|
onAddNew: props.actions.addNewMedia,
|
|
351
351
|
canAddNew: props.canUploadAssets
|
|
352
|
-
}), _react.createElement(_f36components.IconButton, {
|
|
352
|
+
}), /*#__PURE__*/ _react.createElement(_f36components.IconButton, {
|
|
353
353
|
testId: "markdown-action-button-zen-close",
|
|
354
354
|
variant: "secondary",
|
|
355
355
|
size: "small",
|
|
@@ -357,17 +357,17 @@ function ZenMarkdownToolbar(props) {
|
|
|
357
357
|
onClick: ()=>{
|
|
358
358
|
props.actions.closeZenMode();
|
|
359
359
|
},
|
|
360
|
-
icon: _react.createElement(_icons.Zen, {
|
|
360
|
+
icon: /*#__PURE__*/ _react.createElement(_icons.Zen, {
|
|
361
361
|
label: "Collapse",
|
|
362
362
|
className: styles.icon
|
|
363
363
|
}),
|
|
364
364
|
"aria-label": "Collapse"
|
|
365
365
|
}))));
|
|
366
366
|
}
|
|
367
|
-
const MarkdownToolbar = _react.memo((props)=>{
|
|
367
|
+
const MarkdownToolbar = /*#__PURE__*/ _react.memo((props)=>{
|
|
368
368
|
if (props.mode === 'zen') {
|
|
369
|
-
return _react.createElement(ZenMarkdownToolbar, props);
|
|
369
|
+
return /*#__PURE__*/ _react.createElement(ZenMarkdownToolbar, props);
|
|
370
370
|
}
|
|
371
|
-
return _react.createElement(DefaultMarkdownToolbar, props);
|
|
371
|
+
return /*#__PURE__*/ _react.createElement(DefaultMarkdownToolbar, props);
|
|
372
372
|
});
|
|
373
373
|
MarkdownToolbar.displayName = 'MarkdownToolbar';
|