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
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkb-fields-document",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.0.0",
|
|
3
|
+
"version": "1.0.1",
|
|
5
4
|
"license": "MIT",
|
|
5
|
+
"description": "负责处理富文档编辑器相关的逻辑。",
|
|
6
6
|
"main": "dist/lkb-fields-document.cjs.js",
|
|
7
7
|
"module": "dist/lkb-fields-document.esm.js",
|
|
8
8
|
"exports": {
|
|
@@ -102,11 +102,11 @@
|
|
|
102
102
|
"zod": "^3.23.8"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"
|
|
106
|
-
"
|
|
105
|
+
"@types/is-hotkey": "^0.1.7",
|
|
106
|
+
"lkb-core": "^1.0.1"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"lkb-core": "
|
|
109
|
+
"lkb-core": "^1.0.1"
|
|
110
110
|
},
|
|
111
111
|
"imports": {
|
|
112
112
|
"#fields-ui": {
|
|
@@ -115,4 +115,4 @@
|
|
|
115
115
|
"default": "./src/document-editor/component-blocks/fields-ui.tsx"
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
}
|
|
118
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "../../
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
1
|
+
export * from "../../src/structure-views.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC1zdHJ1Y3R1cmUtdmlld3MuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RydWN0dXJlLXZpZXdzLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
|
|
@@ -1,138 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
require('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
require('@keystar/ui/icon');
|
|
18
|
-
require('@keystar/ui/list-view');
|
|
19
|
-
require('@keystar/ui/drag-and-drop');
|
|
20
|
-
require('@keystar/ui/tooltip');
|
|
21
|
-
require('@keystar/ui/layout');
|
|
22
|
-
require('@keystar/ui/icon/icons/trash2Icon');
|
|
23
|
-
require('@keystar/ui/slots');
|
|
24
|
-
|
|
25
|
-
function serializeValue(schema, value, kind) {
|
|
26
|
-
if (schema.kind === 'conditional') {
|
|
27
|
-
return {
|
|
28
|
-
[value.discriminant]: serializeValue(schema.values[value.discriminant], value.value, kind)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (schema.kind === 'array') {
|
|
32
|
-
if (value === null) return [];
|
|
33
|
-
return value.map(x => serializeValue(schema.element, x, kind));
|
|
34
|
-
}
|
|
35
|
-
if (schema.kind === 'form') return value;
|
|
36
|
-
if (schema.kind === 'object') {
|
|
37
|
-
return Object.fromEntries(Object.entries(schema.fields).map(([key, val]) => {
|
|
38
|
-
return [key, serializeValue(val, value[key], kind)];
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
if (schema.kind === 'relationship') {
|
|
42
|
-
if (Array.isArray(value)) {
|
|
43
|
-
return {
|
|
44
|
-
[kind === 'create' ? 'connect' : 'set']: value.map(x => ({
|
|
45
|
-
id: x.id
|
|
46
|
-
}))
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (value === null) {
|
|
50
|
-
if (kind === 'create') return;
|
|
51
|
-
return {
|
|
52
|
-
disconnect: true
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
connect: {
|
|
57
|
-
id: value.id
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (schema.kind === 'child') {
|
|
62
|
-
throw new Error('Child fields are not supported in the structure field');
|
|
63
|
-
}
|
|
64
|
-
utils.assertNever(schema);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function controller(config) {
|
|
68
|
-
if (!config.customViews.schema) throw new Error(`No schema in custom view. Did you forgot to set \`views\` to a file that exports a \`schema\` on ${config.listKey}.${config.path}`);
|
|
69
|
-
return {
|
|
70
|
-
path: config.path,
|
|
71
|
-
label: config.label,
|
|
72
|
-
description: config.description,
|
|
73
|
-
graphqlSelection: `${config.path} { json(hydrateRelationships: true) }`,
|
|
74
|
-
schema: config.customViews.schema,
|
|
75
|
-
defaultValue: {
|
|
76
|
-
kind: 'create',
|
|
77
|
-
value: utils.getInitialPropsValue(config.customViews.schema)
|
|
78
|
-
},
|
|
79
|
-
validate: value => utils.clientSideValidateProp(config.customViews.schema, value.value),
|
|
80
|
-
deserialize: data => {
|
|
81
|
-
var _data$json, _data;
|
|
82
|
-
return {
|
|
83
|
-
kind: 'update',
|
|
84
|
-
value: (_data$json = (_data = data[`${config.path}`]) === null || _data === void 0 ? void 0 : _data.json) !== null && _data$json !== void 0 ? _data$json : null
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
serialize: value => {
|
|
88
|
-
return {
|
|
89
|
-
[config.path]: serializeValue(config.customViews.schema, value.value, value.kind)
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function Field({
|
|
96
|
-
field: field$1,
|
|
97
|
-
value,
|
|
98
|
-
onChange,
|
|
99
|
-
autoFocus,
|
|
100
|
-
forceValidation
|
|
101
|
-
}) {
|
|
102
|
-
const valueRef = React.useRef(value);
|
|
103
|
-
React.useEffect(() => {
|
|
104
|
-
valueRef.current = value;
|
|
105
|
-
});
|
|
106
|
-
const createPreviewProps = React.useMemo(() => {
|
|
107
|
-
return utils.createGetPreviewProps(field$1.schema, getNewVal => {
|
|
108
|
-
onChange === null || onChange === void 0 || onChange({
|
|
109
|
-
kind: valueRef.current.kind,
|
|
110
|
-
value: getNewVal(valueRef.current.value)
|
|
111
|
-
});
|
|
112
|
-
}, () => undefined);
|
|
113
|
-
}, [field$1.schema, onChange]);
|
|
114
|
-
return /*#__PURE__*/jsxRuntime.jsx(field.Field, {
|
|
115
|
-
label: field$1.label,
|
|
116
|
-
description: field$1.description,
|
|
117
|
-
children: inputProps => /*#__PURE__*/jsxRuntime.jsx(formFromPreview.FormValueContentFromPreviewProps, {
|
|
118
|
-
autoFocus: autoFocus,
|
|
119
|
-
forceValidation: forceValidation,
|
|
120
|
-
...createPreviewProps(value.value)
|
|
121
|
-
})
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const Cell = ({
|
|
126
|
-
value
|
|
127
|
-
}) => {
|
|
128
|
-
return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
|
|
129
|
-
children: JSON.stringify(value.json)
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const allowedExportsOnCustomViews = ['schema'];
|
|
134
|
-
|
|
135
|
-
exports.Cell = Cell;
|
|
136
|
-
exports.Field = Field;
|
|
137
|
-
exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
|
|
138
|
-
exports.controller = controller;
|
|
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/structure-views.tsx");
|
|
15
|
+
|
|
16
|
+
unregister();
|
|
@@ -1,138 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
require('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
require('@keystar/ui/icon');
|
|
18
|
-
require('@keystar/ui/list-view');
|
|
19
|
-
require('@keystar/ui/drag-and-drop');
|
|
20
|
-
require('@keystar/ui/tooltip');
|
|
21
|
-
require('@keystar/ui/layout');
|
|
22
|
-
require('@keystar/ui/icon/icons/trash2Icon');
|
|
23
|
-
require('@keystar/ui/slots');
|
|
24
|
-
|
|
25
|
-
function serializeValue(schema, value, kind) {
|
|
26
|
-
if (schema.kind === 'conditional') {
|
|
27
|
-
return {
|
|
28
|
-
[value.discriminant]: serializeValue(schema.values[value.discriminant], value.value, kind)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (schema.kind === 'array') {
|
|
32
|
-
if (value === null) return [];
|
|
33
|
-
return value.map(x => serializeValue(schema.element, x, kind));
|
|
34
|
-
}
|
|
35
|
-
if (schema.kind === 'form') return value;
|
|
36
|
-
if (schema.kind === 'object') {
|
|
37
|
-
return Object.fromEntries(Object.entries(schema.fields).map(([key, val]) => {
|
|
38
|
-
return [key, serializeValue(val, value[key], kind)];
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
if (schema.kind === 'relationship') {
|
|
42
|
-
if (Array.isArray(value)) {
|
|
43
|
-
return {
|
|
44
|
-
[kind === 'create' ? 'connect' : 'set']: value.map(x => ({
|
|
45
|
-
id: x.id
|
|
46
|
-
}))
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (value === null) {
|
|
50
|
-
if (kind === 'create') return;
|
|
51
|
-
return {
|
|
52
|
-
disconnect: true
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
connect: {
|
|
57
|
-
id: value.id
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (schema.kind === 'child') {
|
|
62
|
-
throw new Error('Child fields are not supported in the structure field');
|
|
63
|
-
}
|
|
64
|
-
utils.assertNever(schema);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function controller(config) {
|
|
68
|
-
if (!config.customViews.schema) throw new Error(`No schema in custom view. Did you forgot to set \`views\` to a file that exports a \`schema\` on ${config.listKey}.${config.path}`);
|
|
69
|
-
return {
|
|
70
|
-
path: config.path,
|
|
71
|
-
label: config.label,
|
|
72
|
-
description: config.description,
|
|
73
|
-
graphqlSelection: `${config.path} { json(hydrateRelationships: true) }`,
|
|
74
|
-
schema: config.customViews.schema,
|
|
75
|
-
defaultValue: {
|
|
76
|
-
kind: 'create',
|
|
77
|
-
value: utils.getInitialPropsValue(config.customViews.schema)
|
|
78
|
-
},
|
|
79
|
-
validate: value => utils.clientSideValidateProp(config.customViews.schema, value.value),
|
|
80
|
-
deserialize: data => {
|
|
81
|
-
var _data$json, _data;
|
|
82
|
-
return {
|
|
83
|
-
kind: 'update',
|
|
84
|
-
value: (_data$json = (_data = data[`${config.path}`]) === null || _data === void 0 ? void 0 : _data.json) !== null && _data$json !== void 0 ? _data$json : null
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
serialize: value => {
|
|
88
|
-
return {
|
|
89
|
-
[config.path]: serializeValue(config.customViews.schema, value.value, value.kind)
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function Field({
|
|
96
|
-
field: field$1,
|
|
97
|
-
value,
|
|
98
|
-
onChange,
|
|
99
|
-
autoFocus,
|
|
100
|
-
forceValidation
|
|
101
|
-
}) {
|
|
102
|
-
const valueRef = React.useRef(value);
|
|
103
|
-
React.useEffect(() => {
|
|
104
|
-
valueRef.current = value;
|
|
105
|
-
});
|
|
106
|
-
const createPreviewProps = React.useMemo(() => {
|
|
107
|
-
return utils.createGetPreviewProps(field$1.schema, getNewVal => {
|
|
108
|
-
onChange === null || onChange === void 0 || onChange({
|
|
109
|
-
kind: valueRef.current.kind,
|
|
110
|
-
value: getNewVal(valueRef.current.value)
|
|
111
|
-
});
|
|
112
|
-
}, () => undefined);
|
|
113
|
-
}, [field$1.schema, onChange]);
|
|
114
|
-
return /*#__PURE__*/jsxRuntime.jsx(field.Field, {
|
|
115
|
-
label: field$1.label,
|
|
116
|
-
description: field$1.description,
|
|
117
|
-
children: inputProps => /*#__PURE__*/jsxRuntime.jsx(formFromPreview.FormValueContentFromPreviewProps, {
|
|
118
|
-
autoFocus: autoFocus,
|
|
119
|
-
forceValidation: forceValidation,
|
|
120
|
-
...createPreviewProps(value.value)
|
|
121
|
-
})
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const Cell = ({
|
|
126
|
-
value
|
|
127
|
-
}) => {
|
|
128
|
-
return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
|
|
129
|
-
children: JSON.stringify(value.json)
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const allowedExportsOnCustomViews = ['schema'];
|
|
134
|
-
|
|
135
|
-
exports.Cell = Cell;
|
|
136
|
-
exports.Field = Field;
|
|
137
|
-
exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
|
|
138
|
-
exports.controller = controller;
|
|
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/structure-views.tsx");
|
|
15
|
+
|
|
16
|
+
unregister();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "../../
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
1
|
+
export * from "../../src/views.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC12aWV3cy5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92aWV3cy50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -1,114 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
'
|
|
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
|
|
3
9
|
|
|
4
|
-
|
|
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, "../../../..", "../..");
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var index = require('../../dist/index-06c36775.cjs.js');
|
|
9
|
-
var editorShared = require('../../dist/editor-shared-cc1293ed.cjs.js');
|
|
10
|
-
var utils = require('../../dist/utils-6409f730.cjs.js');
|
|
11
|
-
var Field = require('../../dist/Field-28177061.cjs.js');
|
|
12
|
-
var Cell = require('../../dist/Cell-bfb56d74.cjs.js');
|
|
13
|
-
require('@braintree/sanitize-url');
|
|
14
|
-
require('slate-history');
|
|
15
|
-
require('../../dist/shared-0533009e.cjs.js');
|
|
16
|
-
require('mdast-util-from-markdown');
|
|
17
|
-
require('mdast-util-gfm-autolink-literal/from-markdown');
|
|
18
|
-
require('micromark-extension-gfm-autolink-literal');
|
|
19
|
-
require('mdast-util-gfm-strikethrough/from-markdown');
|
|
20
|
-
require('micromark-extension-gfm-strikethrough');
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../src/views.tsx");
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var weakMemoize__default = /*#__PURE__*/_interopDefault(weakMemoize);
|
|
25
|
-
var Field__default = /*#__PURE__*/_interopDefault(Field);
|
|
26
|
-
var Cell__default = /*#__PURE__*/_interopDefault(Cell);
|
|
27
|
-
|
|
28
|
-
function controller(config) {
|
|
29
|
-
const memoizedIsComponentBlockValid = weakMemoize__default["default"](componentBlock => weakMemoize__default["default"](props => utils.clientSideValidateProp({
|
|
30
|
-
kind: 'object',
|
|
31
|
-
fields: componentBlock.schema
|
|
32
|
-
}, props)));
|
|
33
|
-
const componentBlocks = config.customViews.componentBlocks || {};
|
|
34
|
-
const serverSideComponentBlocksSet = new Set(config.fieldMeta.componentBlocksPassedOnServer);
|
|
35
|
-
const componentBlocksOnlyBeingPassedOnTheClient = Object.keys(componentBlocks).filter(x => !serverSideComponentBlocksSet.has(x));
|
|
36
|
-
if (componentBlocksOnlyBeingPassedOnTheClient.length) {
|
|
37
|
-
throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the custom view but not in the server-side field config: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheClient)}`);
|
|
38
|
-
}
|
|
39
|
-
const clientSideComponentBlocksSet = new Set(Object.keys(componentBlocks));
|
|
40
|
-
const componentBlocksOnlyBeingPassedOnTheServer = config.fieldMeta.componentBlocksPassedOnServer.filter(x => !clientSideComponentBlocksSet.has(x));
|
|
41
|
-
if (componentBlocksOnlyBeingPassedOnTheServer.length) {
|
|
42
|
-
throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the server-side field config but not in the custom view: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheServer)}`);
|
|
43
|
-
}
|
|
44
|
-
const validateNode = weakMemoize__default["default"](node => {
|
|
45
|
-
if (slate.Text.isText(node)) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
if (node.type === 'component-block') {
|
|
49
|
-
const componentBlock = componentBlocks[node.component];
|
|
50
|
-
if (componentBlock) {
|
|
51
|
-
if (!memoizedIsComponentBlockValid(componentBlock)(node.props)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (node.type === 'link' && (typeof node.href !== 'string' || !index.isValidURL(node.href))) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
return node.children.every(node => validateNode(node));
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
path: config.path,
|
|
63
|
-
label: config.label,
|
|
64
|
-
description: config.description,
|
|
65
|
-
graphqlSelection: `${config.path} {document(hydrateRelationships: true)}`,
|
|
66
|
-
componentBlocks: config.customViews.componentBlocks || {},
|
|
67
|
-
documentFeatures: config.fieldMeta.documentFeatures,
|
|
68
|
-
relationships: config.fieldMeta.relationships,
|
|
69
|
-
defaultValue: [{
|
|
70
|
-
type: 'paragraph',
|
|
71
|
-
children: [{
|
|
72
|
-
text: ''
|
|
73
|
-
}]
|
|
74
|
-
}],
|
|
75
|
-
deserialize: data => {
|
|
76
|
-
var _data$config$path;
|
|
77
|
-
const documentFromServer = (_data$config$path = data[config.path]) === null || _data$config$path === void 0 ? void 0 : _data$config$path.document;
|
|
78
|
-
if (!documentFromServer) {
|
|
79
|
-
return [{
|
|
80
|
-
type: 'paragraph',
|
|
81
|
-
children: [{
|
|
82
|
-
text: ''
|
|
83
|
-
}]
|
|
84
|
-
}];
|
|
85
|
-
}
|
|
86
|
-
// make a temporary editor to normalize the document
|
|
87
|
-
const editor = editorShared.createDocumentEditor(config.fieldMeta.documentFeatures, componentBlocks, config.fieldMeta.relationships);
|
|
88
|
-
editor.children = documentFromServer;
|
|
89
|
-
slate.Editor.normalize(editor, {
|
|
90
|
-
force: true
|
|
91
|
-
});
|
|
92
|
-
return editor.children;
|
|
93
|
-
},
|
|
94
|
-
serialize: value => ({
|
|
95
|
-
[config.path]: value
|
|
96
|
-
}),
|
|
97
|
-
validate(value) {
|
|
98
|
-
return value.every(node => validateNode(node));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const allowedExportsOnCustomViews = ['componentBlocks'];
|
|
104
|
-
|
|
105
|
-
Object.defineProperty(exports, 'Field', {
|
|
106
|
-
enumerable: true,
|
|
107
|
-
get: function () { return Field__default["default"]; }
|
|
108
|
-
});
|
|
109
|
-
Object.defineProperty(exports, 'Cell', {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function () { return Cell__default["default"]; }
|
|
112
|
-
});
|
|
113
|
-
exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
|
|
114
|
-
exports.controller = controller;
|
|
16
|
+
unregister();
|
|
@@ -1,114 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
'
|
|
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
|
|
3
9
|
|
|
4
|
-
|
|
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, "../../../..", "../..");
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var index = require('../../dist/index-c3223fdc.node.cjs.js');
|
|
9
|
-
var editorShared = require('../../dist/editor-shared-a997ae98.node.cjs.js');
|
|
10
|
-
var utils = require('../../dist/utils-06bcddc4.node.cjs.js');
|
|
11
|
-
var Field = require('../../dist/Field-0e0f75ed.node.cjs.js');
|
|
12
|
-
var Cell = require('../../dist/Cell-0ac0ac66.node.cjs.js');
|
|
13
|
-
require('@braintree/sanitize-url');
|
|
14
|
-
require('slate-history');
|
|
15
|
-
require('../../dist/shared-4684cc24.node.cjs.js');
|
|
16
|
-
require('mdast-util-from-markdown');
|
|
17
|
-
require('mdast-util-gfm-autolink-literal/from-markdown');
|
|
18
|
-
require('micromark-extension-gfm-autolink-literal');
|
|
19
|
-
require('mdast-util-gfm-strikethrough/from-markdown');
|
|
20
|
-
require('micromark-extension-gfm-strikethrough');
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../../src/views.tsx");
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var weakMemoize__default = /*#__PURE__*/_interopDefault(weakMemoize);
|
|
25
|
-
var Field__default = /*#__PURE__*/_interopDefault(Field);
|
|
26
|
-
var Cell__default = /*#__PURE__*/_interopDefault(Cell);
|
|
27
|
-
|
|
28
|
-
function controller(config) {
|
|
29
|
-
const memoizedIsComponentBlockValid = weakMemoize__default["default"](componentBlock => weakMemoize__default["default"](props => utils.clientSideValidateProp({
|
|
30
|
-
kind: 'object',
|
|
31
|
-
fields: componentBlock.schema
|
|
32
|
-
}, props)));
|
|
33
|
-
const componentBlocks = config.customViews.componentBlocks || {};
|
|
34
|
-
const serverSideComponentBlocksSet = new Set(config.fieldMeta.componentBlocksPassedOnServer);
|
|
35
|
-
const componentBlocksOnlyBeingPassedOnTheClient = Object.keys(componentBlocks).filter(x => !serverSideComponentBlocksSet.has(x));
|
|
36
|
-
if (componentBlocksOnlyBeingPassedOnTheClient.length) {
|
|
37
|
-
throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the custom view but not in the server-side field config: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheClient)}`);
|
|
38
|
-
}
|
|
39
|
-
const clientSideComponentBlocksSet = new Set(Object.keys(componentBlocks));
|
|
40
|
-
const componentBlocksOnlyBeingPassedOnTheServer = config.fieldMeta.componentBlocksPassedOnServer.filter(x => !clientSideComponentBlocksSet.has(x));
|
|
41
|
-
if (componentBlocksOnlyBeingPassedOnTheServer.length) {
|
|
42
|
-
throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the server-side field config but not in the custom view: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheServer)}`);
|
|
43
|
-
}
|
|
44
|
-
const validateNode = weakMemoize__default["default"](node => {
|
|
45
|
-
if (slate.Text.isText(node)) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
if (node.type === 'component-block') {
|
|
49
|
-
const componentBlock = componentBlocks[node.component];
|
|
50
|
-
if (componentBlock) {
|
|
51
|
-
if (!memoizedIsComponentBlockValid(componentBlock)(node.props)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (node.type === 'link' && (typeof node.href !== 'string' || !index.isValidURL(node.href))) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
return node.children.every(node => validateNode(node));
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
path: config.path,
|
|
63
|
-
label: config.label,
|
|
64
|
-
description: config.description,
|
|
65
|
-
graphqlSelection: `${config.path} {document(hydrateRelationships: true)}`,
|
|
66
|
-
componentBlocks: config.customViews.componentBlocks || {},
|
|
67
|
-
documentFeatures: config.fieldMeta.documentFeatures,
|
|
68
|
-
relationships: config.fieldMeta.relationships,
|
|
69
|
-
defaultValue: [{
|
|
70
|
-
type: 'paragraph',
|
|
71
|
-
children: [{
|
|
72
|
-
text: ''
|
|
73
|
-
}]
|
|
74
|
-
}],
|
|
75
|
-
deserialize: data => {
|
|
76
|
-
var _data$config$path;
|
|
77
|
-
const documentFromServer = (_data$config$path = data[config.path]) === null || _data$config$path === void 0 ? void 0 : _data$config$path.document;
|
|
78
|
-
if (!documentFromServer) {
|
|
79
|
-
return [{
|
|
80
|
-
type: 'paragraph',
|
|
81
|
-
children: [{
|
|
82
|
-
text: ''
|
|
83
|
-
}]
|
|
84
|
-
}];
|
|
85
|
-
}
|
|
86
|
-
// make a temporary editor to normalize the document
|
|
87
|
-
const editor = editorShared.createDocumentEditor(config.fieldMeta.documentFeatures, componentBlocks, config.fieldMeta.relationships);
|
|
88
|
-
editor.children = documentFromServer;
|
|
89
|
-
slate.Editor.normalize(editor, {
|
|
90
|
-
force: true
|
|
91
|
-
});
|
|
92
|
-
return editor.children;
|
|
93
|
-
},
|
|
94
|
-
serialize: value => ({
|
|
95
|
-
[config.path]: value
|
|
96
|
-
}),
|
|
97
|
-
validate(value) {
|
|
98
|
-
return value.every(node => validateNode(node));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const allowedExportsOnCustomViews = ['componentBlocks'];
|
|
104
|
-
|
|
105
|
-
Object.defineProperty(exports, 'Field', {
|
|
106
|
-
enumerable: true,
|
|
107
|
-
get: function () { return Field__default["default"]; }
|
|
108
|
-
});
|
|
109
|
-
Object.defineProperty(exports, 'Cell', {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function () { return Cell__default["default"]; }
|
|
112
|
-
});
|
|
113
|
-
exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
|
|
114
|
-
exports.controller = controller;
|
|
16
|
+
unregister();
|