lkb-fields-document 1.0.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/component-blocks/dist/lkb-fields-document-component-blocks.cjs.d.ts +2 -0
- package/component-blocks/dist/lkb-fields-document-component-blocks.cjs.js +306 -0
- package/component-blocks/dist/lkb-fields-document-component-blocks.esm.js +300 -0
- package/component-blocks/dist/lkb-fields-document-component-blocks.node.cjs.js +306 -0
- package/component-blocks/dist/lkb-fields-document-component-blocks.node.esm.js +300 -0
- package/component-blocks/package.json +4 -0
- package/dist/Cell-0ac0ac66.node.cjs.js +21 -0
- package/dist/Cell-242f7404.esm.js +17 -0
- package/dist/Cell-3103f73d.node.esm.js +17 -0
- package/dist/Cell-bfb56d74.cjs.js +21 -0
- package/dist/Field-0e0f75ed.node.cjs.js +1628 -0
- package/dist/Field-28177061.cjs.js +1628 -0
- package/dist/Field-35b79e6b.node.esm.js +1619 -0
- package/dist/Field-92d13205.esm.js +1619 -0
- package/dist/api-2f524611.esm.js +502 -0
- package/dist/api-73636987.cjs.js +506 -0
- package/dist/api-8e2b20b8.node.cjs.js +506 -0
- package/dist/api-c32e360e.node.esm.js +502 -0
- package/dist/callout-ui-2aded278.cjs.js +131 -0
- package/dist/callout-ui-3e5ca544.node.esm.js +126 -0
- package/dist/callout-ui-8b5f2376.esm.js +126 -0
- package/dist/callout-ui-ad50f301.node.cjs.js +131 -0
- package/dist/declarations/src/component-blocks.d.ts +4 -0
- package/dist/declarations/src/component-blocks.d.ts.map +1 -0
- package/dist/declarations/src/document-editor/component-blocks/api.d.ts +120 -0
- package/dist/declarations/src/document-editor/component-blocks/api.d.ts.map +1 -0
- package/dist/declarations/src/document-editor/component-blocks/types.d.ts +241 -0
- package/dist/declarations/src/document-editor/component-blocks/types.d.ts.map +1 -0
- package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts +10 -0
- package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +7 -0
- package/dist/declarations/src/index.d.ts.map +1 -0
- package/dist/declarations/src/my-component-blocks/index.d.ts +46 -0
- package/dist/declarations/src/my-component-blocks/index.d.ts.map +1 -0
- package/dist/declarations/src/structure/Cell.d.ts +5 -0
- package/dist/declarations/src/structure/Cell.d.ts.map +1 -0
- package/dist/declarations/src/structure/Field.d.ts +5 -0
- package/dist/declarations/src/structure/Field.d.ts.map +1 -0
- package/dist/declarations/src/structure/controller.d.ts +10 -0
- package/dist/declarations/src/structure/controller.d.ts.map +1 -0
- package/dist/declarations/src/structure/structure.d.ts +4 -0
- package/dist/declarations/src/structure/structure.d.ts.map +1 -0
- package/dist/declarations/src/structure-views.d.ts +5 -0
- package/dist/declarations/src/structure-views.d.ts.map +1 -0
- package/dist/declarations/src/types/DocumentFeatures.d.ts +33 -0
- package/dist/declarations/src/types/DocumentFeatures.d.ts.map +1 -0
- package/dist/declarations/src/types/DocumentFieldConfig.d.ts +18 -0
- package/dist/declarations/src/types/DocumentFieldConfig.d.ts.map +1 -0
- package/dist/declarations/src/types/FormattingConfig.d.ts +28 -0
- package/dist/declarations/src/types/FormattingConfig.d.ts.map +1 -0
- package/dist/declarations/src/types/RelationshipsConfig.d.ts +9 -0
- package/dist/declarations/src/types/RelationshipsConfig.d.ts.map +1 -0
- package/dist/declarations/src/types/StructureFieldConfig.d.ts +10 -0
- package/dist/declarations/src/types/StructureFieldConfig.d.ts.map +1 -0
- package/dist/declarations/src/validation/structure-validation.d.ts +218 -0
- package/dist/declarations/src/validation/structure-validation.d.ts.map +1 -0
- package/dist/declarations/src/views/Cell.d.ts +5 -0
- package/dist/declarations/src/views/Cell.d.ts.map +1 -0
- package/dist/declarations/src/views/Field.d.ts +5 -0
- package/dist/declarations/src/views/Field.d.ts.map +1 -0
- package/dist/declarations/src/views/controller.d.ts +15 -0
- package/dist/declarations/src/views/controller.d.ts.map +1 -0
- package/dist/declarations/src/views/document.d.ts +4 -0
- package/dist/declarations/src/views/document.d.ts.map +1 -0
- package/dist/declarations/src/views.d.ts +7 -0
- package/dist/declarations/src/views.d.ts.map +1 -0
- package/dist/editor-shared-a6e340e6.node.esm.js +1993 -0
- package/dist/editor-shared-a997ae98.node.cjs.js +2007 -0
- package/dist/editor-shared-cc1293ed.cjs.js +2007 -0
- package/dist/editor-shared-da518ba3.esm.js +1993 -0
- package/dist/form-from-preview-2042b9ef.cjs.js +512 -0
- package/dist/form-from-preview-5df6e492.node.esm.js +508 -0
- package/dist/form-from-preview-9e501058.node.cjs.js +512 -0
- package/dist/form-from-preview-b3a66f37.esm.js +508 -0
- package/dist/index-06c36775.cjs.js +14 -0
- package/dist/index-586adb8f.node.esm.js +11 -0
- package/dist/index-67d52357.esm.js +11 -0
- package/dist/index-c3223fdc.node.cjs.js +14 -0
- package/dist/layouts-6412fa2a.esm.js +189 -0
- package/dist/layouts-a4a3cf0b.node.cjs.js +196 -0
- package/dist/layouts-ba9a558b.cjs.js +196 -0
- package/dist/layouts-e653b908.node.esm.js +189 -0
- package/dist/lkb-fields-document.cjs.d.ts +2 -0
- package/dist/lkb-fields-document.cjs.js +1167 -0
- package/dist/lkb-fields-document.esm.js +1162 -0
- package/dist/lkb-fields-document.node.cjs.js +1167 -0
- package/dist/lkb-fields-document.node.esm.js +1162 -0
- package/dist/shared-0533009e.cjs.js +594 -0
- package/dist/shared-4684cc24.node.cjs.js +594 -0
- package/dist/shared-5e864055.node.esm.js +579 -0
- package/dist/shared-aaba5901.esm.js +579 -0
- package/dist/toolbar-state-3359e2f3.cjs.js +994 -0
- package/dist/toolbar-state-945823b8.node.esm.js +971 -0
- package/dist/toolbar-state-9611743f.node.cjs.js +994 -0
- package/dist/toolbar-state-bc8fe661.esm.js +971 -0
- package/dist/utils-06bcddc4.node.cjs.js +747 -0
- package/dist/utils-200ff260.node.esm.js +722 -0
- package/dist/utils-6409f730.cjs.js +747 -0
- package/dist/utils-bc6a0b82.esm.js +722 -0
- package/package.json +118 -0
- package/structure-views/dist/lkb-fields-document-structure-views.cjs.d.ts +2 -0
- package/structure-views/dist/lkb-fields-document-structure-views.cjs.js +138 -0
- package/structure-views/dist/lkb-fields-document-structure-views.esm.js +131 -0
- package/structure-views/dist/lkb-fields-document-structure-views.node.cjs.js +138 -0
- package/structure-views/dist/lkb-fields-document-structure-views.node.esm.js +131 -0
- package/structure-views/package.json +4 -0
- package/views/dist/lkb-fields-document-views.cjs.d.ts +2 -0
- package/views/dist/lkb-fields-document-views.cjs.js +114 -0
- package/views/dist/lkb-fields-document-views.esm.js +95 -0
- package/views/dist/lkb-fields-document-views.node.cjs.js +114 -0
- package/views/dist/lkb-fields-document-views.node.esm.js +95 -0
- package/views/package.json +4 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var api = require('../../dist/api-8e2b20b8.node.cjs.js');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var layout = require('@keystar/ui/layout');
|
|
9
|
+
var style = require('@keystar/ui/style');
|
|
10
|
+
var callout_ui = require('../../dist/callout-ui-ad50f301.node.cjs.js');
|
|
11
|
+
require('lkb-core');
|
|
12
|
+
require('@keystar/ui/button');
|
|
13
|
+
require('@keystar/ui/drag-and-drop');
|
|
14
|
+
require('react');
|
|
15
|
+
require('../../dist/index-c3223fdc.node.cjs.js');
|
|
16
|
+
require('slate');
|
|
17
|
+
require('@braintree/sanitize-url');
|
|
18
|
+
require('@react-aria/i18n');
|
|
19
|
+
require('@keystar/ui/number-field');
|
|
20
|
+
require('@keystar/ui/picker');
|
|
21
|
+
require('@keystar/ui/combobox');
|
|
22
|
+
require('@keystar/ui/text-field');
|
|
23
|
+
require('@keystar/ui/tag');
|
|
24
|
+
require('@keystar/ui/typography');
|
|
25
|
+
require('@keystar/ui/checkbox');
|
|
26
|
+
|
|
27
|
+
const quoteBlock = api.component({
|
|
28
|
+
preview: props => {
|
|
29
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
30
|
+
style: {
|
|
31
|
+
borderLeft: '3px solid #CBD5E0',
|
|
32
|
+
paddingLeft: 16
|
|
33
|
+
},
|
|
34
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
35
|
+
style: {
|
|
36
|
+
fontStyle: 'italic',
|
|
37
|
+
color: '#4A5568'
|
|
38
|
+
},
|
|
39
|
+
children: props.fields.content.element
|
|
40
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
41
|
+
style: {
|
|
42
|
+
fontWeight: 'bold',
|
|
43
|
+
color: '#718096'
|
|
44
|
+
},
|
|
45
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(api.NotEditable, {
|
|
46
|
+
children: "\u2014 "
|
|
47
|
+
}), props.fields.attribution.element]
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
label: '内容引用',
|
|
52
|
+
schema: {
|
|
53
|
+
content: api.fields.child({
|
|
54
|
+
kind: 'block',
|
|
55
|
+
placeholder: 'Quote...',
|
|
56
|
+
formatting: {
|
|
57
|
+
inlineMarks: 'inherit',
|
|
58
|
+
softBreaks: 'inherit'
|
|
59
|
+
},
|
|
60
|
+
links: 'inherit'
|
|
61
|
+
}),
|
|
62
|
+
attribution: api.fields.child({
|
|
63
|
+
kind: 'inline',
|
|
64
|
+
placeholder: 'Attribution...'
|
|
65
|
+
})
|
|
66
|
+
},
|
|
67
|
+
chromeless: true
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const carousel = api.component({
|
|
71
|
+
label: '旋转木马',
|
|
72
|
+
preview: function Preview(props) {
|
|
73
|
+
return /*#__PURE__*/jsxRuntime.jsx(api.NotEditable, {
|
|
74
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
75
|
+
className: style.css({
|
|
76
|
+
overflowY: 'scroll',
|
|
77
|
+
display: 'flex',
|
|
78
|
+
scrollSnapType: 'y mandatory'
|
|
79
|
+
}),
|
|
80
|
+
children: props.fields.items.elements.map(item => {
|
|
81
|
+
return /*#__PURE__*/jsxRuntime.jsxs(layout.Box, {
|
|
82
|
+
margin: "xsmall",
|
|
83
|
+
className: style.css({
|
|
84
|
+
minWidth: '61.8%',
|
|
85
|
+
scrollSnapAlign: 'center',
|
|
86
|
+
scrollSnapStop: 'always',
|
|
87
|
+
margin: 4,
|
|
88
|
+
padding: 8,
|
|
89
|
+
boxSizing: 'border-box',
|
|
90
|
+
borderRadius: 6,
|
|
91
|
+
background: '#eff3f6'
|
|
92
|
+
}),
|
|
93
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("img", {
|
|
94
|
+
role: "presentation",
|
|
95
|
+
src: item.fields.imageSrc.value,
|
|
96
|
+
className: style.css({
|
|
97
|
+
objectFit: 'cover',
|
|
98
|
+
objectPosition: 'center center',
|
|
99
|
+
height: 240,
|
|
100
|
+
width: '100%',
|
|
101
|
+
borderRadius: 4
|
|
102
|
+
})
|
|
103
|
+
}), /*#__PURE__*/jsxRuntime.jsx("h1", {
|
|
104
|
+
className: style.css({
|
|
105
|
+
'&&': {
|
|
106
|
+
fontSize: '1.25rem',
|
|
107
|
+
lineHeight: 'unset',
|
|
108
|
+
marginTop: 8
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
children: item.fields.title.value
|
|
112
|
+
})]
|
|
113
|
+
}, item.key);
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
schema: {
|
|
119
|
+
items: api.fields.array(api.fields.object({
|
|
120
|
+
title: api.fields.text({
|
|
121
|
+
label: '标题'
|
|
122
|
+
}),
|
|
123
|
+
imageSrc: api.fields.url({
|
|
124
|
+
label: '图片 URL',
|
|
125
|
+
defaultValue: '/assets/images/placeholder.jpeg'
|
|
126
|
+
})
|
|
127
|
+
}))
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const callout = api.component({
|
|
132
|
+
preview: function (props) {
|
|
133
|
+
return /*#__PURE__*/jsxRuntime.jsx(callout_ui.Callout, {
|
|
134
|
+
tone: props.fields.tone.value,
|
|
135
|
+
children: props.fields.content.element
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
label: '提示面板',
|
|
139
|
+
chromeless: true,
|
|
140
|
+
schema: {
|
|
141
|
+
tone: api.fields.select({
|
|
142
|
+
label: 'Tone',
|
|
143
|
+
options: [{
|
|
144
|
+
value: 'info',
|
|
145
|
+
label: '消息'
|
|
146
|
+
}, {
|
|
147
|
+
value: 'caution',
|
|
148
|
+
label: '警告'
|
|
149
|
+
}, {
|
|
150
|
+
value: 'positive',
|
|
151
|
+
label: '成功'
|
|
152
|
+
}, {
|
|
153
|
+
value: 'critical',
|
|
154
|
+
label: '错误'
|
|
155
|
+
}],
|
|
156
|
+
defaultValue: 'info'
|
|
157
|
+
}),
|
|
158
|
+
content: api.fields.child({
|
|
159
|
+
kind: 'block',
|
|
160
|
+
placeholder: '',
|
|
161
|
+
formatting: 'inherit',
|
|
162
|
+
dividers: 'inherit',
|
|
163
|
+
links: 'inherit'
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
toolbar({
|
|
167
|
+
props,
|
|
168
|
+
onRemove
|
|
169
|
+
}) {
|
|
170
|
+
return /*#__PURE__*/jsxRuntime.jsx(callout_ui.CalloutToolbar, {
|
|
171
|
+
onChange: tone => {
|
|
172
|
+
props.fields.tone.onChange(tone);
|
|
173
|
+
},
|
|
174
|
+
onRemove: onRemove,
|
|
175
|
+
tone: props.fields.tone.value,
|
|
176
|
+
tones: props.fields.tone.schema.options
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// 上传函数
|
|
182
|
+
async function uploadImage(albumId, file, name, altText) {
|
|
183
|
+
const operations = {
|
|
184
|
+
variables: {
|
|
185
|
+
data: {
|
|
186
|
+
name,
|
|
187
|
+
altText,
|
|
188
|
+
image: {
|
|
189
|
+
upload: null
|
|
190
|
+
},
|
|
191
|
+
album: {
|
|
192
|
+
connect: {
|
|
193
|
+
id: albumId
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
query: `mutation ($data: ImageCreateInput!) {
|
|
199
|
+
item: createImage(data: $data) {
|
|
200
|
+
id
|
|
201
|
+
name
|
|
202
|
+
image { url }
|
|
203
|
+
album { id name }
|
|
204
|
+
__typename
|
|
205
|
+
}
|
|
206
|
+
}`
|
|
207
|
+
};
|
|
208
|
+
const map = {
|
|
209
|
+
'1': ['variables.data.image.upload']
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// useMutation
|
|
213
|
+
const formData = new FormData();
|
|
214
|
+
formData.append('operations', JSON.stringify(operations));
|
|
215
|
+
formData.append('map', JSON.stringify(map));
|
|
216
|
+
formData.append('1', file); // 这里的 '1' 对应 map 中的键
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
const response = await fetch('/api/graphql', {
|
|
220
|
+
method: 'POST',
|
|
221
|
+
body: formData,
|
|
222
|
+
headers: {
|
|
223
|
+
'x-apollo-operation-name': 'UploadImage',
|
|
224
|
+
'apollo-require-preflight': 'true'
|
|
225
|
+
}
|
|
226
|
+
// 注意:不要手动设置 Content-Type,浏览器会自动设置正确的 boundary
|
|
227
|
+
});
|
|
228
|
+
const result = await response.json();
|
|
229
|
+
if (result.errors) {
|
|
230
|
+
throw new Error(result.errors[0].message);
|
|
231
|
+
}
|
|
232
|
+
return result.data.item;
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.log('上传失败:', error);
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const Image = api.component({
|
|
240
|
+
label: '图片',
|
|
241
|
+
schema: {
|
|
242
|
+
webImageUrl: api.fields.text({
|
|
243
|
+
label: 'Web 图片地址'
|
|
244
|
+
}),
|
|
245
|
+
uploadedImageUrl: api.fields.file({
|
|
246
|
+
label: '使用上传的图片',
|
|
247
|
+
allowedFileTypes: ['image/png', 'image/jpg', 'image/jpeg', 'image/gif', 'image/webp'],
|
|
248
|
+
isImage: true,
|
|
249
|
+
onUpload(file) {
|
|
250
|
+
// console.log(file)
|
|
251
|
+
return new Promise((resolve, reject) => {
|
|
252
|
+
// 使用固定的 albumId:cmhepys2l0000dd2m4cxaozc8,文档相关的临时图片都存放在这儿。
|
|
253
|
+
try {
|
|
254
|
+
uploadImage('cmhepys2l0000dd2m4cxaozc8', file, file.name).then(ret => resolve(ret.image.url)).catch(reject);
|
|
255
|
+
} catch (e) {
|
|
256
|
+
reject(e);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}),
|
|
261
|
+
caption: api.fields.conditional(api.fields.checkbox({
|
|
262
|
+
label: '显示图片描述'
|
|
263
|
+
}), {
|
|
264
|
+
false: api.fields.empty(),
|
|
265
|
+
true: api.fields.child({
|
|
266
|
+
kind: 'block',
|
|
267
|
+
placeholder: '输入图片描述',
|
|
268
|
+
formatting: 'inherit',
|
|
269
|
+
links: 'inherit'
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
},
|
|
273
|
+
preview: function Image(props) {
|
|
274
|
+
const imageUrl = props.fields.webImageUrl.value || props.fields.uploadedImageUrl.value || '/assets/images/placeholder.jpeg';
|
|
275
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
276
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(api.NotEditable, {
|
|
277
|
+
children: /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
278
|
+
src: imageUrl,
|
|
279
|
+
className: style.css({
|
|
280
|
+
display: 'block',
|
|
281
|
+
width: '100%',
|
|
282
|
+
minHeight: 10
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
}), props.fields.caption.discriminant ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
286
|
+
className: style.css({
|
|
287
|
+
textAlign: 'center',
|
|
288
|
+
marginTop: 5
|
|
289
|
+
}),
|
|
290
|
+
children: props.fields.caption.value.element
|
|
291
|
+
}) : null]
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const componentBlocks = {
|
|
297
|
+
quoteBlock,
|
|
298
|
+
carousel,
|
|
299
|
+
callout,
|
|
300
|
+
Image
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
exports.NotEditable = api.NotEditable;
|
|
304
|
+
exports.component = api.component;
|
|
305
|
+
exports.fields = api.fields;
|
|
306
|
+
exports.componentBlocks = componentBlocks;
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { c as component, N as NotEditable, f as fields } from '../../dist/api-c32e360e.node.esm.js';
|
|
3
|
+
export { N as NotEditable, c as component, f as fields } from '../../dist/api-c32e360e.node.esm.js';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
import { Box } from '@keystar/ui/layout';
|
|
6
|
+
import { css } from '@keystar/ui/style';
|
|
7
|
+
import { Callout, CalloutToolbar } from '../../dist/callout-ui-3e5ca544.node.esm.js';
|
|
8
|
+
import 'lkb-core';
|
|
9
|
+
import '@keystar/ui/button';
|
|
10
|
+
import '@keystar/ui/drag-and-drop';
|
|
11
|
+
import 'react';
|
|
12
|
+
import '../../dist/index-586adb8f.node.esm.js';
|
|
13
|
+
import 'slate';
|
|
14
|
+
import '@braintree/sanitize-url';
|
|
15
|
+
import '@react-aria/i18n';
|
|
16
|
+
import '@keystar/ui/number-field';
|
|
17
|
+
import '@keystar/ui/picker';
|
|
18
|
+
import '@keystar/ui/combobox';
|
|
19
|
+
import '@keystar/ui/text-field';
|
|
20
|
+
import '@keystar/ui/tag';
|
|
21
|
+
import '@keystar/ui/typography';
|
|
22
|
+
import '@keystar/ui/checkbox';
|
|
23
|
+
|
|
24
|
+
const quoteBlock = component({
|
|
25
|
+
preview: props => {
|
|
26
|
+
return /*#__PURE__*/jsxs("div", {
|
|
27
|
+
style: {
|
|
28
|
+
borderLeft: '3px solid #CBD5E0',
|
|
29
|
+
paddingLeft: 16
|
|
30
|
+
},
|
|
31
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
32
|
+
style: {
|
|
33
|
+
fontStyle: 'italic',
|
|
34
|
+
color: '#4A5568'
|
|
35
|
+
},
|
|
36
|
+
children: props.fields.content.element
|
|
37
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
38
|
+
style: {
|
|
39
|
+
fontWeight: 'bold',
|
|
40
|
+
color: '#718096'
|
|
41
|
+
},
|
|
42
|
+
children: [/*#__PURE__*/jsx(NotEditable, {
|
|
43
|
+
children: "\u2014 "
|
|
44
|
+
}), props.fields.attribution.element]
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
label: '内容引用',
|
|
49
|
+
schema: {
|
|
50
|
+
content: fields.child({
|
|
51
|
+
kind: 'block',
|
|
52
|
+
placeholder: 'Quote...',
|
|
53
|
+
formatting: {
|
|
54
|
+
inlineMarks: 'inherit',
|
|
55
|
+
softBreaks: 'inherit'
|
|
56
|
+
},
|
|
57
|
+
links: 'inherit'
|
|
58
|
+
}),
|
|
59
|
+
attribution: fields.child({
|
|
60
|
+
kind: 'inline',
|
|
61
|
+
placeholder: 'Attribution...'
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
chromeless: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const carousel = component({
|
|
68
|
+
label: '旋转木马',
|
|
69
|
+
preview: function Preview(props) {
|
|
70
|
+
return /*#__PURE__*/jsx(NotEditable, {
|
|
71
|
+
children: /*#__PURE__*/jsx("div", {
|
|
72
|
+
className: css({
|
|
73
|
+
overflowY: 'scroll',
|
|
74
|
+
display: 'flex',
|
|
75
|
+
scrollSnapType: 'y mandatory'
|
|
76
|
+
}),
|
|
77
|
+
children: props.fields.items.elements.map(item => {
|
|
78
|
+
return /*#__PURE__*/jsxs(Box, {
|
|
79
|
+
margin: "xsmall",
|
|
80
|
+
className: css({
|
|
81
|
+
minWidth: '61.8%',
|
|
82
|
+
scrollSnapAlign: 'center',
|
|
83
|
+
scrollSnapStop: 'always',
|
|
84
|
+
margin: 4,
|
|
85
|
+
padding: 8,
|
|
86
|
+
boxSizing: 'border-box',
|
|
87
|
+
borderRadius: 6,
|
|
88
|
+
background: '#eff3f6'
|
|
89
|
+
}),
|
|
90
|
+
children: [/*#__PURE__*/jsx("img", {
|
|
91
|
+
role: "presentation",
|
|
92
|
+
src: item.fields.imageSrc.value,
|
|
93
|
+
className: css({
|
|
94
|
+
objectFit: 'cover',
|
|
95
|
+
objectPosition: 'center center',
|
|
96
|
+
height: 240,
|
|
97
|
+
width: '100%',
|
|
98
|
+
borderRadius: 4
|
|
99
|
+
})
|
|
100
|
+
}), /*#__PURE__*/jsx("h1", {
|
|
101
|
+
className: css({
|
|
102
|
+
'&&': {
|
|
103
|
+
fontSize: '1.25rem',
|
|
104
|
+
lineHeight: 'unset',
|
|
105
|
+
marginTop: 8
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
children: item.fields.title.value
|
|
109
|
+
})]
|
|
110
|
+
}, item.key);
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
schema: {
|
|
116
|
+
items: fields.array(fields.object({
|
|
117
|
+
title: fields.text({
|
|
118
|
+
label: '标题'
|
|
119
|
+
}),
|
|
120
|
+
imageSrc: fields.url({
|
|
121
|
+
label: '图片 URL',
|
|
122
|
+
defaultValue: '/assets/images/placeholder.jpeg'
|
|
123
|
+
})
|
|
124
|
+
}))
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const callout = component({
|
|
129
|
+
preview: function (props) {
|
|
130
|
+
return /*#__PURE__*/jsx(Callout, {
|
|
131
|
+
tone: props.fields.tone.value,
|
|
132
|
+
children: props.fields.content.element
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
label: '提示面板',
|
|
136
|
+
chromeless: true,
|
|
137
|
+
schema: {
|
|
138
|
+
tone: fields.select({
|
|
139
|
+
label: 'Tone',
|
|
140
|
+
options: [{
|
|
141
|
+
value: 'info',
|
|
142
|
+
label: '消息'
|
|
143
|
+
}, {
|
|
144
|
+
value: 'caution',
|
|
145
|
+
label: '警告'
|
|
146
|
+
}, {
|
|
147
|
+
value: 'positive',
|
|
148
|
+
label: '成功'
|
|
149
|
+
}, {
|
|
150
|
+
value: 'critical',
|
|
151
|
+
label: '错误'
|
|
152
|
+
}],
|
|
153
|
+
defaultValue: 'info'
|
|
154
|
+
}),
|
|
155
|
+
content: fields.child({
|
|
156
|
+
kind: 'block',
|
|
157
|
+
placeholder: '',
|
|
158
|
+
formatting: 'inherit',
|
|
159
|
+
dividers: 'inherit',
|
|
160
|
+
links: 'inherit'
|
|
161
|
+
})
|
|
162
|
+
},
|
|
163
|
+
toolbar({
|
|
164
|
+
props,
|
|
165
|
+
onRemove
|
|
166
|
+
}) {
|
|
167
|
+
return /*#__PURE__*/jsx(CalloutToolbar, {
|
|
168
|
+
onChange: tone => {
|
|
169
|
+
props.fields.tone.onChange(tone);
|
|
170
|
+
},
|
|
171
|
+
onRemove: onRemove,
|
|
172
|
+
tone: props.fields.tone.value,
|
|
173
|
+
tones: props.fields.tone.schema.options
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// 上传函数
|
|
179
|
+
async function uploadImage(albumId, file, name, altText) {
|
|
180
|
+
const operations = {
|
|
181
|
+
variables: {
|
|
182
|
+
data: {
|
|
183
|
+
name,
|
|
184
|
+
altText,
|
|
185
|
+
image: {
|
|
186
|
+
upload: null
|
|
187
|
+
},
|
|
188
|
+
album: {
|
|
189
|
+
connect: {
|
|
190
|
+
id: albumId
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
query: `mutation ($data: ImageCreateInput!) {
|
|
196
|
+
item: createImage(data: $data) {
|
|
197
|
+
id
|
|
198
|
+
name
|
|
199
|
+
image { url }
|
|
200
|
+
album { id name }
|
|
201
|
+
__typename
|
|
202
|
+
}
|
|
203
|
+
}`
|
|
204
|
+
};
|
|
205
|
+
const map = {
|
|
206
|
+
'1': ['variables.data.image.upload']
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// useMutation
|
|
210
|
+
const formData = new FormData();
|
|
211
|
+
formData.append('operations', JSON.stringify(operations));
|
|
212
|
+
formData.append('map', JSON.stringify(map));
|
|
213
|
+
formData.append('1', file); // 这里的 '1' 对应 map 中的键
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
const response = await fetch('/api/graphql', {
|
|
217
|
+
method: 'POST',
|
|
218
|
+
body: formData,
|
|
219
|
+
headers: {
|
|
220
|
+
'x-apollo-operation-name': 'UploadImage',
|
|
221
|
+
'apollo-require-preflight': 'true'
|
|
222
|
+
}
|
|
223
|
+
// 注意:不要手动设置 Content-Type,浏览器会自动设置正确的 boundary
|
|
224
|
+
});
|
|
225
|
+
const result = await response.json();
|
|
226
|
+
if (result.errors) {
|
|
227
|
+
throw new Error(result.errors[0].message);
|
|
228
|
+
}
|
|
229
|
+
return result.data.item;
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.log('上传失败:', error);
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const Image = component({
|
|
237
|
+
label: '图片',
|
|
238
|
+
schema: {
|
|
239
|
+
webImageUrl: fields.text({
|
|
240
|
+
label: 'Web 图片地址'
|
|
241
|
+
}),
|
|
242
|
+
uploadedImageUrl: fields.file({
|
|
243
|
+
label: '使用上传的图片',
|
|
244
|
+
allowedFileTypes: ['image/png', 'image/jpg', 'image/jpeg', 'image/gif', 'image/webp'],
|
|
245
|
+
isImage: true,
|
|
246
|
+
onUpload(file) {
|
|
247
|
+
// console.log(file)
|
|
248
|
+
return new Promise((resolve, reject) => {
|
|
249
|
+
// 使用固定的 albumId:cmhepys2l0000dd2m4cxaozc8,文档相关的临时图片都存放在这儿。
|
|
250
|
+
try {
|
|
251
|
+
uploadImage('cmhepys2l0000dd2m4cxaozc8', file, file.name).then(ret => resolve(ret.image.url)).catch(reject);
|
|
252
|
+
} catch (e) {
|
|
253
|
+
reject(e);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}),
|
|
258
|
+
caption: fields.conditional(fields.checkbox({
|
|
259
|
+
label: '显示图片描述'
|
|
260
|
+
}), {
|
|
261
|
+
false: fields.empty(),
|
|
262
|
+
true: fields.child({
|
|
263
|
+
kind: 'block',
|
|
264
|
+
placeholder: '输入图片描述',
|
|
265
|
+
formatting: 'inherit',
|
|
266
|
+
links: 'inherit'
|
|
267
|
+
})
|
|
268
|
+
})
|
|
269
|
+
},
|
|
270
|
+
preview: function Image(props) {
|
|
271
|
+
const imageUrl = props.fields.webImageUrl.value || props.fields.uploadedImageUrl.value || '/assets/images/placeholder.jpeg';
|
|
272
|
+
return /*#__PURE__*/jsxs("div", {
|
|
273
|
+
children: [/*#__PURE__*/jsx(NotEditable, {
|
|
274
|
+
children: /*#__PURE__*/jsx("img", {
|
|
275
|
+
src: imageUrl,
|
|
276
|
+
className: css({
|
|
277
|
+
display: 'block',
|
|
278
|
+
width: '100%',
|
|
279
|
+
minHeight: 10
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
}), props.fields.caption.discriminant ? /*#__PURE__*/jsx("div", {
|
|
283
|
+
className: css({
|
|
284
|
+
textAlign: 'center',
|
|
285
|
+
marginTop: 5
|
|
286
|
+
}),
|
|
287
|
+
children: props.fields.caption.value.element
|
|
288
|
+
}) : null]
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
const componentBlocks = {
|
|
294
|
+
quoteBlock,
|
|
295
|
+
carousel,
|
|
296
|
+
callout,
|
|
297
|
+
Image
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export { componentBlocks };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var typography = require('@keystar/ui/typography');
|
|
7
|
+
var index = require('./index-c3223fdc.node.cjs.js');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
require('slate');
|
|
10
|
+
require('@braintree/sanitize-url');
|
|
11
|
+
|
|
12
|
+
const Cell = ({
|
|
13
|
+
value
|
|
14
|
+
}) => {
|
|
15
|
+
if (!value) return null;
|
|
16
|
+
return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
|
|
17
|
+
children: index.serializeSlateNodes(value.document).slice(0, 50)
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports["default"] = Cell;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Text } from '@keystar/ui/typography';
|
|
3
|
+
import { s as serializeSlateNodes } from './index-67d52357.esm.js';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
import 'slate';
|
|
6
|
+
import '@braintree/sanitize-url';
|
|
7
|
+
|
|
8
|
+
const Cell = ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
if (!value) return null;
|
|
12
|
+
return /*#__PURE__*/jsx(Text, {
|
|
13
|
+
children: serializeSlateNodes(value.document).slice(0, 50)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Cell as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Text } from '@keystar/ui/typography';
|
|
3
|
+
import { s as serializeSlateNodes } from './index-586adb8f.node.esm.js';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
import 'slate';
|
|
6
|
+
import '@braintree/sanitize-url';
|
|
7
|
+
|
|
8
|
+
const Cell = ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
if (!value) return null;
|
|
12
|
+
return /*#__PURE__*/jsx(Text, {
|
|
13
|
+
children: serializeSlateNodes(value.document).slice(0, 50)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Cell as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var typography = require('@keystar/ui/typography');
|
|
7
|
+
var index = require('./index-06c36775.cjs.js');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
require('slate');
|
|
10
|
+
require('@braintree/sanitize-url');
|
|
11
|
+
|
|
12
|
+
const Cell = ({
|
|
13
|
+
value
|
|
14
|
+
}) => {
|
|
15
|
+
if (!value) return null;
|
|
16
|
+
return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
|
|
17
|
+
children: index.serializeSlateNodes(value.document).slice(0, 50)
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports["default"] = Cell;
|