@tiptap/core 3.10.4 → 3.10.5
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/dist/index.cjs +13 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/helpers/getSchemaByResolvedExtensions.ts +25 -16
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/core",
|
|
3
3
|
"description": "headless rich text editor",
|
|
4
|
-
"version": "3.10.
|
|
4
|
+
"version": "3.10.5",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"jsx-dev-runtime"
|
|
53
53
|
],
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@tiptap/pm": "^3.10.
|
|
55
|
+
"@tiptap/pm": "^3.10.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@tiptap/pm": "^3.10.
|
|
58
|
+
"@tiptap/pm": "^3.10.5"
|
|
59
59
|
},
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
@@ -24,6 +24,29 @@ function cleanUpSchemaItem<T>(data: T) {
|
|
|
24
24
|
) as T
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Builds an attribute spec tuple for ProseMirror schema from an extension attribute.
|
|
29
|
+
* @param extensionAttribute The extension attribute to build the spec for
|
|
30
|
+
* @returns A tuple of [attributeName, spec]
|
|
31
|
+
*/
|
|
32
|
+
function buildAttributeSpec(
|
|
33
|
+
extensionAttribute: ReturnType<typeof getAttributesFromExtensions>[number],
|
|
34
|
+
): [string, Record<string, any>] {
|
|
35
|
+
const spec: Record<string, any> = {}
|
|
36
|
+
|
|
37
|
+
// Only include 'default' if the attribute is not required and default is defined
|
|
38
|
+
if (!extensionAttribute?.attribute?.isRequired && extensionAttribute?.attribute?.default !== undefined) {
|
|
39
|
+
spec.default = extensionAttribute.attribute.default
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Only include 'validate' if it's defined
|
|
43
|
+
if (extensionAttribute?.attribute?.validate !== undefined) {
|
|
44
|
+
spec.validate = extensionAttribute.attribute.validate
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return [extensionAttribute.name, spec]
|
|
48
|
+
}
|
|
49
|
+
|
|
27
50
|
/**
|
|
28
51
|
* Creates a new Prosemirror schema based on the given extensions.
|
|
29
52
|
* @param extensions An array of Tiptap extensions
|
|
@@ -70,14 +93,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
|
|
|
70
93
|
),
|
|
71
94
|
defining: callOrReturn(getExtensionField<NodeConfig['defining']>(extension, 'defining', context)),
|
|
72
95
|
isolating: callOrReturn(getExtensionField<NodeConfig['isolating']>(extension, 'isolating', context)),
|
|
73
|
-
attrs: Object.fromEntries(
|
|
74
|
-
extensionAttributes.map(extensionAttribute => {
|
|
75
|
-
return [
|
|
76
|
-
extensionAttribute.name,
|
|
77
|
-
{ default: extensionAttribute?.attribute?.default, validate: extensionAttribute?.attribute?.validate },
|
|
78
|
-
]
|
|
79
|
-
}),
|
|
80
|
-
),
|
|
96
|
+
attrs: Object.fromEntries(extensionAttributes.map(buildAttributeSpec)),
|
|
81
97
|
})
|
|
82
98
|
|
|
83
99
|
const parseHTML = callOrReturn(getExtensionField<NodeConfig['parseHTML']>(extension, 'parseHTML', context))
|
|
@@ -134,14 +150,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
|
|
|
134
150
|
group: callOrReturn(getExtensionField<MarkConfig['group']>(extension, 'group', context)),
|
|
135
151
|
spanning: callOrReturn(getExtensionField<MarkConfig['spanning']>(extension, 'spanning', context)),
|
|
136
152
|
code: callOrReturn(getExtensionField<MarkConfig['code']>(extension, 'code', context)),
|
|
137
|
-
attrs: Object.fromEntries(
|
|
138
|
-
extensionAttributes.map(extensionAttribute => {
|
|
139
|
-
return [
|
|
140
|
-
extensionAttribute.name,
|
|
141
|
-
{ default: extensionAttribute?.attribute?.default, validate: extensionAttribute?.attribute?.validate },
|
|
142
|
-
]
|
|
143
|
-
}),
|
|
144
|
-
),
|
|
153
|
+
attrs: Object.fromEntries(extensionAttributes.map(buildAttributeSpec)),
|
|
145
154
|
})
|
|
146
155
|
|
|
147
156
|
const parseHTML = callOrReturn(getExtensionField<MarkConfig['parseHTML']>(extension, 'parseHTML', context))
|