@contentful/field-editor-markdown 2.4.4-canary.26 → 2.4.4-canary.30
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 +15 -15
- package/dist/cjs/__fixtures__/asset/index.js +6 -6
- package/dist/cjs/__fixtures__/entry/index.js +5 -5
- package/dist/cjs/__fixtures__/fixtures.js +6 -6
- package/dist/cjs/__fixtures__/locale/index.js +4 -4
- package/dist/cjs/components/HeadingSelector.js +5 -5
- package/dist/cjs/components/InsertLinkSelector.js +9 -9
- package/dist/cjs/components/MarkdownBottomBar.js +14 -14
- 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 +62 -62
- package/dist/cjs/components/MarkdownToolbar.spec.js +4 -4
- package/dist/cjs/dialogs/CheatsheetModalDialog.js +48 -48
- package/dist/cjs/dialogs/ConfirmInsertAssetModalDialog.js +8 -8
- package/dist/cjs/dialogs/EmdebExternalContentDialog.js +21 -21
- package/dist/cjs/dialogs/InsertLinkModalDialog.js +13 -13
- package/dist/cjs/dialogs/InsertTableModalDialog.js +10 -10
- package/dist/cjs/dialogs/SpecialCharacterModalDialog.js +13 -13
- package/dist/cjs/dialogs/ZenModeModalDialog.js +20 -20
- package/dist/cjs/dialogs/openMarkdownDialog.js +7 -7
- package/dist/cjs/dialogs/renderMarkdownDialog.js +8 -8
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/types.js +3 -3
- package/dist/cjs/utils/insertAssetLinks.js +3 -3
- package/dist/cjs/utils/isValidUrl.js +3 -3
- package/dist/cjs/utils/linkOrganizer.js +7 -7
- package/dist/esm/MarkdownEditor.js +12 -12
- package/dist/esm/components/HeadingSelector.js +5 -5
- 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 +58 -58
- package/dist/esm/components/MarkdownToolbar.spec.js +4 -4
- package/dist/esm/dialogs/CheatsheetModalDialog.js +45 -45
- package/dist/esm/dialogs/ConfirmInsertAssetModalDialog.js +5 -5
- package/dist/esm/dialogs/EmdebExternalContentDialog.js +18 -18
- 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 +5 -5
|
@@ -5,26 +5,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
convertInlineToRef
|
|
12
|
+
get convertInlineToRef () {
|
|
13
13
|
return convertInlineToRef;
|
|
14
14
|
},
|
|
15
|
-
findInline
|
|
15
|
+
get findInline () {
|
|
16
16
|
return findInline;
|
|
17
17
|
},
|
|
18
|
-
findLabels
|
|
18
|
+
get findLabels () {
|
|
19
19
|
return findLabels;
|
|
20
20
|
},
|
|
21
|
-
findMaxLabelId
|
|
21
|
+
get findMaxLabelId () {
|
|
22
22
|
return findMaxLabelId;
|
|
23
23
|
},
|
|
24
|
-
findRefs
|
|
24
|
+
get findRefs () {
|
|
25
25
|
return findRefs;
|
|
26
26
|
},
|
|
27
|
-
rewriteRefs
|
|
27
|
+
get rewriteRefs () {
|
|
28
28
|
return rewriteRefs;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
@@ -10,7 +10,7 @@ import { MarkdownTextarea } from './components/MarkdownTextarea/MarkdownTextarea
|
|
|
10
10
|
import { MarkdownToolbar } from './components/MarkdownToolbar';
|
|
11
11
|
import { openCheatsheetModal } from './dialogs/CheatsheetModalDialog';
|
|
12
12
|
import { createMarkdownActions } from './MarkdownActions';
|
|
13
|
-
const MarkdownPreview =
|
|
13
|
+
const MarkdownPreview = React.lazy(()=>import('./components/MarkdownPreview'));
|
|
14
14
|
const styles = {
|
|
15
15
|
container: css({
|
|
16
16
|
display: 'flex',
|
|
@@ -78,22 +78,22 @@ export function MarkdownEditor(props) {
|
|
|
78
78
|
const openMarkdownHelp = React.useCallback(()=>{
|
|
79
79
|
openCheatsheetModal(props.sdk.dialogs);
|
|
80
80
|
}, []);
|
|
81
|
-
return
|
|
81
|
+
return React.createElement("div", {
|
|
82
82
|
className: styles.container,
|
|
83
83
|
"data-test-id": "markdown-editor"
|
|
84
|
-
},
|
|
84
|
+
}, React.createElement(MarkdownTabs, {
|
|
85
85
|
active: selectedTab,
|
|
86
86
|
onSelect: (tab)=>{
|
|
87
87
|
if (props.enableTab) return;
|
|
88
88
|
setSelectedTab(tab);
|
|
89
89
|
},
|
|
90
90
|
enableTab: props.enableTab
|
|
91
|
-
}),
|
|
91
|
+
}), React.createElement(MarkdownToolbar, {
|
|
92
92
|
mode: "default",
|
|
93
93
|
disabled: isActionDisabled,
|
|
94
94
|
canUploadAssets: canUploadAssets,
|
|
95
95
|
actions: actions
|
|
96
|
-
}),
|
|
96
|
+
}), React.createElement(MarkdownTextarea, {
|
|
97
97
|
minHeight: props.minHeight,
|
|
98
98
|
mode: "default",
|
|
99
99
|
visible: selectedTab === 'editor',
|
|
@@ -109,29 +109,29 @@ export function MarkdownEditor(props) {
|
|
|
109
109
|
setCurrentValue(value);
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
}), selectedTab === 'preview' &&
|
|
113
|
-
fallback:
|
|
114
|
-
},
|
|
112
|
+
}), selectedTab === 'preview' && React.createElement(React.Suspense, {
|
|
113
|
+
fallback: React.createElement(MarkdownPreviewSkeleton, null)
|
|
114
|
+
}, React.createElement(MarkdownPreview, {
|
|
115
115
|
direction: direction,
|
|
116
116
|
minHeight: props.minHeight,
|
|
117
117
|
mode: "default",
|
|
118
118
|
value: currentValue,
|
|
119
119
|
previewComponents: props.previewComponents
|
|
120
|
-
})),
|
|
120
|
+
})), React.createElement(MarkdownBottomBar, null, React.createElement(MarkdownHelp, {
|
|
121
121
|
mode: selectedTab,
|
|
122
122
|
onClick: openMarkdownHelp
|
|
123
|
-
})),
|
|
123
|
+
})), React.createElement(MarkdownConstraints, {
|
|
124
124
|
sdk: props.sdk,
|
|
125
125
|
value: currentValue
|
|
126
126
|
}));
|
|
127
127
|
}
|
|
128
128
|
export function MarkdownEditorConnected(props) {
|
|
129
|
-
return
|
|
129
|
+
return React.createElement(FieldConnector, {
|
|
130
130
|
debounce: 300,
|
|
131
131
|
field: props.sdk.field,
|
|
132
132
|
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
133
133
|
isDisabled: props.isDisabled
|
|
134
|
-
}, ({ value, disabled, setValue, externalReset })
|
|
134
|
+
}, ({ value, disabled, setValue, externalReset })=>React.createElement(MarkdownEditor, {
|
|
135
135
|
...props,
|
|
136
136
|
value: value,
|
|
137
137
|
isDisabled: disabled,
|
|
@@ -6,19 +6,19 @@ export const HeadingSelector = (props)=>{
|
|
|
6
6
|
setIsOpen(false);
|
|
7
7
|
props.onSelect(heading);
|
|
8
8
|
};
|
|
9
|
-
return
|
|
9
|
+
return React.createElement(Menu, {
|
|
10
10
|
isOpen: isOpen,
|
|
11
11
|
onClose: ()=>setIsOpen(false)
|
|
12
|
-
},
|
|
12
|
+
}, React.createElement(Menu.Trigger, null, props.renderTrigger({
|
|
13
13
|
isOpen,
|
|
14
14
|
onClick: ()=>setIsOpen((current)=>!current)
|
|
15
|
-
})),
|
|
15
|
+
})), React.createElement(Menu.List, null, React.createElement(Menu.Item, {
|
|
16
16
|
testId: "markdown-action-button-heading-h1",
|
|
17
17
|
onClick: ()=>handleMenuClick('h1')
|
|
18
|
-
}, "Heading 1"),
|
|
18
|
+
}, "Heading 1"), React.createElement(Menu.Item, {
|
|
19
19
|
testId: "markdown-action-button-heading-h2",
|
|
20
20
|
onClick: ()=>handleMenuClick('h2')
|
|
21
|
-
}, "Heading 2"),
|
|
21
|
+
}, "Heading 2"), React.createElement(Menu.Item, {
|
|
22
22
|
testId: "markdown-action-button-heading-h3",
|
|
23
23
|
onClick: ()=>handleMenuClick('h3')
|
|
24
24
|
}, "Heading 3")));
|
|
@@ -3,11 +3,11 @@ import { Button, Menu } from '@contentful/f36-components';
|
|
|
3
3
|
import { ImageSquareIcon, CaretDownIcon } from '@contentful/f36-icons';
|
|
4
4
|
export const InsertLinkSelector = (props)=>{
|
|
5
5
|
if (props.canAddNew) {
|
|
6
|
-
return
|
|
6
|
+
return React.createElement(MultipleMediaContextMenu, props);
|
|
7
7
|
} else {
|
|
8
|
-
return
|
|
8
|
+
return React.createElement(Button, {
|
|
9
9
|
isDisabled: props.disabled,
|
|
10
|
-
startIcon:
|
|
10
|
+
startIcon: React.createElement(ImageSquareIcon, null),
|
|
11
11
|
testId: "markdownEditor.linkExistingAssets",
|
|
12
12
|
size: "small",
|
|
13
13
|
variant: "secondary",
|
|
@@ -18,19 +18,19 @@ export const InsertLinkSelector = (props)=>{
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
const MultipleMediaContextMenu = (props)=>{
|
|
21
|
-
return
|
|
21
|
+
return React.createElement(Menu, {
|
|
22
22
|
placement: "bottom-end"
|
|
23
|
-
},
|
|
24
|
-
endIcon:
|
|
23
|
+
}, React.createElement(Menu.Trigger, null, React.createElement(Button, {
|
|
24
|
+
endIcon: React.createElement(CaretDownIcon, null),
|
|
25
25
|
isDisabled: props.disabled,
|
|
26
|
-
startIcon:
|
|
26
|
+
startIcon: React.createElement(ImageSquareIcon, null),
|
|
27
27
|
testId: "markdownEditor.insertMediaDropdownTrigger",
|
|
28
28
|
size: "small",
|
|
29
29
|
variant: "secondary"
|
|
30
|
-
}, "Insert media")),
|
|
30
|
+
}, "Insert media")), React.createElement(Menu.List, null, React.createElement(Menu.Item, {
|
|
31
31
|
testId: "markdownEditor.uploadAssetsAndLink",
|
|
32
32
|
onClick: ()=>props.onAddNew()
|
|
33
|
-
}, "Add new media and link"),
|
|
33
|
+
}, "Add new media and link"), React.createElement(Menu.Item, {
|
|
34
34
|
testId: "markdownEditor.linkExistingAssets",
|
|
35
35
|
onClick: ()=>props.onSelectExisting()
|
|
36
36
|
}, "Link existing media")));
|
|
@@ -23,13 +23,13 @@ const styles = {
|
|
|
23
23
|
})
|
|
24
24
|
};
|
|
25
25
|
export function MarkdownCounter(props) {
|
|
26
|
-
return
|
|
26
|
+
return React.createElement(Paragraph, {
|
|
27
27
|
marginBottom: "none",
|
|
28
28
|
className: styles.help
|
|
29
29
|
}, props.words, " ", props.words !== 1 ? 'words' : 'word', ", ", props.characters, ' ', props.characters !== 1 ? 'characters' : 'character');
|
|
30
30
|
}
|
|
31
31
|
function SanitizeMessage() {
|
|
32
|
-
return
|
|
32
|
+
return React.createElement("span", null, "The preview of the content in this field will be sanitized.", ' ', React.createElement(TextLink, {
|
|
33
33
|
as: "a",
|
|
34
34
|
target: "_blank",
|
|
35
35
|
rel: "noopener noreferrer",
|
|
@@ -37,7 +37,7 @@ function SanitizeMessage() {
|
|
|
37
37
|
}, "Learn more."));
|
|
38
38
|
}
|
|
39
39
|
function CheatSheetMessage({ onClick }) {
|
|
40
|
-
return
|
|
40
|
+
return React.createElement("span", null, "Format your text like a pro with the", ' ', React.createElement(TextLink, {
|
|
41
41
|
as: "button",
|
|
42
42
|
testId: "open-markdown-cheatsheet-button",
|
|
43
43
|
onClick: onClick
|
|
@@ -47,33 +47,33 @@ export function MarkdownHelp(props) {
|
|
|
47
47
|
let content;
|
|
48
48
|
switch(props.mode){
|
|
49
49
|
case 'preview':
|
|
50
|
-
content =
|
|
50
|
+
content = React.createElement(SanitizeMessage, null);
|
|
51
51
|
break;
|
|
52
52
|
case 'editor':
|
|
53
|
-
content =
|
|
53
|
+
content = React.createElement(CheatSheetMessage, {
|
|
54
54
|
onClick: props.onClick
|
|
55
55
|
});
|
|
56
56
|
break;
|
|
57
57
|
case 'zen':
|
|
58
|
-
content =
|
|
58
|
+
content = React.createElement(Stack, {
|
|
59
59
|
flexDirection: "column",
|
|
60
60
|
spacing: "spacing2Xs",
|
|
61
61
|
alignItems: "flex-start"
|
|
62
|
-
},
|
|
62
|
+
}, React.createElement(CheatSheetMessage, {
|
|
63
63
|
onClick: props.onClick
|
|
64
|
-
}),
|
|
64
|
+
}), React.createElement(SanitizeMessage, null));
|
|
65
65
|
break;
|
|
66
66
|
default:
|
|
67
67
|
content = null;
|
|
68
68
|
throw new Error(`Invalid HelpMode provided in MarkdownHelp: ${props.mode}`);
|
|
69
69
|
}
|
|
70
|
-
return
|
|
70
|
+
return React.createElement(Paragraph, {
|
|
71
71
|
marginBottom: "none",
|
|
72
72
|
className: styles.help
|
|
73
73
|
}, content);
|
|
74
74
|
}
|
|
75
75
|
export function MarkdownBottomBar(props) {
|
|
76
|
-
return
|
|
76
|
+
return React.createElement("div", {
|
|
77
77
|
className: styles.root
|
|
78
78
|
}, props.children);
|
|
79
79
|
}
|
|
@@ -14,12 +14,12 @@ const styles = {
|
|
|
14
14
|
export function MarkdownConstraints(props) {
|
|
15
15
|
const constraints = ConstraintsUtils.fromFieldValidations(props.sdk.field.validations, props.sdk.field.type);
|
|
16
16
|
const checkConstraint = ConstraintsUtils.makeChecker(constraints);
|
|
17
|
-
return
|
|
17
|
+
return React.createElement("div", {
|
|
18
18
|
className: styles.root
|
|
19
|
-
},
|
|
19
|
+
}, React.createElement(CharCounter, {
|
|
20
20
|
value: props.value,
|
|
21
21
|
checkConstraint: checkConstraint
|
|
22
|
-
}),
|
|
22
|
+
}), React.createElement(CharValidation, {
|
|
23
23
|
constraints: constraints
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
@@ -159,24 +159,24 @@ const styles = {
|
|
|
159
159
|
function MarkdownLink(props) {
|
|
160
160
|
const { Embedly, children, ...rest } = props;
|
|
161
161
|
if (props.className === 'embedly-card' && Embedly) {
|
|
162
|
-
return
|
|
162
|
+
return React.createElement(Embedly, {
|
|
163
163
|
url: props.href ?? ''
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
return
|
|
166
|
+
return React.createElement("a", {
|
|
167
167
|
...rest,
|
|
168
168
|
target: "_blank",
|
|
169
169
|
rel: "noopener noreferrer"
|
|
170
170
|
}, children);
|
|
171
171
|
}
|
|
172
|
-
const MarkdownPreview =
|
|
172
|
+
const MarkdownPreview = React.memo((props)=>{
|
|
173
173
|
const className = cx(props.minHeight !== undefined ? css({
|
|
174
174
|
minHeight: props.minHeight
|
|
175
175
|
}) : undefined, props.mode === 'default' ? styles.framed : styles.zen, props.direction === 'rtl' ? styles.rtl : undefined);
|
|
176
|
-
return
|
|
176
|
+
return React.createElement("div", {
|
|
177
177
|
className: className,
|
|
178
178
|
"data-test-id": "markdown-preview"
|
|
179
|
-
},
|
|
179
|
+
}, React.createElement(ReactMarkdown, {
|
|
180
180
|
className: styles.root,
|
|
181
181
|
rehypePlugins: [
|
|
182
182
|
rehypeRaw,
|
|
@@ -189,7 +189,7 @@ const MarkdownPreview = /*#__PURE__*/ React.memo((props)=>{
|
|
|
189
189
|
allowDangerousHtml: true
|
|
190
190
|
},
|
|
191
191
|
components: {
|
|
192
|
-
a: (markdownProps)
|
|
192
|
+
a: (markdownProps)=>React.createElement(MarkdownLink, {
|
|
193
193
|
...markdownProps,
|
|
194
194
|
Embedly: props.previewComponents?.embedly
|
|
195
195
|
})
|
|
@@ -11,9 +11,9 @@ const styles = {
|
|
|
11
11
|
})
|
|
12
12
|
};
|
|
13
13
|
export default function MarkdownPreviewSkeleton() {
|
|
14
|
-
return
|
|
14
|
+
return React.createElement(Skeleton.Container, {
|
|
15
15
|
className: styles.root
|
|
16
|
-
},
|
|
16
|
+
}, React.createElement(Skeleton.DisplayText, null), React.createElement(Skeleton.BodyText, {
|
|
17
17
|
offsetTop: 37,
|
|
18
18
|
numberOfLines: 5
|
|
19
19
|
}));
|
|
@@ -45,7 +45,7 @@ const styles = {
|
|
|
45
45
|
})
|
|
46
46
|
};
|
|
47
47
|
function MarkdownTabItem(props) {
|
|
48
|
-
return
|
|
48
|
+
return React.createElement("div", {
|
|
49
49
|
className: cx(styles.tab, {
|
|
50
50
|
[styles.inactiveTab]: props.isActive === false,
|
|
51
51
|
[styles.disabledTab]: props.isDisabled === true
|
|
@@ -66,15 +66,15 @@ function MarkdownTabItem(props) {
|
|
|
66
66
|
}, props.children);
|
|
67
67
|
}
|
|
68
68
|
export function MarkdownTabs(props) {
|
|
69
|
-
return
|
|
69
|
+
return React.createElement("div", {
|
|
70
70
|
className: styles.root
|
|
71
|
-
},
|
|
71
|
+
}, React.createElement(MarkdownTabItem, {
|
|
72
72
|
name: "editor",
|
|
73
73
|
onSelect: props.onSelect,
|
|
74
74
|
isActive: props.active === 'editor',
|
|
75
75
|
testId: "markdown-tab-md",
|
|
76
76
|
isDisabled: props.enableTab && props.enableTab !== 'editor'
|
|
77
|
-
}, "Editor"),
|
|
77
|
+
}, "Editor"), React.createElement(MarkdownTabItem, {
|
|
78
78
|
name: "preview",
|
|
79
79
|
onSelect: props.onSelect,
|
|
80
80
|
isActive: props.active === 'preview',
|
|
@@ -98,7 +98,7 @@ const styles = {
|
|
|
98
98
|
}
|
|
99
99
|
`
|
|
100
100
|
};
|
|
101
|
-
export const MarkdownTextarea =
|
|
101
|
+
export const MarkdownTextarea = React.memo((props)=>{
|
|
102
102
|
const hostRef = useRef(null);
|
|
103
103
|
const [editor, setEditor] = useState(null);
|
|
104
104
|
useEffect(()=>{
|
|
@@ -124,7 +124,7 @@ export const MarkdownTextarea = /*#__PURE__*/ React.memo((props)=>{
|
|
|
124
124
|
const className = cx(styles.root, props.minHeight !== undefined ? css({
|
|
125
125
|
minHeight: props.minHeight
|
|
126
126
|
}) : undefined, props.mode === 'default' ? styles.framed : styles.zen, props.disabled && styles.disabled);
|
|
127
|
-
return
|
|
127
|
+
return React.createElement("div", {
|
|
128
128
|
className: className,
|
|
129
129
|
ref: hostRef,
|
|
130
130
|
"data-test-id": "markdown-textarea",
|