lkb-fields-document 1.0.0 → 1.0.1
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 -2
- package/component-blocks/dist/lkb-fields-document-component-blocks.cjs.js +16 -306
- package/component-blocks/dist/lkb-fields-document-component-blocks.node.cjs.js +16 -306
- package/dist/lkb-fields-document.cjs.d.ts +2 -2
- package/dist/lkb-fields-document.cjs.js +16 -1167
- package/dist/lkb-fields-document.node.cjs.js +16 -1167
- package/package.json +6 -6
- package/structure-views/dist/lkb-fields-document-structure-views.cjs.d.ts +2 -2
- package/structure-views/dist/lkb-fields-document-structure-views.cjs.js +16 -138
- package/structure-views/dist/lkb-fields-document-structure-views.node.cjs.js +16 -138
- package/views/dist/lkb-fields-document-views.cjs.d.ts +2 -2
- package/views/dist/lkb-fields-document-views.cjs.js +13 -111
- package/views/dist/lkb-fields-document-views.node.cjs.js +13 -111
- package/component-blocks/dist/lkb-fields-document-component-blocks.esm.js +0 -300
- package/component-blocks/dist/lkb-fields-document-component-blocks.node.esm.js +0 -300
- package/dist/Cell-0ac0ac66.node.cjs.js +0 -21
- package/dist/Cell-242f7404.esm.js +0 -17
- package/dist/Cell-3103f73d.node.esm.js +0 -17
- package/dist/Cell-bfb56d74.cjs.js +0 -21
- package/dist/Field-0e0f75ed.node.cjs.js +0 -1628
- package/dist/Field-28177061.cjs.js +0 -1628
- package/dist/Field-35b79e6b.node.esm.js +0 -1619
- package/dist/Field-92d13205.esm.js +0 -1619
- package/dist/api-2f524611.esm.js +0 -502
- package/dist/api-73636987.cjs.js +0 -506
- package/dist/api-8e2b20b8.node.cjs.js +0 -506
- package/dist/api-c32e360e.node.esm.js +0 -502
- package/dist/callout-ui-2aded278.cjs.js +0 -131
- package/dist/callout-ui-3e5ca544.node.esm.js +0 -126
- package/dist/callout-ui-8b5f2376.esm.js +0 -126
- package/dist/callout-ui-ad50f301.node.cjs.js +0 -131
- package/dist/declarations/src/component-blocks.d.ts +0 -4
- package/dist/declarations/src/component-blocks.d.ts.map +0 -1
- package/dist/declarations/src/document-editor/component-blocks/api.d.ts +0 -120
- package/dist/declarations/src/document-editor/component-blocks/api.d.ts.map +0 -1
- package/dist/declarations/src/document-editor/component-blocks/types.d.ts +0 -241
- package/dist/declarations/src/document-editor/component-blocks/types.d.ts.map +0 -1
- package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts +0 -10
- package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts.map +0 -1
- package/dist/declarations/src/index.d.ts +0 -7
- package/dist/declarations/src/index.d.ts.map +0 -1
- package/dist/declarations/src/my-component-blocks/index.d.ts +0 -46
- package/dist/declarations/src/my-component-blocks/index.d.ts.map +0 -1
- package/dist/declarations/src/structure/Cell.d.ts +0 -5
- package/dist/declarations/src/structure/Cell.d.ts.map +0 -1
- package/dist/declarations/src/structure/Field.d.ts +0 -5
- package/dist/declarations/src/structure/Field.d.ts.map +0 -1
- package/dist/declarations/src/structure/controller.d.ts +0 -10
- package/dist/declarations/src/structure/controller.d.ts.map +0 -1
- package/dist/declarations/src/structure/structure.d.ts +0 -4
- package/dist/declarations/src/structure/structure.d.ts.map +0 -1
- package/dist/declarations/src/structure-views.d.ts +0 -5
- package/dist/declarations/src/structure-views.d.ts.map +0 -1
- package/dist/declarations/src/types/DocumentFeatures.d.ts +0 -33
- package/dist/declarations/src/types/DocumentFeatures.d.ts.map +0 -1
- package/dist/declarations/src/types/DocumentFieldConfig.d.ts +0 -18
- package/dist/declarations/src/types/DocumentFieldConfig.d.ts.map +0 -1
- package/dist/declarations/src/types/FormattingConfig.d.ts +0 -28
- package/dist/declarations/src/types/FormattingConfig.d.ts.map +0 -1
- package/dist/declarations/src/types/RelationshipsConfig.d.ts +0 -9
- package/dist/declarations/src/types/RelationshipsConfig.d.ts.map +0 -1
- package/dist/declarations/src/types/StructureFieldConfig.d.ts +0 -10
- package/dist/declarations/src/types/StructureFieldConfig.d.ts.map +0 -1
- package/dist/declarations/src/validation/structure-validation.d.ts +0 -218
- package/dist/declarations/src/validation/structure-validation.d.ts.map +0 -1
- package/dist/declarations/src/views/Cell.d.ts +0 -5
- package/dist/declarations/src/views/Cell.d.ts.map +0 -1
- package/dist/declarations/src/views/Field.d.ts +0 -5
- package/dist/declarations/src/views/Field.d.ts.map +0 -1
- package/dist/declarations/src/views/controller.d.ts +0 -15
- package/dist/declarations/src/views/controller.d.ts.map +0 -1
- package/dist/declarations/src/views/document.d.ts +0 -4
- package/dist/declarations/src/views/document.d.ts.map +0 -1
- package/dist/declarations/src/views.d.ts +0 -7
- package/dist/declarations/src/views.d.ts.map +0 -1
- package/dist/editor-shared-a6e340e6.node.esm.js +0 -1993
- package/dist/editor-shared-a997ae98.node.cjs.js +0 -2007
- package/dist/editor-shared-cc1293ed.cjs.js +0 -2007
- package/dist/editor-shared-da518ba3.esm.js +0 -1993
- package/dist/form-from-preview-2042b9ef.cjs.js +0 -512
- package/dist/form-from-preview-5df6e492.node.esm.js +0 -508
- package/dist/form-from-preview-9e501058.node.cjs.js +0 -512
- package/dist/form-from-preview-b3a66f37.esm.js +0 -508
- package/dist/index-06c36775.cjs.js +0 -14
- package/dist/index-586adb8f.node.esm.js +0 -11
- package/dist/index-67d52357.esm.js +0 -11
- package/dist/index-c3223fdc.node.cjs.js +0 -14
- package/dist/layouts-6412fa2a.esm.js +0 -189
- package/dist/layouts-a4a3cf0b.node.cjs.js +0 -196
- package/dist/layouts-ba9a558b.cjs.js +0 -196
- package/dist/layouts-e653b908.node.esm.js +0 -189
- package/dist/lkb-fields-document.esm.js +0 -1162
- package/dist/lkb-fields-document.node.esm.js +0 -1162
- package/dist/shared-0533009e.cjs.js +0 -594
- package/dist/shared-4684cc24.node.cjs.js +0 -594
- package/dist/shared-5e864055.node.esm.js +0 -579
- package/dist/shared-aaba5901.esm.js +0 -579
- package/dist/toolbar-state-3359e2f3.cjs.js +0 -994
- package/dist/toolbar-state-945823b8.node.esm.js +0 -971
- package/dist/toolbar-state-9611743f.node.cjs.js +0 -994
- package/dist/toolbar-state-bc8fe661.esm.js +0 -971
- package/dist/utils-06bcddc4.node.cjs.js +0 -747
- package/dist/utils-200ff260.node.esm.js +0 -722
- package/dist/utils-6409f730.cjs.js +0 -747
- package/dist/utils-bc6a0b82.esm.js +0 -722
- package/structure-views/dist/lkb-fields-document-structure-views.esm.js +0 -131
- package/structure-views/dist/lkb-fields-document-structure-views.node.esm.js +0 -131
- package/views/dist/lkb-fields-document-views.esm.js +0 -95
- package/views/dist/lkb-fields-document-views.node.esm.js +0 -95
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "../../
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
1
|
+
export * from "../../src/component-blocks.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC1jb21wb25lbnQtYmxvY2tzLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbXBvbmVudC1ibG9ja3MudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|
|
@@ -1,306 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
require('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require(
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
9
|
+
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../..", "../..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../src/component-blocks.tsx");
|
|
15
|
+
|
|
16
|
+
unregister();
|
|
@@ -1,306 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
require('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require(
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
9
|
+
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../..", "../..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../src/component-blocks.tsx");
|
|
15
|
+
|
|
16
|
+
unregister();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
1
|
+
export * from "../src/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
|