@tinacms/app 0.0.0-660f88b-20250131021316 → 0.0.0-67b5c0b-20250414080731
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/CHANGELOG.md +74 -11
- package/package.json +13 -11
- package/src/App.tsx +24 -24
- package/src/Playground.tsx +55 -55
- package/src/dummy-client.ts +1 -1
- package/src/fields/rich-text/index.tsx +2 -2
- package/src/fields/rich-text/monaco/error-message.tsx +54 -54
- package/src/fields/rich-text/monaco/index.tsx +137 -142
- package/src/fields/rich-text/monaco/use-debounce.ts +8 -8
- package/src/fields/rich-text/monaco/use-monaco.tsx +53 -0
- package/src/global.css +3 -3
- package/src/index.css +15 -15
- package/src/lib/build-form.ts +24 -24
- package/src/lib/errors.tsx +7 -7
- package/src/lib/expand-query.ts +66 -61
- package/src/lib/graphql-reducer.ts +295 -275
- package/src/lib/types.ts +35 -33
- package/src/lib/util.ts +41 -41
- package/src/main.tsx +7 -7
- package/src/preflight.css +10 -10
- package/src/preview.tsx +12 -12
- package/src/vite-env.d.ts +3 -3
|
@@ -1,166 +1,168 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import React from 'react'
|
|
8
|
-
import MonacoEditor, { useMonaco, loader } from '@monaco-editor/react'
|
|
9
|
-
/**
|
|
10
|
-
* MDX is built directly to the app because of how we load dependencies.
|
|
11
|
-
* Since we drop the package.json in to the end users folder, we can't
|
|
12
|
-
* easily install the current version of the mdx package in all scenarios
|
|
13
|
-
* (when we're working in the monorepo, or working with a tagged npm version)
|
|
14
|
-
*/
|
|
15
|
-
import { parseMDX, stringifyMDX } from '@tinacms/mdx'
|
|
16
|
-
import { useDebounce } from './use-debounce'
|
|
17
|
-
import type * as monaco from 'monaco-editor'
|
|
1
|
+
import MonacoEditor, { Monaco } from '@monaco-editor/react';
|
|
2
|
+
import { parseMDX, stringifyMDX } from '@tinacms/mdx';
|
|
3
|
+
import type * as monaco from 'monaco-editor';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { RichTextType } from 'tinacms';
|
|
18
6
|
import {
|
|
19
|
-
buildError,
|
|
20
7
|
ErrorMessage,
|
|
21
8
|
InvalidMarkdownElement,
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
buildError,
|
|
10
|
+
} from './error-message';
|
|
11
|
+
import { useDebounce } from './use-debounce';
|
|
12
|
+
import useCustomMonaco from './use-monaco';
|
|
24
13
|
|
|
25
14
|
export const uuid = () => {
|
|
26
|
-
// @ts-ignore
|
|
27
15
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
|
|
28
16
|
(
|
|
29
17
|
c ^
|
|
30
18
|
(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
|
|
31
19
|
).toString(16)
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type Monaco = typeof monaco
|
|
36
|
-
|
|
37
|
-
// 0.33.0 has a bug https://github.com/microsoft/monaco-editor/issues/2947
|
|
38
|
-
loader.config({
|
|
39
|
-
paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.31.1/min/vs' },
|
|
40
|
-
})
|
|
20
|
+
);
|
|
21
|
+
};
|
|
41
22
|
|
|
42
23
|
/**
|
|
43
24
|
* Since monaco lazy-loads we may have a delay from when the block is inserted
|
|
44
|
-
* to when monaco has
|
|
45
|
-
*
|
|
46
|
-
* Will try for 3 seconds before moving on
|
|
25
|
+
* to when monaco has instantiated.
|
|
47
26
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
setTimeout(() => {
|
|
55
|
-
retryCount = retryCount + 1
|
|
56
|
-
retryFocus(ref)
|
|
57
|
-
}, 100)
|
|
27
|
+
const retryFocus = (editor) => {
|
|
28
|
+
if (editor && editor.focus) {
|
|
29
|
+
try {
|
|
30
|
+
editor.focus();
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.warn('Error focusing editor:', err);
|
|
58
33
|
}
|
|
59
34
|
}
|
|
60
|
-
}
|
|
35
|
+
};
|
|
61
36
|
|
|
62
37
|
export const RawEditor = (props: RichTextType) => {
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const
|
|
38
|
+
const monacoInstance = useCustomMonaco();
|
|
39
|
+
const editorRef = React.useRef<monaco.editor.IStandaloneCodeEditor | null>(
|
|
40
|
+
null
|
|
41
|
+
);
|
|
42
|
+
const [height, setHeight] = React.useState(100);
|
|
43
|
+
const id = React.useMemo(() => uuid(), []);
|
|
44
|
+
const field = props.field;
|
|
45
|
+
|
|
46
|
+
// Get initial value safely
|
|
69
47
|
const inputValue = React.useMemo(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
48
|
+
try {
|
|
49
|
+
// @ts-ignore no access to the rich-text type from this package
|
|
50
|
+
const res = stringifyMDX(props.input.value, field, (value) => value);
|
|
51
|
+
return typeof props.input.value === 'string' ? props.input.value : res;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error('Error stringifying MDX:', err);
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
}, []); // Empty dependency array to only run once
|
|
57
|
+
|
|
58
|
+
const [value, setValue] = React.useState(inputValue);
|
|
59
|
+
const [error, setError] = React.useState<InvalidMarkdownElement>(null);
|
|
76
60
|
|
|
77
|
-
const debouncedValue = useDebounce(value, 500)
|
|
61
|
+
const debouncedValue = useDebounce(value, 500);
|
|
78
62
|
|
|
63
|
+
// Update parsed MDX when value changes
|
|
79
64
|
React.useEffect(() => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
parsedValue
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
let isMounted = true;
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
// @ts-ignore no access to the rich-text type from this package
|
|
69
|
+
const parsedValue = parseMDX(debouncedValue, field, (value) => value);
|
|
70
|
+
|
|
71
|
+
if (!isMounted) return;
|
|
72
|
+
|
|
73
|
+
if (
|
|
74
|
+
parsedValue.children[0] &&
|
|
75
|
+
parsedValue.children[0].type === 'invalid_markdown'
|
|
76
|
+
) {
|
|
77
|
+
setError(parsedValue.children[0]);
|
|
78
|
+
} else {
|
|
79
|
+
setError(null);
|
|
80
|
+
props.input.onChange(parsedValue);
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.error('Error parsing MDX:', err);
|
|
90
84
|
}
|
|
91
|
-
props.input.onChange(parsedValue)
|
|
92
|
-
}, [JSON.stringify(debouncedValue)])
|
|
93
85
|
|
|
86
|
+
return () => {
|
|
87
|
+
isMounted = false;
|
|
88
|
+
};
|
|
89
|
+
}, [debouncedValue, field]); // Only dependency should be the debounced value and field
|
|
90
|
+
|
|
91
|
+
// Handle error markers in editor
|
|
94
92
|
React.useEffect(() => {
|
|
95
|
-
if (
|
|
93
|
+
if (!monacoInstance || !editorRef.current) return;
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const model = editorRef.current.getModel();
|
|
97
|
+
if (!model) return;
|
|
98
|
+
|
|
96
99
|
if (error) {
|
|
97
|
-
const errorMessage = buildError(error)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
const errorMessage = buildError(error);
|
|
101
|
+
|
|
102
|
+
// Make sure all position properties are numbers (not undefined)
|
|
103
|
+
const markerData = {
|
|
104
|
+
message: errorMessage.message,
|
|
105
|
+
severity: monacoInstance.MarkerSeverity?.Error || 8,
|
|
106
|
+
startLineNumber: errorMessage.position?.startLineNumber || 1,
|
|
107
|
+
endLineNumber: errorMessage.position?.endLineNumber || 1,
|
|
108
|
+
startColumn: errorMessage.position?.startColumn || 1,
|
|
109
|
+
endColumn: errorMessage.position?.endColumn || 1,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
monacoInstance.editor.setModelMarkers(model, id, [markerData]);
|
|
105
113
|
} else {
|
|
106
|
-
|
|
107
|
-
monacoEditorRef.current.getModel(),
|
|
108
|
-
id,
|
|
109
|
-
[]
|
|
110
|
-
)
|
|
114
|
+
monacoInstance.editor.setModelMarkers(model, id, []);
|
|
111
115
|
}
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.error('Error setting model markers:', err);
|
|
112
118
|
}
|
|
113
|
-
}, [
|
|
119
|
+
}, [error, monacoInstance, id]);
|
|
114
120
|
|
|
121
|
+
// Configure TypeScript settings once when Monaco loads
|
|
115
122
|
React.useEffect(() => {
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// startColumn: word.startColumn,
|
|
131
|
-
// endColumn: word.endColumn,
|
|
132
|
-
// }
|
|
133
|
-
// return {
|
|
134
|
-
// suggestions: [
|
|
135
|
-
// {
|
|
136
|
-
// label: '<DateTime />',
|
|
137
|
-
// insertText: '<DateTime format="iso" />',
|
|
138
|
-
// kind: 0,
|
|
139
|
-
// range,
|
|
140
|
-
// },
|
|
141
|
-
// ],
|
|
142
|
-
// }
|
|
143
|
-
// },
|
|
144
|
-
// })
|
|
123
|
+
if (!monacoInstance) return;
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
monacoInstance.languages.typescript.typescriptDefaults.setEagerModelSync(
|
|
127
|
+
true
|
|
128
|
+
);
|
|
129
|
+
monacoInstance.languages.typescript.typescriptDefaults.setDiagnosticsOptions(
|
|
130
|
+
{
|
|
131
|
+
noSemanticValidation: true,
|
|
132
|
+
noSyntaxValidation: true,
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.error('Error configuring Monaco TypeScript settings:', err);
|
|
145
137
|
}
|
|
146
|
-
}, [
|
|
138
|
+
}, [monacoInstance]);
|
|
147
139
|
|
|
148
140
|
function handleEditorDidMount(
|
|
149
|
-
|
|
141
|
+
editor: monaco.editor.IStandaloneCodeEditor,
|
|
150
142
|
monaco: Monaco
|
|
151
143
|
) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
144
|
+
if (!editor) return;
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
editorRef.current = editor;
|
|
148
|
+
|
|
149
|
+
// Focus the editor once when mounted
|
|
150
|
+
setTimeout(() => editor.focus(), 100);
|
|
151
|
+
|
|
152
|
+
// Set up content size listener
|
|
153
|
+
editor.onDidContentSizeChange(() => {
|
|
154
|
+
const contentHeight = editor.getContentHeight();
|
|
155
|
+
setHeight(Math.min(Math.max(100, contentHeight), 1000));
|
|
156
|
+
editor.layout();
|
|
157
|
+
});
|
|
158
|
+
} catch (err) {
|
|
159
|
+
console.error('Error in editor mount handler:', err);
|
|
160
|
+
}
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
return (
|
|
162
|
-
<div className=
|
|
163
|
-
<div className=
|
|
164
|
+
<div className='relative'>
|
|
165
|
+
<div className='sticky top-1 w-full flex justify-between mb-2 z-50 max-w-full bg-white'>
|
|
164
166
|
<Button onClick={() => props.setRawMode(false)}>
|
|
165
167
|
View in rich-text editor 📝
|
|
166
168
|
</Button>
|
|
@@ -170,9 +172,6 @@ export const RawEditor = (props: RichTextType) => {
|
|
|
170
172
|
<MonacoEditor
|
|
171
173
|
path={id}
|
|
172
174
|
onMount={handleEditorDidMount}
|
|
173
|
-
// Setting a custom theme is kind of buggy because it doesn't get defined until monaco has mounted.
|
|
174
|
-
// So we end up with the default (light) theme in some scenarios. Seems like a race condition.
|
|
175
|
-
// theme="vs-dark"
|
|
176
175
|
options={{
|
|
177
176
|
scrollBeyondLastLine: false,
|
|
178
177
|
tabSize: 2,
|
|
@@ -190,30 +189,26 @@ export const RawEditor = (props: RichTextType) => {
|
|
|
190
189
|
lineNumbersMinChars: 2,
|
|
191
190
|
formatOnType: true,
|
|
192
191
|
fixedOverflowWidgets: true,
|
|
193
|
-
// Takes too much horizontal space for iframe
|
|
194
192
|
folding: false,
|
|
195
193
|
renderLineHighlight: 'none',
|
|
196
194
|
scrollbar: {
|
|
197
195
|
verticalScrollbarSize: 4,
|
|
198
196
|
horizontalScrollbarSize: 4,
|
|
199
|
-
// https://github.com/microsoft/monaco-editor/issues/2007#issuecomment-644425664
|
|
200
197
|
alwaysConsumeMouseWheel: false,
|
|
201
198
|
},
|
|
202
199
|
}}
|
|
203
|
-
language=
|
|
200
|
+
language='markdown'
|
|
204
201
|
value={value}
|
|
205
|
-
onChange={(
|
|
206
|
-
|
|
207
|
-
setValue(
|
|
208
|
-
} catch (e) {
|
|
209
|
-
console.log('error', e)
|
|
202
|
+
onChange={(newValue) => {
|
|
203
|
+
if (newValue !== undefined) {
|
|
204
|
+
setValue(newValue);
|
|
210
205
|
}
|
|
211
206
|
}}
|
|
212
207
|
/>
|
|
213
208
|
</div>
|
|
214
209
|
</div>
|
|
215
|
-
)
|
|
216
|
-
}
|
|
210
|
+
);
|
|
211
|
+
};
|
|
217
212
|
|
|
218
213
|
const Button = (props) => {
|
|
219
214
|
return (
|
|
@@ -223,14 +218,14 @@ const Button = (props) => {
|
|
|
223
218
|
? 'rounded-l-md border-r-0'
|
|
224
219
|
: 'rounded-r-md border-l-0'
|
|
225
220
|
} flex justify-center w-full shadow rounded-md bg-white cursor-pointer relative inline-flex items-center px-2 py-2 border border-gray-200 hover:text-white text-sm font-medium transition-all ease-out duration-150 hover:bg-blue-500 focus:z-10 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500`}
|
|
226
|
-
type=
|
|
221
|
+
type='button'
|
|
227
222
|
onClick={props.onClick}
|
|
228
223
|
>
|
|
229
|
-
<span className=
|
|
224
|
+
<span className='text-sm font-semibold tracking-wide align-baseline mr-1'>
|
|
230
225
|
{props.children}
|
|
231
226
|
</span>
|
|
232
227
|
</button>
|
|
233
|
-
)
|
|
234
|
-
}
|
|
228
|
+
);
|
|
229
|
+
};
|
|
235
230
|
|
|
236
|
-
export default RawEditor
|
|
231
|
+
export default RawEditor;
|
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
|
-
import { useState, useEffect } from 'react'
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
7
|
export function useDebounce(value, delay) {
|
|
8
|
-
const [debouncedValue, setDebouncedValue] = useState(value)
|
|
8
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
9
9
|
useEffect(
|
|
10
10
|
() => {
|
|
11
11
|
// Update debounced value after delay
|
|
12
12
|
const handler = setTimeout(() => {
|
|
13
|
-
setDebouncedValue(value)
|
|
14
|
-
}, delay)
|
|
13
|
+
setDebouncedValue(value);
|
|
14
|
+
}, delay);
|
|
15
15
|
// Cancel the timeout if value changes (also on delay change or unmount)
|
|
16
16
|
// This is how we prevent debounced value from updating if value is changed ...
|
|
17
17
|
// .. within the delay period. Timeout gets cleared and restarted.
|
|
18
18
|
return () => {
|
|
19
|
-
clearTimeout(handler)
|
|
20
|
-
}
|
|
19
|
+
clearTimeout(handler);
|
|
20
|
+
};
|
|
21
21
|
},
|
|
22
22
|
[value, delay] // Only re-call effect if value or delay changes
|
|
23
|
-
)
|
|
24
|
-
return debouncedValue
|
|
23
|
+
);
|
|
24
|
+
return debouncedValue;
|
|
25
25
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { loader } from '@monaco-editor/react';
|
|
2
|
+
import * as monaco from 'monaco-editor';
|
|
3
|
+
// hooks/useCustomMonaco.ts
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export function useCustomMonaco() {
|
|
7
|
+
const [monacoInstance, setMonacoInstance] = useState<typeof monaco | null>(
|
|
8
|
+
null
|
|
9
|
+
);
|
|
10
|
+
const mountedRef = useRef(true);
|
|
11
|
+
const loaderRef = useRef<any>(null);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const instance = loader.__getMonacoInstance();
|
|
15
|
+
|
|
16
|
+
if (instance) {
|
|
17
|
+
setMonacoInstance(instance);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!loaderRef.current) {
|
|
22
|
+
loader.config({
|
|
23
|
+
'vs/nls': { availableLanguages: {} },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
loaderRef.current = loader.init();
|
|
28
|
+
|
|
29
|
+
loaderRef.current
|
|
30
|
+
.then((monacoApi: typeof monaco) => {
|
|
31
|
+
if (mountedRef.current) {
|
|
32
|
+
setMonacoInstance(monacoApi);
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
.catch((error: any) => {
|
|
36
|
+
if (mountedRef.current && error.type !== 'cancelation') {
|
|
37
|
+
console.error('Monaco initialization error:', error);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error('Failed to initialize Monaco:', err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
mountedRef.current = false;
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
return monacoInstance;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default useCustomMonaco;
|
package/src/global.css
CHANGED
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
--tina-font-size-7: 26px;
|
|
41
41
|
--tina-font-size-8: 32px;
|
|
42
42
|
|
|
43
|
-
--tina-font-family:
|
|
43
|
+
--tina-font-family: "Inter", sans-serif;
|
|
44
44
|
|
|
45
45
|
--tina-font-weight-regular: 400;
|
|
46
46
|
--tina-font-weight-bold: 600;
|
|
47
47
|
|
|
48
|
-
--tina-shadow-big: 0px 2px 3px rgba(0, 0, 0, 0.05),
|
|
49
|
-
|
|
48
|
+
--tina-shadow-big: 0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px
|
|
49
|
+
rgba(0, 0, 0, 0.1);
|
|
50
50
|
--tina-shadow-small: 0px 2px 3px rgba(0, 0, 0, 0.12);
|
|
51
51
|
|
|
52
52
|
--tina-timing-short: 85ms;
|
package/src/index.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@import
|
|
2
|
-
@import
|
|
1
|
+
@import "global.css";
|
|
2
|
+
@import "preflight.css";
|
|
3
3
|
@tailwind base;
|
|
4
4
|
@tailwind components;
|
|
5
5
|
@tailwind utilities;
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
body {
|
|
17
17
|
margin: 0;
|
|
18
18
|
padding: 0;
|
|
19
|
-
font-family: -apple-system, BlinkMacSystemFont,
|
|
20
|
-
|
|
19
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
|
20
|
+
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
|
21
21
|
sans-serif;
|
|
22
22
|
-webkit-font-smoothing: antialiased;
|
|
23
23
|
-moz-osx-font-smoothing: grayscale;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
code {
|
|
27
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas,
|
|
27
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
|
28
28
|
monospace;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -38,32 +38,32 @@ div.graphiql-explorer-root > div:last-child {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/* if the last block has margin-bottom it makes the text box larger but some of it isn't clickable */
|
|
41
|
-
.tina-prose [data-slate-editor=
|
|
41
|
+
.tina-prose [data-slate-editor="true"] {
|
|
42
42
|
padding-bottom: 0.5em;
|
|
43
43
|
/* Outline is placed on the parent element for styling consistency with other elements */
|
|
44
44
|
outline: none;
|
|
45
45
|
}
|
|
46
46
|
/* prose adds backticks, which look like they should be editable */
|
|
47
|
-
.tina-prose [data-slate-editor=
|
|
48
|
-
content:
|
|
47
|
+
.tina-prose [data-slate-editor="true"] .slate-code::before {
|
|
48
|
+
content: "";
|
|
49
49
|
}
|
|
50
|
-
.tina-prose [data-slate-editor=
|
|
51
|
-
content:
|
|
50
|
+
.tina-prose [data-slate-editor="true"] .slate-code::after {
|
|
51
|
+
content: "";
|
|
52
52
|
}
|
|
53
|
-
.tina-prose [data-slate-editor=
|
|
53
|
+
.tina-prose [data-slate-editor="true"] .slate-code_block {
|
|
54
54
|
margin: 0;
|
|
55
55
|
}
|
|
56
56
|
/* code lines as part of a block don't need the same background formatting */
|
|
57
|
-
.tina-prose [data-slate-editor=
|
|
57
|
+
.tina-prose [data-slate-editor="true"] .slate-code_block .slate-code {
|
|
58
58
|
background: none;
|
|
59
59
|
}
|
|
60
60
|
/* prose makes the first p in a block slightly larger */
|
|
61
|
-
.tina-prose [data-slate-editor=
|
|
61
|
+
.tina-prose [data-slate-editor="true"] p:first-of-type {
|
|
62
62
|
font-size: 1em;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/* experimental floating toolbar doesn't need a large text area */
|
|
66
|
-
.with-toolbar [data-slate-editor=
|
|
66
|
+
.with-toolbar [data-slate-editor="true"] {
|
|
67
67
|
min-height: 72px;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -190,7 +190,7 @@ div.graphiql-explorer-root > div:last-child {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
.tina-date-field .rdtPicker td.rdtToday:before {
|
|
193
|
-
content:
|
|
193
|
+
content: "";
|
|
194
194
|
display: inline-block;
|
|
195
195
|
border-left: 7px solid transparent;
|
|
196
196
|
border-bottom: 7px solid var(--tina-color-primary);
|
package/src/lib/build-form.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { Field, Form, FormOptions, TinaCMS, TinaField } from 'tinacms'
|
|
1
|
+
import { Field, Form, FormOptions, TinaCMS, TinaField } from 'tinacms';
|
|
2
2
|
|
|
3
|
-
export type FieldType = Field & TinaField
|
|
4
|
-
export type FormValues = Record<string, unknown
|
|
5
|
-
export type FormType = Form<FormValues, FieldType
|
|
3
|
+
export type FieldType = Field & TinaField;
|
|
4
|
+
export type FormValues = Record<string, unknown>;
|
|
5
|
+
export type FormType = Form<FormValues, FieldType>;
|
|
6
6
|
|
|
7
|
-
type FormCreator = (formConfig: FormOptions<any>) => Form
|
|
7
|
+
type FormCreator = (formConfig: FormOptions<any>) => Form;
|
|
8
8
|
interface GlobalFormOptions {
|
|
9
|
-
icon?: any
|
|
10
|
-
layout: 'fullscreen' | 'popup'
|
|
9
|
+
icon?: any;
|
|
10
|
+
layout: 'fullscreen' | 'popup';
|
|
11
11
|
}
|
|
12
12
|
type GlobalFormCreator = (
|
|
13
13
|
formConfig: FormOptions<any>,
|
|
14
14
|
options?: GlobalFormOptions
|
|
15
|
-
) => Form
|
|
15
|
+
) => Form;
|
|
16
16
|
interface GlobalFormOptions {
|
|
17
|
-
icon?: any
|
|
18
|
-
layout: 'fullscreen' | 'popup'
|
|
17
|
+
icon?: any;
|
|
18
|
+
layout: 'fullscreen' | 'popup';
|
|
19
19
|
}
|
|
20
20
|
export interface FormifyArgs {
|
|
21
|
-
formConfig: FormOptions<any
|
|
22
|
-
createForm: FormCreator
|
|
23
|
-
createGlobalForm: FormCreator
|
|
24
|
-
skip?: () => void
|
|
21
|
+
formConfig: FormOptions<any>;
|
|
22
|
+
createForm: FormCreator;
|
|
23
|
+
createGlobalForm: FormCreator;
|
|
24
|
+
skip?: () => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export type FormifyCallback = (args: FormifyArgs, cms: TinaCMS) => Form | void
|
|
27
|
+
export type FormifyCallback = (args: FormifyArgs, cms: TinaCMS) => Form | void;
|
|
28
28
|
export type onSubmitArgs = {
|
|
29
29
|
/**
|
|
30
30
|
* @deprecated queryString is actually a mutation string, use `mutationString` instead
|
|
31
31
|
*/
|
|
32
|
-
queryString: string
|
|
33
|
-
mutationString: string
|
|
34
|
-
variables: object
|
|
35
|
-
}
|
|
32
|
+
queryString: string;
|
|
33
|
+
mutationString: string;
|
|
34
|
+
variables: object;
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
export const createForm = (formConfig: FormOptions<any, any>) => {
|
|
38
|
-
return new Form(formConfig)
|
|
39
|
-
}
|
|
38
|
+
return new Form(formConfig);
|
|
39
|
+
};
|
|
40
40
|
export const createGlobalForm: GlobalFormCreator = (
|
|
41
41
|
formConfig,
|
|
42
42
|
options?: { icon?: any; layout: 'fullscreen' | 'popup' }
|
|
@@ -44,6 +44,6 @@ export const createGlobalForm: GlobalFormCreator = (
|
|
|
44
44
|
const form = new Form({
|
|
45
45
|
...formConfig,
|
|
46
46
|
global: { global: true, ...options },
|
|
47
|
-
})
|
|
48
|
-
return form
|
|
49
|
-
}
|
|
47
|
+
});
|
|
48
|
+
return form;
|
|
49
|
+
};
|
package/src/lib/errors.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { TinaCMS } from 'tinacms'
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TinaCMS } from 'tinacms';
|
|
3
3
|
|
|
4
4
|
const ErrorModalContent = (props: { title: string; errors: string[] }) => {
|
|
5
|
-
const { title, errors } = props
|
|
5
|
+
const { title, errors } = props;
|
|
6
6
|
return (
|
|
7
7
|
<>
|
|
8
8
|
<div>{title}</div>
|
|
@@ -12,13 +12,13 @@ const ErrorModalContent = (props: { title: string; errors: string[] }) => {
|
|
|
12
12
|
))}
|
|
13
13
|
</ul>
|
|
14
14
|
</>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
export const showErrorModal = (
|
|
19
19
|
title: string,
|
|
20
20
|
errors: string[],
|
|
21
21
|
cms: TinaCMS
|
|
22
22
|
) => {
|
|
23
|
-
cms.alerts.error(() => <ErrorModalContent title={title} errors={errors} />)
|
|
24
|
-
}
|
|
23
|
+
cms.alerts.error(() => <ErrorModalContent title={title} errors={errors} />);
|
|
24
|
+
};
|