@thomasfosterau/effect-richtext 0.0.0-stage → 0.1.0

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 (176) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +118 -2
  3. package/dist/_virtual/_rolldown/runtime.js +12 -0
  4. package/dist/commands/commands.d.ts +323 -0
  5. package/dist/commands/commands.js +722 -0
  6. package/dist/commands/internal.js +43 -0
  7. package/dist/commands/keymaps.d.ts +46 -0
  8. package/dist/commands/keymaps.js +64 -0
  9. package/dist/commands.d.ts +3 -0
  10. package/dist/commands.js +3 -0
  11. package/dist/compat/commands.d.ts +250 -0
  12. package/dist/compat/commands.js +275 -0
  13. package/dist/compat/internal/core.d.ts +20 -0
  14. package/dist/compat/internal/core.js +148 -0
  15. package/dist/compat/internal/props.js +82 -0
  16. package/dist/compat/keymap.d.ts +21 -0
  17. package/dist/compat/keymap.js +38 -0
  18. package/dist/compat/model.d.ts +893 -0
  19. package/dist/compat/model.js +1212 -0
  20. package/dist/compat/orderedmap.d.ts +74 -0
  21. package/dist/compat/orderedmap.js +124 -0
  22. package/dist/compat/schema-basic.d.ts +38 -0
  23. package/dist/compat/schema-basic.js +238 -0
  24. package/dist/compat/schema-list.d.ts +81 -0
  25. package/dist/compat/schema-list.js +156 -0
  26. package/dist/compat/state.d.ts +415 -0
  27. package/dist/compat/state.js +689 -0
  28. package/dist/compat/test-builder.d.ts +98 -0
  29. package/dist/compat/test-builder.js +197 -0
  30. package/dist/compat/transform.d.ts +458 -0
  31. package/dist/compat/transform.js +803 -0
  32. package/dist/compat/view.d.ts +411 -0
  33. package/dist/compat/view.js +409 -0
  34. package/dist/dropcursor.d.ts +46 -0
  35. package/dist/dropcursor.js +176 -0
  36. package/dist/extensions/defaults.d.ts +716 -0
  37. package/dist/extensions/defaults.js +209 -0
  38. package/dist/extensions/editor.d.ts +246 -0
  39. package/dist/extensions/editor.js +271 -0
  40. package/dist/extensions/extension.d.ts +375 -0
  41. package/dist/extensions/extension.js +233 -0
  42. package/dist/extensions.d.ts +4 -0
  43. package/dist/extensions.js +4 -0
  44. package/dist/gapcursor.d.ts +66 -0
  45. package/dist/gapcursor.js +273 -0
  46. package/dist/history.d.ts +178 -0
  47. package/dist/history.js +412 -0
  48. package/dist/html.d.ts +158 -0
  49. package/dist/html.js +164 -0
  50. package/dist/inputrules.d.ts +271 -0
  51. package/dist/inputrules.js +321 -0
  52. package/dist/internal/attempt.js +15 -0
  53. package/dist/internal/json.js +29 -0
  54. package/dist/keymap/keymap.d.ts +130 -0
  55. package/dist/keymap/keymap.js +159 -0
  56. package/dist/keymap.d.ts +2 -0
  57. package/dist/keymap.js +1 -0
  58. package/dist/markdown/errors.d.ts +23 -0
  59. package/dist/markdown/errors.js +26 -0
  60. package/dist/markdown/from_markdown.d.ts +185 -0
  61. package/dist/markdown/from_markdown.js +266 -0
  62. package/dist/markdown/schema.d.ts +522 -0
  63. package/dist/markdown/schema.js +292 -0
  64. package/dist/markdown/to_markdown.d.ts +251 -0
  65. package/dist/markdown/to_markdown.js +413 -0
  66. package/dist/markdown.d.ts +5 -0
  67. package/dist/markdown.js +5 -0
  68. package/dist/model/attrsCodec.js +48 -0
  69. package/dist/model/comparedeep.js +17 -0
  70. package/dist/model/content.d.ts +232 -0
  71. package/dist/model/content.js +630 -0
  72. package/dist/model/diff.js +66 -0
  73. package/dist/model/dom.d.ts +3 -0
  74. package/dist/model/errors.d.ts +90 -0
  75. package/dist/model/errors.js +76 -0
  76. package/dist/model/fragment.d.ts +131 -0
  77. package/dist/model/fragment.js +262 -0
  78. package/dist/model/from_dom.d.ts +299 -0
  79. package/dist/model/from_dom.js +618 -0
  80. package/dist/model/json.d.ts +37 -0
  81. package/dist/model/json.js +126 -0
  82. package/dist/model/mark.d.ts +73 -0
  83. package/dist/model/mark.js +121 -0
  84. package/dist/model/node.d.ts +267 -0
  85. package/dist/model/node.js +434 -0
  86. package/dist/model/replace.d.ts +78 -0
  87. package/dist/model/replace.js +207 -0
  88. package/dist/model/resolvedpos.d.ts +196 -0
  89. package/dist/model/resolvedpos.js +305 -0
  90. package/dist/model/schema.d.ts +740 -0
  91. package/dist/model/schema.js +451 -0
  92. package/dist/model/to_dom.d.ts +169 -0
  93. package/dist/model/to_dom.js +238 -0
  94. package/dist/model.d.ts +12 -0
  95. package/dist/model.js +12 -0
  96. package/dist/placeholder.d.ts +53 -0
  97. package/dist/placeholder.js +79 -0
  98. package/dist/reactive/observer.d.ts +54 -0
  99. package/dist/reactive/observer.js +61 -0
  100. package/dist/reactive/selectors.d.ts +22 -0
  101. package/dist/reactive/selectors.js +61 -0
  102. package/dist/reactive/stateref.d.ts +72 -0
  103. package/dist/reactive/stateref.js +71 -0
  104. package/dist/reactive/streams.d.ts +83 -0
  105. package/dist/reactive/streams.js +85 -0
  106. package/dist/reactive.d.ts +16 -0
  107. package/dist/reactive.js +26 -0
  108. package/dist/schema-basic.d.ts +448 -0
  109. package/dist/schema-basic.js +269 -0
  110. package/dist/schema-list/commands.d.ts +66 -0
  111. package/dist/schema-list/commands.js +203 -0
  112. package/dist/schema-list.d.ts +92 -0
  113. package/dist/schema-list.js +100 -0
  114. package/dist/state/errors.d.ts +39 -0
  115. package/dist/state/errors.js +32 -0
  116. package/dist/state/plugin.d.ts +232 -0
  117. package/dist/state/plugin.js +82 -0
  118. package/dist/state/selection.d.ts +297 -0
  119. package/dist/state/selection.js +486 -0
  120. package/dist/state/state.d.ts +212 -0
  121. package/dist/state/state.js +489 -0
  122. package/dist/state/transaction.d.ts +145 -0
  123. package/dist/state/transaction.js +195 -0
  124. package/dist/state.d.ts +6 -0
  125. package/dist/state.js +6 -0
  126. package/dist/test-builder.d.ts +3582 -0
  127. package/dist/test-builder.js +239 -0
  128. package/dist/transform/attr_step.d.ts +60 -0
  129. package/dist/transform/attr_step.js +105 -0
  130. package/dist/transform/errors.d.ts +50 -0
  131. package/dist/transform/errors.js +35 -0
  132. package/dist/transform/map.d.ts +182 -0
  133. package/dist/transform/map.js +280 -0
  134. package/dist/transform/mark.js +98 -0
  135. package/dist/transform/mark_set_step.js +69 -0
  136. package/dist/transform/mark_step.d.ts +113 -0
  137. package/dist/transform/mark_step.js +225 -0
  138. package/dist/transform/replace.d.ts +18 -0
  139. package/dist/transform/replace.js +381 -0
  140. package/dist/transform/replace_step.d.ts +109 -0
  141. package/dist/transform/replace_step.js +175 -0
  142. package/dist/transform/step.d.ts +157 -0
  143. package/dist/transform/step.js +168 -0
  144. package/dist/transform/structure.d.ts +89 -0
  145. package/dist/transform/structure.js +350 -0
  146. package/dist/transform/transform.d.ts +248 -0
  147. package/dist/transform/transform.js +373 -0
  148. package/dist/transform.d.ts +10 -0
  149. package/dist/transform.js +10 -0
  150. package/dist/view/browser.js +39 -0
  151. package/dist/view/capturekeys.js +282 -0
  152. package/dist/view/clipboard.d.ts +8 -0
  153. package/dist/view/clipboard.js +245 -0
  154. package/dist/view/decoration.d.ts +339 -0
  155. package/dist/view/decoration.js +566 -0
  156. package/dist/view/dom.d.ts +18 -0
  157. package/dist/view/dom.js +140 -0
  158. package/dist/view/domchange.js +295 -0
  159. package/dist/view/domcoords.d.ts +22 -0
  160. package/dist/view/domcoords.js +448 -0
  161. package/dist/view/domobserver.d.ts +47 -0
  162. package/dist/view/domobserver.js +328 -0
  163. package/dist/view/errors.d.ts +18 -0
  164. package/dist/view/errors.js +21 -0
  165. package/dist/view/input.d.ts +58 -0
  166. package/dist/view/input.js +704 -0
  167. package/dist/view/selection.js +198 -0
  168. package/dist/view/view.d.ts +699 -0
  169. package/dist/view/view.js +623 -0
  170. package/dist/view/viewdesc.d.ts +236 -0
  171. package/dist/view/viewdesc.js +1205 -0
  172. package/dist/view-css.d.ts +43 -0
  173. package/dist/view-css.js +124 -0
  174. package/dist/view.d.ts +6 -0
  175. package/dist/view.js +4 -0
  176. package/package.json +206 -3
@@ -0,0 +1,74 @@
1
+ /**
2
+ * A port of the [`orderedmap`](https://github.com/marijnh/orderedmap)
3
+ * package (MIT, Marijn Haverbeke), used by the ProseMirror-compatible
4
+ * schema (`schema.spec.nodes` / `schema.spec.marks`). Code that imports
5
+ * `orderedmap` directly can alias it to this module.
6
+ *
7
+ * @since 0.1.0
8
+ */
9
+ /**
10
+ * A persistent, ordered map from string keys to values.
11
+ *
12
+ * @since 0.1.0
13
+ * @category models
14
+ */
15
+ export declare class OrderedMap<T = any> {
16
+ readonly content: Array<string | T>;
17
+ /** @internal */
18
+ constructor(content: Array<string | T>);
19
+ /** @internal */
20
+ find(key: string): number;
21
+ /** Retrieve the value stored under `key`, or `undefined`. */
22
+ get(key: string): T | undefined;
23
+ /**
24
+ * Create a new map by replacing the value of `key` with a new value,
25
+ * or adding a binding to the end of the map. If `newKey` is given,
26
+ * the key of the binding will be replaced with that key.
27
+ */
28
+ update(key: string, value: T, newKey?: string): OrderedMap<T>;
29
+ /** Return a map with the given key removed, if it existed. */
30
+ remove(key: string): OrderedMap<T>;
31
+ /** Add a new key to the start of the map. */
32
+ addToStart(key: string, value: T): OrderedMap<T>;
33
+ /** Add a new key to the end of the map. */
34
+ addToEnd(key: string, value: T): OrderedMap<T>;
35
+ /**
36
+ * Add a key before the given key. If `place` is not found, the new key
37
+ * is added to the end.
38
+ */
39
+ addBefore(place: string, key: string, value: T): OrderedMap<T>;
40
+ /** Call the given function for each key/value pair in the map, in order. */
41
+ forEach(f: (key: string, value: T) => void): void;
42
+ /**
43
+ * Create a new map by prepending the keys in `map` that don't appear
44
+ * in this map before the keys in this map.
45
+ */
46
+ prepend(map: MapLike<T>): OrderedMap<T>;
47
+ /**
48
+ * Create a new map by appending the keys in `map` that don't appear
49
+ * in this map after the keys in this map.
50
+ */
51
+ append(map: MapLike<T>): OrderedMap<T>;
52
+ /** Create a map containing all the keys in this map that don't appear in `map`. */
53
+ subtract(map: MapLike<T>): OrderedMap<T>;
54
+ /** Turn the ordered map into a plain object. */
55
+ toObject(): Record<string, T>;
56
+ /** The amount of keys in this map. */
57
+ get size(): number;
58
+ /**
59
+ * Return a map with the given content. If null, create an empty map.
60
+ * If given an ordered map, return that map itself. If given an
61
+ * object, create a map from the object's properties.
62
+ */
63
+ static from<T>(map: MapLike<T>): OrderedMap<T>;
64
+ }
65
+ /**
66
+ * Anything that can be converted to an `OrderedMap`.
67
+ *
68
+ * @since 0.1.0
69
+ * @category models
70
+ */
71
+ export type MapLike<T = any> = {
72
+ readonly [key: string]: T;
73
+ } | OrderedMap<T> | null | undefined;
74
+ export { OrderedMap as default };
@@ -0,0 +1,124 @@
1
+ // src/compat/orderedmap.ts
2
+ /**
3
+ * A port of the [`orderedmap`](https://github.com/marijnh/orderedmap)
4
+ * package (MIT, Marijn Haverbeke), used by the ProseMirror-compatible
5
+ * schema (`schema.spec.nodes` / `schema.spec.marks`). Code that imports
6
+ * `orderedmap` directly can alias it to this module.
7
+ *
8
+ * @since 0.1.0
9
+ */
10
+ /**
11
+ * A persistent, ordered map from string keys to values.
12
+ *
13
+ * @since 0.1.0
14
+ * @category models
15
+ */
16
+ var OrderedMap = class OrderedMap {
17
+ /** @internal */
18
+ constructor(content) {
19
+ this.content = content;
20
+ }
21
+ /** @internal */
22
+ find(key) {
23
+ for (let i = 0; i < this.content.length; i += 2) if (this.content[i] === key) return i;
24
+ return -1;
25
+ }
26
+ /** Retrieve the value stored under `key`, or `undefined`. */
27
+ get(key) {
28
+ const found = this.find(key);
29
+ return found === -1 ? void 0 : this.content[found + 1];
30
+ }
31
+ /**
32
+ * Create a new map by replacing the value of `key` with a new value,
33
+ * or adding a binding to the end of the map. If `newKey` is given,
34
+ * the key of the binding will be replaced with that key.
35
+ */
36
+ update(key, value, newKey) {
37
+ const self = newKey && newKey !== key ? this.remove(newKey) : this;
38
+ const found = self.find(key), content = self.content.slice();
39
+ if (found === -1) content.push(newKey || key, value);
40
+ else {
41
+ content[found + 1] = value;
42
+ if (newKey) content[found] = newKey;
43
+ }
44
+ return new OrderedMap(content);
45
+ }
46
+ /** Return a map with the given key removed, if it existed. */
47
+ remove(key) {
48
+ const found = this.find(key);
49
+ if (found === -1) return this;
50
+ const content = this.content.slice();
51
+ content.splice(found, 2);
52
+ return new OrderedMap(content);
53
+ }
54
+ /** Add a new key to the start of the map. */
55
+ addToStart(key, value) {
56
+ return new OrderedMap([key, value].concat(this.remove(key).content));
57
+ }
58
+ /** Add a new key to the end of the map. */
59
+ addToEnd(key, value) {
60
+ const content = this.remove(key).content.slice();
61
+ content.push(key, value);
62
+ return new OrderedMap(content);
63
+ }
64
+ /**
65
+ * Add a key before the given key. If `place` is not found, the new key
66
+ * is added to the end.
67
+ */
68
+ addBefore(place, key, value) {
69
+ const without = this.remove(key), content = without.content.slice();
70
+ const found = without.find(place);
71
+ content.splice(found === -1 ? content.length : found, 0, key, value);
72
+ return new OrderedMap(content);
73
+ }
74
+ /** Call the given function for each key/value pair in the map, in order. */
75
+ forEach(f) {
76
+ for (let i = 0; i < this.content.length; i += 2) f(this.content[i], this.content[i + 1]);
77
+ }
78
+ /**
79
+ * Create a new map by prepending the keys in `map` that don't appear
80
+ * in this map before the keys in this map.
81
+ */
82
+ prepend(map) {
83
+ const other = OrderedMap.from(map);
84
+ if (!other.size) return this;
85
+ return new OrderedMap(other.content.concat(this.subtract(other).content));
86
+ }
87
+ /**
88
+ * Create a new map by appending the keys in `map` that don't appear
89
+ * in this map after the keys in this map.
90
+ */
91
+ append(map) {
92
+ const other = OrderedMap.from(map);
93
+ if (!other.size) return this;
94
+ return new OrderedMap(this.subtract(other).content.concat(other.content));
95
+ }
96
+ /** Create a map containing all the keys in this map that don't appear in `map`. */
97
+ subtract(map) {
98
+ return OrderedMap.from(map).content.reduce((result, key, i) => i % 2 === 0 ? result.remove(key) : result, this);
99
+ }
100
+ /** Turn the ordered map into a plain object. */
101
+ toObject() {
102
+ const result = {};
103
+ this.forEach((key, value) => {
104
+ result[key] = value;
105
+ });
106
+ return result;
107
+ }
108
+ /** The amount of keys in this map. */
109
+ get size() {
110
+ return this.content.length >> 1;
111
+ }
112
+ /**
113
+ * Return a map with the given content. If null, create an empty map.
114
+ * If given an ordered map, return that map itself. If given an
115
+ * object, create a map from the object's properties.
116
+ */
117
+ static from(map) {
118
+ if (map instanceof OrderedMap) return map;
119
+ const content = [];
120
+ if (map) for (const prop in map) content.push(prop, map[prop]);
121
+ return new OrderedMap(content);
122
+ }
123
+ };
124
+ export { OrderedMap, OrderedMap as default };
@@ -0,0 +1,38 @@
1
+ import { MarkSpec, NodeSpec, Schema } from "./model.js";
2
+ /**
3
+ * Specs for the nodes defined in this schema.
4
+ *
5
+ * @since 0.1.0
6
+ * @category specs
7
+ */
8
+ export declare const nodes: {
9
+ doc: NodeSpec;
10
+ paragraph: NodeSpec;
11
+ blockquote: NodeSpec;
12
+ horizontal_rule: NodeSpec;
13
+ heading: NodeSpec;
14
+ code_block: NodeSpec;
15
+ text: NodeSpec;
16
+ image: NodeSpec;
17
+ hard_break: NodeSpec;
18
+ };
19
+ /**
20
+ * Specs for the marks in the schema.
21
+ *
22
+ * @since 0.1.0
23
+ * @category specs
24
+ */
25
+ export declare const marks: {
26
+ link: MarkSpec;
27
+ em: MarkSpec;
28
+ strong: MarkSpec;
29
+ code: MarkSpec;
30
+ };
31
+ /**
32
+ * This schema roughly corresponds to the document schema used by
33
+ * CommonMark, minus the list elements.
34
+ *
35
+ * @since 0.1.0
36
+ * @category schemas
37
+ */
38
+ export declare const schema: Schema<keyof typeof nodes, keyof typeof marks>;
@@ -0,0 +1,238 @@
1
+ import { Schema } from "./model.js";
2
+ // src/compat/schema-basic.ts
3
+ /**
4
+ * A `prosemirror-schema-basic`-compatible module: the basic schema
5
+ * specs, built with the compat `Schema`.
6
+ *
7
+ * Ported from prosemirror-schema-basic (MIT, Marijn Haverbeke and others).
8
+ *
9
+ * @since 0.1.0
10
+ */
11
+ const pDOM = ["p", 0];
12
+ const blockquoteDOM = ["blockquote", 0];
13
+ const hrDOM = ["hr"];
14
+ const preDOM = ["pre", ["code", 0]];
15
+ const brDOM = ["br"];
16
+ /**
17
+ * Specs for the nodes defined in this schema.
18
+ *
19
+ * @since 0.1.0
20
+ * @category specs
21
+ */
22
+ const nodes = {
23
+ doc: { content: "block+" },
24
+ paragraph: {
25
+ content: "inline*",
26
+ group: "block",
27
+ parseDOM: [{ tag: "p" }],
28
+ toDOM() {
29
+ return pDOM;
30
+ }
31
+ },
32
+ blockquote: {
33
+ content: "block+",
34
+ group: "block",
35
+ defining: true,
36
+ parseDOM: [{ tag: "blockquote" }],
37
+ toDOM() {
38
+ return blockquoteDOM;
39
+ }
40
+ },
41
+ horizontal_rule: {
42
+ group: "block",
43
+ parseDOM: [{ tag: "hr" }],
44
+ toDOM() {
45
+ return hrDOM;
46
+ }
47
+ },
48
+ heading: {
49
+ attrs: { level: {
50
+ default: 1,
51
+ validate: "number"
52
+ } },
53
+ content: "inline*",
54
+ group: "block",
55
+ defining: true,
56
+ parseDOM: [
57
+ {
58
+ tag: "h1",
59
+ attrs: { level: 1 }
60
+ },
61
+ {
62
+ tag: "h2",
63
+ attrs: { level: 2 }
64
+ },
65
+ {
66
+ tag: "h3",
67
+ attrs: { level: 3 }
68
+ },
69
+ {
70
+ tag: "h4",
71
+ attrs: { level: 4 }
72
+ },
73
+ {
74
+ tag: "h5",
75
+ attrs: { level: 5 }
76
+ },
77
+ {
78
+ tag: "h6",
79
+ attrs: { level: 6 }
80
+ }
81
+ ],
82
+ toDOM(node) {
83
+ return ["h" + node.attrs.level, 0];
84
+ }
85
+ },
86
+ code_block: {
87
+ content: "text*",
88
+ marks: "",
89
+ group: "block",
90
+ code: true,
91
+ defining: true,
92
+ parseDOM: [{
93
+ tag: "pre",
94
+ preserveWhitespace: "full"
95
+ }],
96
+ toDOM() {
97
+ return preDOM;
98
+ }
99
+ },
100
+ text: { group: "inline" },
101
+ image: {
102
+ inline: true,
103
+ attrs: {
104
+ src: { validate: "string" },
105
+ alt: {
106
+ default: null,
107
+ validate: "string|null"
108
+ },
109
+ title: {
110
+ default: null,
111
+ validate: "string|null"
112
+ }
113
+ },
114
+ group: "inline",
115
+ draggable: true,
116
+ parseDOM: [{
117
+ tag: "img[src]",
118
+ getAttrs(dom) {
119
+ return {
120
+ src: dom.getAttribute("src"),
121
+ title: dom.getAttribute("title"),
122
+ alt: dom.getAttribute("alt")
123
+ };
124
+ }
125
+ }],
126
+ toDOM(node) {
127
+ const { alt, src, title } = node.attrs;
128
+ return ["img", {
129
+ src,
130
+ alt,
131
+ title
132
+ }];
133
+ }
134
+ },
135
+ hard_break: {
136
+ inline: true,
137
+ group: "inline",
138
+ selectable: false,
139
+ parseDOM: [{ tag: "br" }],
140
+ toDOM() {
141
+ return brDOM;
142
+ }
143
+ }
144
+ };
145
+ const emDOM = ["em", 0];
146
+ const strongDOM = ["strong", 0];
147
+ const codeDOM = ["code", 0];
148
+ /**
149
+ * Specs for the marks in the schema.
150
+ *
151
+ * @since 0.1.0
152
+ * @category specs
153
+ */
154
+ const marks = {
155
+ link: {
156
+ attrs: {
157
+ href: { validate: "string" },
158
+ title: {
159
+ default: null,
160
+ validate: "string|null"
161
+ }
162
+ },
163
+ inclusive: false,
164
+ parseDOM: [{
165
+ tag: "a[href]",
166
+ getAttrs(dom) {
167
+ return {
168
+ href: dom.getAttribute("href"),
169
+ title: dom.getAttribute("title")
170
+ };
171
+ }
172
+ }],
173
+ toDOM(node) {
174
+ const { href, title } = node.attrs;
175
+ return [
176
+ "a",
177
+ {
178
+ href,
179
+ title
180
+ },
181
+ 0
182
+ ];
183
+ }
184
+ },
185
+ em: {
186
+ parseDOM: [
187
+ { tag: "i" },
188
+ { tag: "em" },
189
+ { style: "font-style=italic" },
190
+ {
191
+ style: "font-style=normal",
192
+ clearMark: (m) => m.type.name == "em"
193
+ }
194
+ ],
195
+ toDOM() {
196
+ return emDOM;
197
+ }
198
+ },
199
+ strong: {
200
+ parseDOM: [
201
+ { tag: "strong" },
202
+ {
203
+ tag: "b",
204
+ getAttrs: (node) => node.style.fontWeight != "normal" && null
205
+ },
206
+ {
207
+ style: "font-weight=400",
208
+ clearMark: (m) => m.type.name == "strong"
209
+ },
210
+ {
211
+ style: "font-weight",
212
+ getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
213
+ }
214
+ ],
215
+ toDOM() {
216
+ return strongDOM;
217
+ }
218
+ },
219
+ code: {
220
+ code: true,
221
+ parseDOM: [{ tag: "code" }],
222
+ toDOM() {
223
+ return codeDOM;
224
+ }
225
+ }
226
+ };
227
+ /**
228
+ * This schema roughly corresponds to the document schema used by
229
+ * CommonMark, minus the list elements.
230
+ *
231
+ * @since 0.1.0
232
+ * @category schemas
233
+ */
234
+ const schema = new Schema({
235
+ nodes,
236
+ marks
237
+ });
238
+ export { marks, nodes, schema };
@@ -0,0 +1,81 @@
1
+ import { Attrs, NodeRange, NodeSpec, NodeType } from "./model.js";
2
+ import { OrderedMap } from "./orderedmap.js";
3
+ import { Command, Transaction } from "./state.js";
4
+ /**
5
+ * An ordered list node spec.
6
+ *
7
+ * @since 0.1.0
8
+ * @category specs
9
+ */
10
+ export declare const orderedList: NodeSpec;
11
+ /**
12
+ * A bullet list node spec.
13
+ *
14
+ * @since 0.1.0
15
+ * @category specs
16
+ */
17
+ export declare const bulletList: NodeSpec;
18
+ /**
19
+ * A list item node spec.
20
+ *
21
+ * @since 0.1.0
22
+ * @category specs
23
+ */
24
+ export declare const listItem: NodeSpec;
25
+ /**
26
+ * Convenience function for adding list-related node types to a map
27
+ * specifying the nodes for a schema.
28
+ *
29
+ * @since 0.1.0
30
+ * @category specs
31
+ */
32
+ export declare function addListNodes(nodes: OrderedMap<NodeSpec>, itemContent: string, listGroup?: string): OrderedMap<NodeSpec>;
33
+ /**
34
+ * Returns a command function that wraps the selection in a list with
35
+ * the given type and attributes.
36
+ *
37
+ * @since 0.1.0
38
+ * @category commands
39
+ */
40
+ export declare function wrapInList(listType: NodeType, attrs?: Attrs | null): Command;
41
+ /**
42
+ * Try to wrap the given node range in a list of the given type.
43
+ * Return `true` when this is possible, `false` otherwise. When `tr` is
44
+ * non-null, the wrapping is added to that transaction.
45
+ *
46
+ * @since 0.1.0
47
+ * @category commands
48
+ */
49
+ export declare function wrapRangeInList(tr: Transaction | null, range: NodeRange, listType: NodeType, attrs?: Attrs | null): boolean;
50
+ /**
51
+ * Build a command that splits a non-empty textblock at the top level
52
+ * of a list item by also splitting that list item.
53
+ *
54
+ * @since 0.1.0
55
+ * @category commands
56
+ */
57
+ export declare function splitListItem(itemType: NodeType | ReadonlyArray<NodeType>, itemAttrs?: Attrs): Command;
58
+ /**
59
+ * Acts like `splitListItem`, but without resetting the set of active
60
+ * marks at the cursor.
61
+ *
62
+ * @since 0.1.0
63
+ * @category commands
64
+ */
65
+ export declare function splitListItemKeepMarks(itemType: NodeType | ReadonlyArray<NodeType>, itemAttrs?: Attrs): Command;
66
+ /**
67
+ * Create a command to lift the list item around the selection up into
68
+ * a wrapping list.
69
+ *
70
+ * @since 0.1.0
71
+ * @category commands
72
+ */
73
+ export declare function liftListItem(itemType: NodeType | ReadonlyArray<NodeType>): Command;
74
+ /**
75
+ * Create a command to sink the list item around the selection down
76
+ * into an inner list.
77
+ *
78
+ * @since 0.1.0
79
+ * @category commands
80
+ */
81
+ export declare function sinkListItem(itemType: NodeType | ReadonlyArray<NodeType>): Command;
@@ -0,0 +1,156 @@
1
+ import { liftListItem as liftListItem$1, sinkListItem as sinkListItem$1, splitListItem as splitListItem$1, splitListItemKeepMarks as splitListItemKeepMarks$1, wrapInList as wrapInList$1, wrapRangeInList as wrapRangeInList$1 } from "../schema-list/commands.js";
2
+ import { fromCoreCommand } from "./state.js";
3
+ import { CORE } from "./internal/core.js";
4
+ import { NodeType } from "./model.js";
5
+ // src/compat/schema-list.ts
6
+ /**
7
+ * A `prosemirror-schema-list`-compatible module: list node specs,
8
+ * `addListNodes`, and the list commands (bridged to the core
9
+ * `@thomasfosterau/effect-richtext/schema-list` commands).
10
+ *
11
+ * Ported from prosemirror-schema-list (MIT, Marijn Haverbeke and others).
12
+ *
13
+ * @since 0.1.0
14
+ */
15
+ const olDOM = ["ol", 0];
16
+ const ulDOM = ["ul", 0];
17
+ const liDOM = ["li", 0];
18
+ /**
19
+ * An ordered list node spec.
20
+ *
21
+ * @since 0.1.0
22
+ * @category specs
23
+ */
24
+ const orderedList = {
25
+ attrs: { order: {
26
+ default: 1,
27
+ validate: "number"
28
+ } },
29
+ parseDOM: [{
30
+ tag: "ol",
31
+ getAttrs(dom) {
32
+ return { order: dom.hasAttribute("start") ? +dom.getAttribute("start") : 1 };
33
+ }
34
+ }],
35
+ toDOM(node) {
36
+ return node.attrs.order == 1 ? olDOM : [
37
+ "ol",
38
+ { start: node.attrs.order },
39
+ 0
40
+ ];
41
+ }
42
+ };
43
+ /**
44
+ * A bullet list node spec.
45
+ *
46
+ * @since 0.1.0
47
+ * @category specs
48
+ */
49
+ const bulletList = {
50
+ parseDOM: [{ tag: "ul" }],
51
+ toDOM() {
52
+ return ulDOM;
53
+ }
54
+ };
55
+ /**
56
+ * A list item node spec.
57
+ *
58
+ * @since 0.1.0
59
+ * @category specs
60
+ */
61
+ const listItem = {
62
+ parseDOM: [{ tag: "li" }],
63
+ toDOM() {
64
+ return liDOM;
65
+ },
66
+ defining: true
67
+ };
68
+ function add(obj, props) {
69
+ const copy = {};
70
+ for (const prop in obj) copy[prop] = obj[prop];
71
+ for (const prop in props) copy[prop] = props[prop];
72
+ return copy;
73
+ }
74
+ /**
75
+ * Convenience function for adding list-related node types to a map
76
+ * specifying the nodes for a schema.
77
+ *
78
+ * @since 0.1.0
79
+ * @category specs
80
+ */
81
+ function addListNodes(nodes, itemContent, listGroup) {
82
+ return nodes.append({
83
+ ordered_list: add(orderedList, {
84
+ content: "list_item+",
85
+ group: listGroup
86
+ }),
87
+ bullet_list: add(bulletList, {
88
+ content: "list_item+",
89
+ group: listGroup
90
+ }),
91
+ list_item: add(listItem, { content: itemContent })
92
+ });
93
+ }
94
+ /**
95
+ * Returns a command function that wraps the selection in a list with
96
+ * the given type and attributes.
97
+ *
98
+ * @since 0.1.0
99
+ * @category commands
100
+ */
101
+ function wrapInList(listType, attrs = null) {
102
+ return fromCoreCommand(wrapInList$1(listType[CORE], attrs));
103
+ }
104
+ /**
105
+ * Try to wrap the given node range in a list of the given type.
106
+ * Return `true` when this is possible, `false` otherwise. When `tr` is
107
+ * non-null, the wrapping is added to that transaction.
108
+ *
109
+ * @since 0.1.0
110
+ * @category commands
111
+ */
112
+ function wrapRangeInList(tr, range, listType, attrs = null) {
113
+ return wrapRangeInList$1(tr ? tr[CORE] : null, range[CORE], listType[CORE], attrs);
114
+ }
115
+ const coreItemTypes = (itemType) => itemType instanceof NodeType ? itemType[CORE] : itemType.map((t) => t[CORE]);
116
+ /**
117
+ * Build a command that splits a non-empty textblock at the top level
118
+ * of a list item by also splitting that list item.
119
+ *
120
+ * @since 0.1.0
121
+ * @category commands
122
+ */
123
+ function splitListItem(itemType, itemAttrs) {
124
+ return fromCoreCommand(splitListItem$1(coreItemTypes(itemType), itemAttrs));
125
+ }
126
+ /**
127
+ * Acts like `splitListItem`, but without resetting the set of active
128
+ * marks at the cursor.
129
+ *
130
+ * @since 0.1.0
131
+ * @category commands
132
+ */
133
+ function splitListItemKeepMarks(itemType, itemAttrs) {
134
+ return fromCoreCommand(splitListItemKeepMarks$1(coreItemTypes(itemType), itemAttrs));
135
+ }
136
+ /**
137
+ * Create a command to lift the list item around the selection up into
138
+ * a wrapping list.
139
+ *
140
+ * @since 0.1.0
141
+ * @category commands
142
+ */
143
+ function liftListItem(itemType) {
144
+ return fromCoreCommand(liftListItem$1(coreItemTypes(itemType)));
145
+ }
146
+ /**
147
+ * Create a command to sink the list item around the selection down
148
+ * into an inner list.
149
+ *
150
+ * @since 0.1.0
151
+ * @category commands
152
+ */
153
+ function sinkListItem(itemType) {
154
+ return fromCoreCommand(sinkListItem$1(coreItemTypes(itemType)));
155
+ }
156
+ export { addListNodes, bulletList, liftListItem, listItem, orderedList, sinkListItem, splitListItem, splitListItemKeepMarks, wrapInList, wrapRangeInList };