prosemirror-schema-basic 1.2.1 → 1.2.3
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/CHANGELOG.md +12 -0
- package/LICENSE +1 -1
- package/dist/index.cjs +25 -22
- package/dist/index.d.cts +87 -0
- package/dist/index.js +6 -6
- package/package.json +2 -2
- package/src/schema-basic.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 1.2.3 (2024-07-14)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Add attribute type validation for headings, images, and link marks.
|
|
6
|
+
|
|
7
|
+
## 1.2.2 (2023-05-17)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Include CommonJS type declarations in the package to please new TypeScript resolution settings.
|
|
12
|
+
|
|
1
13
|
## 1.2.1 (2023-01-18)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (C) 2015-2017 by Marijn Haverbeke <
|
|
1
|
+
Copyright (C) 2015-2017 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
3
|
var prosemirrorModel = require('prosemirror-model');
|
|
8
|
-
|
|
9
4
|
var pDOM = ["p", 0],
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
blockquoteDOM = ["blockquote", 0],
|
|
6
|
+
hrDOM = ["hr"],
|
|
7
|
+
preDOM = ["pre", ["code", 0]],
|
|
8
|
+
brDOM = ["br"];
|
|
14
9
|
var nodes = {
|
|
15
10
|
doc: {
|
|
16
11
|
content: "block+"
|
|
@@ -48,7 +43,8 @@ var nodes = {
|
|
|
48
43
|
heading: {
|
|
49
44
|
attrs: {
|
|
50
45
|
level: {
|
|
51
|
-
"default": 1
|
|
46
|
+
"default": 1,
|
|
47
|
+
validate: "number"
|
|
52
48
|
}
|
|
53
49
|
},
|
|
54
50
|
content: "inline*",
|
|
@@ -109,12 +105,16 @@ var nodes = {
|
|
|
109
105
|
image: {
|
|
110
106
|
inline: true,
|
|
111
107
|
attrs: {
|
|
112
|
-
src: {
|
|
108
|
+
src: {
|
|
109
|
+
validate: "string"
|
|
110
|
+
},
|
|
113
111
|
alt: {
|
|
114
|
-
"default": null
|
|
112
|
+
"default": null,
|
|
113
|
+
validate: "string|null"
|
|
115
114
|
},
|
|
116
115
|
title: {
|
|
117
|
-
"default": null
|
|
116
|
+
"default": null,
|
|
117
|
+
validate: "string|null"
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
group: "inline",
|
|
@@ -131,9 +131,9 @@ var nodes = {
|
|
|
131
131
|
}],
|
|
132
132
|
toDOM: function toDOM(node) {
|
|
133
133
|
var _node$attrs = node.attrs,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
src = _node$attrs.src,
|
|
135
|
+
alt = _node$attrs.alt,
|
|
136
|
+
title = _node$attrs.title;
|
|
137
137
|
return ["img", {
|
|
138
138
|
src: src,
|
|
139
139
|
alt: alt,
|
|
@@ -154,14 +154,17 @@ var nodes = {
|
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
var emDOM = ["em", 0],
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
strongDOM = ["strong", 0],
|
|
158
|
+
codeDOM = ["code", 0];
|
|
159
159
|
var marks = {
|
|
160
160
|
link: {
|
|
161
161
|
attrs: {
|
|
162
|
-
href: {
|
|
162
|
+
href: {
|
|
163
|
+
validate: "string"
|
|
164
|
+
},
|
|
163
165
|
title: {
|
|
164
|
-
"default": null
|
|
166
|
+
"default": null,
|
|
167
|
+
validate: "string|null"
|
|
165
168
|
}
|
|
166
169
|
},
|
|
167
170
|
inclusive: false,
|
|
@@ -176,8 +179,8 @@ var marks = {
|
|
|
176
179
|
}],
|
|
177
180
|
toDOM: function toDOM(node) {
|
|
178
181
|
var _node$attrs2 = node.attrs,
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
href = _node$attrs2.href,
|
|
183
|
+
title = _node$attrs2.title;
|
|
181
184
|
return ["a", {
|
|
182
185
|
href: href,
|
|
183
186
|
title: title
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
[Specs](https://prosemirror.net/docs/ref/#model.NodeSpec) for the nodes defined in this schema.
|
|
5
|
+
*/
|
|
6
|
+
declare const nodes: {
|
|
7
|
+
/**
|
|
8
|
+
NodeSpec The top level document node.
|
|
9
|
+
*/
|
|
10
|
+
doc: NodeSpec;
|
|
11
|
+
/**
|
|
12
|
+
A plain paragraph textblock. Represented in the DOM
|
|
13
|
+
as a `<p>` element.
|
|
14
|
+
*/
|
|
15
|
+
paragraph: NodeSpec;
|
|
16
|
+
/**
|
|
17
|
+
A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
18
|
+
*/
|
|
19
|
+
blockquote: NodeSpec;
|
|
20
|
+
/**
|
|
21
|
+
A horizontal rule (`<hr>`).
|
|
22
|
+
*/
|
|
23
|
+
horizontal_rule: NodeSpec;
|
|
24
|
+
/**
|
|
25
|
+
A heading textblock, with a `level` attribute that
|
|
26
|
+
should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
27
|
+
`<h6>` elements.
|
|
28
|
+
*/
|
|
29
|
+
heading: NodeSpec;
|
|
30
|
+
/**
|
|
31
|
+
A code listing. Disallows marks or non-text inline
|
|
32
|
+
nodes by default. Represented as a `<pre>` element with a
|
|
33
|
+
`<code>` element inside of it.
|
|
34
|
+
*/
|
|
35
|
+
code_block: NodeSpec;
|
|
36
|
+
/**
|
|
37
|
+
The text node.
|
|
38
|
+
*/
|
|
39
|
+
text: NodeSpec;
|
|
40
|
+
/**
|
|
41
|
+
An inline image (`<img>`) node. Supports `src`,
|
|
42
|
+
`alt`, and `href` attributes. The latter two default to the empty
|
|
43
|
+
string.
|
|
44
|
+
*/
|
|
45
|
+
image: NodeSpec;
|
|
46
|
+
/**
|
|
47
|
+
A hard line break, represented in the DOM as `<br>`.
|
|
48
|
+
*/
|
|
49
|
+
hard_break: NodeSpec;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
[Specs](https://prosemirror.net/docs/ref/#model.MarkSpec) for the marks in the schema.
|
|
53
|
+
*/
|
|
54
|
+
declare const marks: {
|
|
55
|
+
/**
|
|
56
|
+
A link. Has `href` and `title` attributes. `title`
|
|
57
|
+
defaults to the empty string. Rendered and parsed as an `<a>`
|
|
58
|
+
element.
|
|
59
|
+
*/
|
|
60
|
+
link: MarkSpec;
|
|
61
|
+
/**
|
|
62
|
+
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
63
|
+
that also match `<i>` and `font-style: italic`.
|
|
64
|
+
*/
|
|
65
|
+
em: MarkSpec;
|
|
66
|
+
/**
|
|
67
|
+
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
68
|
+
`<b>` and `font-weight: bold`.
|
|
69
|
+
*/
|
|
70
|
+
strong: MarkSpec;
|
|
71
|
+
/**
|
|
72
|
+
Code font mark. Represented as a `<code>` element.
|
|
73
|
+
*/
|
|
74
|
+
code: MarkSpec;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
This schema roughly corresponds to the document schema used by
|
|
78
|
+
[CommonMark](http://commonmark.org/), minus the list elements,
|
|
79
|
+
which are defined in the [`prosemirror-schema-list`](https://prosemirror.net/docs/ref/#schema-list)
|
|
80
|
+
module.
|
|
81
|
+
|
|
82
|
+
To reuse elements from this schema, extend or read from its
|
|
83
|
+
`spec.nodes` and `spec.marks` [properties](https://prosemirror.net/docs/ref/#model.Schema.spec).
|
|
84
|
+
*/
|
|
85
|
+
declare const schema: Schema<"blockquote" | "image" | "text" | "doc" | "paragraph" | "horizontal_rule" | "heading" | "code_block" | "hard_break", "link" | "code" | "em" | "strong">;
|
|
86
|
+
|
|
87
|
+
export { marks, nodes, schema };
|
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const nodes = {
|
|
|
45
45
|
`<h6>` elements.
|
|
46
46
|
*/
|
|
47
47
|
heading: {
|
|
48
|
-
attrs: { level: { default: 1 } },
|
|
48
|
+
attrs: { level: { default: 1, validate: "number" } },
|
|
49
49
|
content: "inline*",
|
|
50
50
|
group: "block",
|
|
51
51
|
defining: true,
|
|
@@ -85,9 +85,9 @@ const nodes = {
|
|
|
85
85
|
image: {
|
|
86
86
|
inline: true,
|
|
87
87
|
attrs: {
|
|
88
|
-
src: {},
|
|
89
|
-
alt: { default: null },
|
|
90
|
-
title: { default: null }
|
|
88
|
+
src: { validate: "string" },
|
|
89
|
+
alt: { default: null, validate: "string|null" },
|
|
90
|
+
title: { default: null, validate: "string|null" }
|
|
91
91
|
},
|
|
92
92
|
group: "inline",
|
|
93
93
|
draggable: true,
|
|
@@ -123,8 +123,8 @@ const marks = {
|
|
|
123
123
|
*/
|
|
124
124
|
link: {
|
|
125
125
|
attrs: {
|
|
126
|
-
href: {},
|
|
127
|
-
title: { default: null }
|
|
126
|
+
href: { validate: "string" },
|
|
127
|
+
title: { default: null, validate: "string|null" }
|
|
128
128
|
},
|
|
129
129
|
inclusive: false,
|
|
130
130
|
parseDOM: [{ tag: "a[href]", getAttrs(dom) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-schema-basic",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Basic schema elements for ProseMirror",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"maintainers": [
|
|
16
16
|
{
|
|
17
17
|
"name": "Marijn Haverbeke",
|
|
18
|
-
"email": "
|
|
18
|
+
"email": "marijn@haverbeke.berlin",
|
|
19
19
|
"web": "http://marijnhaverbeke.nl"
|
|
20
20
|
}
|
|
21
21
|
],
|
package/src/schema-basic.ts
CHANGED
|
@@ -40,7 +40,7 @@ export const nodes = {
|
|
|
40
40
|
/// should hold the number 1 to 6. Parsed and serialized as `<h1>` to
|
|
41
41
|
/// `<h6>` elements.
|
|
42
42
|
heading: {
|
|
43
|
-
attrs: {level: {default: 1}},
|
|
43
|
+
attrs: {level: {default: 1, validate: "number"}},
|
|
44
44
|
content: "inline*",
|
|
45
45
|
group: "block",
|
|
46
46
|
defining: true,
|
|
@@ -77,9 +77,9 @@ export const nodes = {
|
|
|
77
77
|
image: {
|
|
78
78
|
inline: true,
|
|
79
79
|
attrs: {
|
|
80
|
-
src: {},
|
|
81
|
-
alt: {default: null},
|
|
82
|
-
title: {default: null}
|
|
80
|
+
src: {validate: "string"},
|
|
81
|
+
alt: {default: null, validate: "string|null"},
|
|
82
|
+
title: {default: null, validate: "string|null"}
|
|
83
83
|
},
|
|
84
84
|
group: "inline",
|
|
85
85
|
draggable: true,
|
|
@@ -112,8 +112,8 @@ export const marks = {
|
|
|
112
112
|
/// element.
|
|
113
113
|
link: {
|
|
114
114
|
attrs: {
|
|
115
|
-
href: {},
|
|
116
|
-
title: {default: null}
|
|
115
|
+
href: {validate: "string"},
|
|
116
|
+
title: {default: null, validate: "string|null"}
|
|
117
117
|
},
|
|
118
118
|
inclusive: false,
|
|
119
119
|
parseDOM: [{tag: "a[href]", getAttrs(dom: HTMLElement) {
|