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.
Files changed (109) hide show
  1. package/component-blocks/dist/lkb-fields-document-component-blocks.cjs.d.ts +2 -2
  2. package/component-blocks/dist/lkb-fields-document-component-blocks.cjs.js +16 -306
  3. package/component-blocks/dist/lkb-fields-document-component-blocks.node.cjs.js +16 -306
  4. package/dist/lkb-fields-document.cjs.d.ts +2 -2
  5. package/dist/lkb-fields-document.cjs.js +16 -1167
  6. package/dist/lkb-fields-document.node.cjs.js +16 -1167
  7. package/package.json +6 -6
  8. package/structure-views/dist/lkb-fields-document-structure-views.cjs.d.ts +2 -2
  9. package/structure-views/dist/lkb-fields-document-structure-views.cjs.js +16 -138
  10. package/structure-views/dist/lkb-fields-document-structure-views.node.cjs.js +16 -138
  11. package/views/dist/lkb-fields-document-views.cjs.d.ts +2 -2
  12. package/views/dist/lkb-fields-document-views.cjs.js +13 -111
  13. package/views/dist/lkb-fields-document-views.node.cjs.js +13 -111
  14. package/component-blocks/dist/lkb-fields-document-component-blocks.esm.js +0 -300
  15. package/component-blocks/dist/lkb-fields-document-component-blocks.node.esm.js +0 -300
  16. package/dist/Cell-0ac0ac66.node.cjs.js +0 -21
  17. package/dist/Cell-242f7404.esm.js +0 -17
  18. package/dist/Cell-3103f73d.node.esm.js +0 -17
  19. package/dist/Cell-bfb56d74.cjs.js +0 -21
  20. package/dist/Field-0e0f75ed.node.cjs.js +0 -1628
  21. package/dist/Field-28177061.cjs.js +0 -1628
  22. package/dist/Field-35b79e6b.node.esm.js +0 -1619
  23. package/dist/Field-92d13205.esm.js +0 -1619
  24. package/dist/api-2f524611.esm.js +0 -502
  25. package/dist/api-73636987.cjs.js +0 -506
  26. package/dist/api-8e2b20b8.node.cjs.js +0 -506
  27. package/dist/api-c32e360e.node.esm.js +0 -502
  28. package/dist/callout-ui-2aded278.cjs.js +0 -131
  29. package/dist/callout-ui-3e5ca544.node.esm.js +0 -126
  30. package/dist/callout-ui-8b5f2376.esm.js +0 -126
  31. package/dist/callout-ui-ad50f301.node.cjs.js +0 -131
  32. package/dist/declarations/src/component-blocks.d.ts +0 -4
  33. package/dist/declarations/src/component-blocks.d.ts.map +0 -1
  34. package/dist/declarations/src/document-editor/component-blocks/api.d.ts +0 -120
  35. package/dist/declarations/src/document-editor/component-blocks/api.d.ts.map +0 -1
  36. package/dist/declarations/src/document-editor/component-blocks/types.d.ts +0 -241
  37. package/dist/declarations/src/document-editor/component-blocks/types.d.ts.map +0 -1
  38. package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts +0 -10
  39. package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts.map +0 -1
  40. package/dist/declarations/src/index.d.ts +0 -7
  41. package/dist/declarations/src/index.d.ts.map +0 -1
  42. package/dist/declarations/src/my-component-blocks/index.d.ts +0 -46
  43. package/dist/declarations/src/my-component-blocks/index.d.ts.map +0 -1
  44. package/dist/declarations/src/structure/Cell.d.ts +0 -5
  45. package/dist/declarations/src/structure/Cell.d.ts.map +0 -1
  46. package/dist/declarations/src/structure/Field.d.ts +0 -5
  47. package/dist/declarations/src/structure/Field.d.ts.map +0 -1
  48. package/dist/declarations/src/structure/controller.d.ts +0 -10
  49. package/dist/declarations/src/structure/controller.d.ts.map +0 -1
  50. package/dist/declarations/src/structure/structure.d.ts +0 -4
  51. package/dist/declarations/src/structure/structure.d.ts.map +0 -1
  52. package/dist/declarations/src/structure-views.d.ts +0 -5
  53. package/dist/declarations/src/structure-views.d.ts.map +0 -1
  54. package/dist/declarations/src/types/DocumentFeatures.d.ts +0 -33
  55. package/dist/declarations/src/types/DocumentFeatures.d.ts.map +0 -1
  56. package/dist/declarations/src/types/DocumentFieldConfig.d.ts +0 -18
  57. package/dist/declarations/src/types/DocumentFieldConfig.d.ts.map +0 -1
  58. package/dist/declarations/src/types/FormattingConfig.d.ts +0 -28
  59. package/dist/declarations/src/types/FormattingConfig.d.ts.map +0 -1
  60. package/dist/declarations/src/types/RelationshipsConfig.d.ts +0 -9
  61. package/dist/declarations/src/types/RelationshipsConfig.d.ts.map +0 -1
  62. package/dist/declarations/src/types/StructureFieldConfig.d.ts +0 -10
  63. package/dist/declarations/src/types/StructureFieldConfig.d.ts.map +0 -1
  64. package/dist/declarations/src/validation/structure-validation.d.ts +0 -218
  65. package/dist/declarations/src/validation/structure-validation.d.ts.map +0 -1
  66. package/dist/declarations/src/views/Cell.d.ts +0 -5
  67. package/dist/declarations/src/views/Cell.d.ts.map +0 -1
  68. package/dist/declarations/src/views/Field.d.ts +0 -5
  69. package/dist/declarations/src/views/Field.d.ts.map +0 -1
  70. package/dist/declarations/src/views/controller.d.ts +0 -15
  71. package/dist/declarations/src/views/controller.d.ts.map +0 -1
  72. package/dist/declarations/src/views/document.d.ts +0 -4
  73. package/dist/declarations/src/views/document.d.ts.map +0 -1
  74. package/dist/declarations/src/views.d.ts +0 -7
  75. package/dist/declarations/src/views.d.ts.map +0 -1
  76. package/dist/editor-shared-a6e340e6.node.esm.js +0 -1993
  77. package/dist/editor-shared-a997ae98.node.cjs.js +0 -2007
  78. package/dist/editor-shared-cc1293ed.cjs.js +0 -2007
  79. package/dist/editor-shared-da518ba3.esm.js +0 -1993
  80. package/dist/form-from-preview-2042b9ef.cjs.js +0 -512
  81. package/dist/form-from-preview-5df6e492.node.esm.js +0 -508
  82. package/dist/form-from-preview-9e501058.node.cjs.js +0 -512
  83. package/dist/form-from-preview-b3a66f37.esm.js +0 -508
  84. package/dist/index-06c36775.cjs.js +0 -14
  85. package/dist/index-586adb8f.node.esm.js +0 -11
  86. package/dist/index-67d52357.esm.js +0 -11
  87. package/dist/index-c3223fdc.node.cjs.js +0 -14
  88. package/dist/layouts-6412fa2a.esm.js +0 -189
  89. package/dist/layouts-a4a3cf0b.node.cjs.js +0 -196
  90. package/dist/layouts-ba9a558b.cjs.js +0 -196
  91. package/dist/layouts-e653b908.node.esm.js +0 -189
  92. package/dist/lkb-fields-document.esm.js +0 -1162
  93. package/dist/lkb-fields-document.node.esm.js +0 -1162
  94. package/dist/shared-0533009e.cjs.js +0 -594
  95. package/dist/shared-4684cc24.node.cjs.js +0 -594
  96. package/dist/shared-5e864055.node.esm.js +0 -579
  97. package/dist/shared-aaba5901.esm.js +0 -579
  98. package/dist/toolbar-state-3359e2f3.cjs.js +0 -994
  99. package/dist/toolbar-state-945823b8.node.esm.js +0 -971
  100. package/dist/toolbar-state-9611743f.node.cjs.js +0 -994
  101. package/dist/toolbar-state-bc8fe661.esm.js +0 -971
  102. package/dist/utils-06bcddc4.node.cjs.js +0 -747
  103. package/dist/utils-200ff260.node.esm.js +0 -722
  104. package/dist/utils-6409f730.cjs.js +0 -747
  105. package/dist/utils-bc6a0b82.esm.js +0 -722
  106. package/structure-views/dist/lkb-fields-document-structure-views.esm.js +0 -131
  107. package/structure-views/dist/lkb-fields-document-structure-views.node.esm.js +0 -131
  108. package/views/dist/lkb-fields-document-views.esm.js +0 -95
  109. package/views/dist/lkb-fields-document-views.node.esm.js +0 -95
@@ -1,300 +0,0 @@
1
- 'use client';
2
- import { c as component, N as NotEditable, f as fields } from '../../dist/api-2f524611.esm.js';
3
- export { N as NotEditable, c as component, f as fields } from '../../dist/api-2f524611.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-8b5f2376.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-67d52357.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 };
@@ -1,300 +0,0 @@
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 };
@@ -1,21 +0,0 @@
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;
@@ -1,17 +0,0 @@
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 };
@@ -1,17 +0,0 @@
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 };
@@ -1,21 +0,0 @@
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;