@contentful/field-editor-markdown 1.6.13 → 1.7.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.
|
@@ -105,11 +105,11 @@ function MarkdownEditor(props) {
|
|
|
105
105
|
}, []);
|
|
106
106
|
_react.useEffect(()=>{
|
|
107
107
|
if (editor) {
|
|
108
|
-
editor.setReadOnly(props.
|
|
108
|
+
editor.setReadOnly(!!props.isDisabled);
|
|
109
109
|
}
|
|
110
110
|
}, [
|
|
111
111
|
editor,
|
|
112
|
-
props.
|
|
112
|
+
props.isDisabled
|
|
113
113
|
]);
|
|
114
114
|
_react.useEffect(()=>{
|
|
115
115
|
if (props.externalReset !== prevExternalReset.current) {
|
|
@@ -121,7 +121,7 @@ function MarkdownEditor(props) {
|
|
|
121
121
|
props.externalReset,
|
|
122
122
|
editor
|
|
123
123
|
]);
|
|
124
|
-
const isActionDisabled = editor === null || props.
|
|
124
|
+
const isActionDisabled = editor === null || props.isDisabled || selectedTab !== 'editor';
|
|
125
125
|
const direction = props.sdk.locales.direction[props.sdk.field.locale] ?? 'ltr';
|
|
126
126
|
const actions = _react.useMemo(()=>{
|
|
127
127
|
return (0, _MarkdownActions.createMarkdownActions)({
|
|
@@ -156,7 +156,7 @@ function MarkdownEditor(props) {
|
|
|
156
156
|
direction: direction,
|
|
157
157
|
onReady: (editor)=>{
|
|
158
158
|
editor.setContent(props.value ?? '');
|
|
159
|
-
editor.setReadOnly(props.
|
|
159
|
+
editor.setReadOnly(!!props.isDisabled);
|
|
160
160
|
setEditor(editor);
|
|
161
161
|
editor.events.onChange((value)=>{
|
|
162
162
|
const trimmedValue = value.replace(/^\s+$/gm, '');
|
|
@@ -184,11 +184,12 @@ function MarkdownEditorConnected(props) {
|
|
|
184
184
|
return _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
185
185
|
debounce: 300,
|
|
186
186
|
field: props.sdk.field,
|
|
187
|
-
isInitiallyDisabled: props.isInitiallyDisabled
|
|
187
|
+
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
188
|
+
isDisabled: props.isDisabled
|
|
188
189
|
}, ({ value, disabled, setValue, externalReset })=>_react.createElement(MarkdownEditor, {
|
|
189
190
|
...props,
|
|
190
191
|
value: value,
|
|
191
|
-
|
|
192
|
+
isDisabled: disabled,
|
|
192
193
|
saveValueToSDK: setValue,
|
|
193
194
|
externalReset: externalReset
|
|
194
195
|
}));
|
|
@@ -41,11 +41,11 @@ export function MarkdownEditor(props) {
|
|
|
41
41
|
}, []);
|
|
42
42
|
React.useEffect(()=>{
|
|
43
43
|
if (editor) {
|
|
44
|
-
editor.setReadOnly(props.
|
|
44
|
+
editor.setReadOnly(!!props.isDisabled);
|
|
45
45
|
}
|
|
46
46
|
}, [
|
|
47
47
|
editor,
|
|
48
|
-
props.
|
|
48
|
+
props.isDisabled
|
|
49
49
|
]);
|
|
50
50
|
React.useEffect(()=>{
|
|
51
51
|
if (props.externalReset !== prevExternalReset.current) {
|
|
@@ -57,7 +57,7 @@ export function MarkdownEditor(props) {
|
|
|
57
57
|
props.externalReset,
|
|
58
58
|
editor
|
|
59
59
|
]);
|
|
60
|
-
const isActionDisabled = editor === null || props.
|
|
60
|
+
const isActionDisabled = editor === null || props.isDisabled || selectedTab !== 'editor';
|
|
61
61
|
const direction = props.sdk.locales.direction[props.sdk.field.locale] ?? 'ltr';
|
|
62
62
|
const actions = React.useMemo(()=>{
|
|
63
63
|
return createMarkdownActions({
|
|
@@ -92,7 +92,7 @@ export function MarkdownEditor(props) {
|
|
|
92
92
|
direction: direction,
|
|
93
93
|
onReady: (editor)=>{
|
|
94
94
|
editor.setContent(props.value ?? '');
|
|
95
|
-
editor.setReadOnly(props.
|
|
95
|
+
editor.setReadOnly(!!props.isDisabled);
|
|
96
96
|
setEditor(editor);
|
|
97
97
|
editor.events.onChange((value)=>{
|
|
98
98
|
const trimmedValue = value.replace(/^\s+$/gm, '');
|
|
@@ -120,11 +120,12 @@ export function MarkdownEditorConnected(props) {
|
|
|
120
120
|
return React.createElement(FieldConnector, {
|
|
121
121
|
debounce: 300,
|
|
122
122
|
field: props.sdk.field,
|
|
123
|
-
isInitiallyDisabled: props.isInitiallyDisabled
|
|
123
|
+
isInitiallyDisabled: props.isInitiallyDisabled,
|
|
124
|
+
isDisabled: props.isDisabled
|
|
124
125
|
}, ({ value, disabled, setValue, externalReset })=>React.createElement(MarkdownEditor, {
|
|
125
126
|
...props,
|
|
126
127
|
value: value,
|
|
127
|
-
|
|
128
|
+
isDisabled: disabled,
|
|
128
129
|
saveValueToSDK: setValue,
|
|
129
130
|
externalReset: externalReset
|
|
130
131
|
}));
|
|
@@ -13,9 +13,9 @@ export interface MarkdownEditorProps {
|
|
|
13
13
|
sdk: FieldAppSDK;
|
|
14
14
|
previewComponents?: PreviewComponents;
|
|
15
15
|
onReady?: Function;
|
|
16
|
+
isDisabled?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare function MarkdownEditor(props: MarkdownEditorProps & {
|
|
18
|
-
disabled: boolean;
|
|
19
19
|
value: string | null | undefined;
|
|
20
20
|
saveValueToSDK: Function;
|
|
21
21
|
externalReset?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-markdown",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@contentful/f36-components": "^4.70.0",
|
|
39
39
|
"@contentful/f36-icons": "^4.29.0",
|
|
40
40
|
"@contentful/f36-tokens": "^4.0.5",
|
|
41
|
-
"@contentful/field-editor-shared": "^2.
|
|
41
|
+
"@contentful/field-editor-shared": "^2.3.0",
|
|
42
42
|
"@types/codemirror": "0.0.109",
|
|
43
43
|
"codemirror": "^5.65.11",
|
|
44
44
|
"constate": "^3.3.2",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"registry": "https://npm.pkg.github.com/"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "28c4e05014732ce423e75ab34dd139c887d7efbd"
|
|
65
65
|
}
|