@prosekit/basic 0.5.0 → 0.5.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.
@@ -22,9 +22,7 @@ import { UnderlineExtension } from "@prosekit/extensions/underline";
22
22
  import { VirtualSelectionExtension } from "@prosekit/extensions/virtual-selection";
23
23
 
24
24
  //#region src/index.d.ts
25
- /**
26
- * @internal
27
- */
25
+
28
26
  /**
29
27
  * @internal
30
28
  */
@@ -63,6 +61,5 @@ type BasicExtension = Union<[DocExtension, TextExtension, ParagraphExtension, He
63
61
  * @public
64
62
  */
65
63
  declare function defineBasicExtension(): BasicExtension;
66
-
67
64
  //#endregion
68
65
  export { BasicExtension, defineBasicExtension };
@@ -56,35 +56,7 @@ import { defineVirtualSelection } from "@prosekit/extensions/virtual-selection";
56
56
  * @public
57
57
  */
58
58
  function defineBasicExtension() {
59
- return union(
60
- // Nodes
61
- defineDoc(),
62
- defineText(),
63
- defineParagraph(),
64
- defineHeading(),
65
- defineList(),
66
- defineBlockquote(),
67
- defineImage(),
68
- defineHorizontalRule(),
69
- defineHardBreak(),
70
- defineTable(),
71
- defineCodeBlock(),
72
- // Marks
73
- defineItalic(),
74
- defineBold(),
75
- defineUnderline(),
76
- defineStrike(),
77
- defineCode(),
78
- defineLink(),
79
- // Others
80
- defineBaseKeymap(),
81
- defineBaseCommands(),
82
- defineHistory(),
83
- defineDropCursor(),
84
- defineGapCursor(),
85
- defineVirtualSelection(),
86
- defineModClickPrevention()
87
- );
59
+ return union(defineDoc(), defineText(), defineParagraph(), defineHeading(), defineList(), defineBlockquote(), defineImage(), defineHorizontalRule(), defineHardBreak(), defineTable(), defineCodeBlock(), defineItalic(), defineBold(), defineUnderline(), defineStrike(), defineCode(), defineLink(), defineBaseKeymap(), defineBaseCommands(), defineHistory(), defineDropCursor(), defineGapCursor(), defineVirtualSelection(), defineModClickPrevention());
88
60
  }
89
61
 
90
62
  //#endregion
package/dist/style.css CHANGED
@@ -146,56 +146,52 @@ img.ProseMirror-separator {
146
146
  .ProseMirror .tableWrapper {
147
147
  overflow-x: auto;
148
148
  }
149
-
150
149
  .ProseMirror table {
151
- border-collapse: collapse;
152
- table-layout: fixed;
153
150
  width: 100%;
154
151
  overflow: hidden;
152
+ border-collapse: collapse;
153
+ table-layout: fixed;
155
154
  }
156
-
157
- .ProseMirror td, .ProseMirror th {
155
+ .ProseMirror td,
156
+ .ProseMirror th {
158
157
  box-sizing: border-box;
159
- vertical-align: top;
160
- border-width: 1px;
161
- padding-left: .75rem;
162
- padding-right: .75rem;
163
158
  position: relative;
159
+ padding-right: 0.75rem;
160
+ padding-left: 0.75rem;
161
+ border-width: 1px;
162
+ vertical-align: top;
164
163
  }
165
-
166
164
  .ProseMirror .column-resize-handle {
167
165
  z-index: 20;
168
- pointer-events: none;
169
- background-color: highlighttext;
170
- width: 4px;
171
166
  position: absolute;
172
167
  top: 0;
173
- bottom: 0;
174
168
  right: -2px;
169
+ bottom: 0;
170
+ width: 4px;
171
+ background-color: HighlightText;
172
+ pointer-events: none;
175
173
  }
176
-
177
174
  .ProseMirror.resize-cursor {
178
175
  cursor: ew-resize;
179
176
  cursor: col-resize;
180
177
  }
181
-
182
178
  .ProseMirror .selectedCell {
183
179
  --color: 210, 100%, 56%;
184
180
  border: 1px double hsl(var(--color));
185
181
  background-color: hsla(var(--color), 20%);
186
182
  }
187
183
 
188
- .prosekit-placeholder:before {
184
+ .prosekit-placeholder::before {
185
+ position: absolute;
186
+ height: 0;
189
187
  content: attr(data-placeholder);
190
- opacity: .3;
188
+ opacity: 30%;
191
189
  pointer-events: none;
192
- height: 0;
193
- position: absolute;
194
190
  }
195
191
 
196
192
  .prosekit-virtual-selection {
197
- background-color: #8888884d;
198
193
  border-radius: 2px;
194
+ background-color: #8888884d;
199
195
  box-shadow: 0 0 0 2px #8888884d;
200
196
  }
201
197
 
@@ -203,25 +199,24 @@ img.ProseMirror-separator {
203
199
  background-color: #e5534b80;
204
200
  text-decoration: line-through;
205
201
  }
206
-
207
202
  .prosekit-commit-addition {
208
203
  background-color: #53e54b80;
209
204
  }
210
205
 
211
206
  .ProseMirror-gapcursor {
212
- pointer-events: none;
213
207
  display: none;
214
208
  position: relative;
209
+ pointer-events: none;
215
210
  }
216
211
 
217
212
  .ProseMirror-gapcursor:after {
218
- content: "";
219
- border-top: 1px solid;
220
- width: 20px;
221
- animation: 1.1s steps(2, start) infinite ProseMirror-cursor-blink;
222
213
  display: block;
223
214
  position: absolute;
224
215
  top: -2px;
216
+ width: 20px;
217
+ border-top: 1px solid currentColor;
218
+ content: "";
219
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
225
220
  }
226
221
 
227
222
  @keyframes ProseMirror-cursor-blink {
@@ -1,160 +1,222 @@
1
1
  div.ProseMirror {
2
- flex-direction: column;
3
- line-height: 1.5;
4
- display: flex;
5
- }
6
-
7
- div.ProseMirror p:first-child, div.ProseMirror h1:first-child, div.ProseMirror h2:first-child, div.ProseMirror h3:first-child, div.ProseMirror h4:first-child, div.ProseMirror h5:first-child, div.ProseMirror h6:first-child {
8
- margin-top: 0;
9
- }
10
-
11
- div.ProseMirror p:last-child, div.ProseMirror h1:last-child, div.ProseMirror h2:last-child, div.ProseMirror h3:last-child, div.ProseMirror h4:last-child, div.ProseMirror h5:last-child, div.ProseMirror h6:last-child {
12
- margin-bottom: 0;
13
- }
14
-
15
- div.ProseMirror h1, div.ProseMirror h2, div.ProseMirror h3, div.ProseMirror h4, div.ProseMirror h5, div.ProseMirror h6 {
16
- border-style: none;
17
- padding-top: 0;
18
- padding-bottom: 0;
19
- font-weight: 600;
20
- line-height: 1.25;
21
- }
22
-
23
- div.ProseMirror a {
24
- font-weight: 500;
25
- text-decoration: underline;
26
- }
27
-
28
- div.ProseMirror p, div.ProseMirror ul, div.ProseMirror ol, div.ProseMirror pre {
29
- margin: 0;
30
- padding: .5rem 0;
31
- line-height: 1.5;
32
- }
33
-
34
- div.ProseMirror blockquote {
35
- border-left: .25em solid #9996;
36
- padding-left: 1em;
37
- }
38
-
39
- div.ProseMirror h1 {
40
- margin: 1rem 0;
41
- font-size: 2.25em;
42
- }
43
-
44
- div.ProseMirror h2 {
45
- margin: 1.75em 0 .5em;
46
- font-size: 1.75em;
47
- }
48
-
49
- div.ProseMirror h3 {
50
- margin: 1.5em 0 .5em;
51
- font-size: 1.375em;
52
- }
53
-
54
- div.ProseMirror h4 {
55
- margin: 1em 0;
56
- font-size: 1.125em;
57
- }
58
-
59
- div.ProseMirror h5 {
60
- margin: .5em 0;
61
- }
62
-
63
- div.ProseMirror h6 {
64
- opacity: .8;
65
- }
66
-
67
- div.ProseMirror img, div.ProseMirror video {
68
- width: min-content;
69
- max-width: 100%;
70
- margin: 0;
71
- }
72
-
73
- div.ProseMirror code {
74
- font-size: .875em;
75
- font-weight: 600;
76
- }
77
-
78
- div.ProseMirror pre {
79
- background-color: var(--prosemirror-highlight-bg, inherit);
80
- color: var(--prosemirror-highlight, inherit);
81
- border: 1px solid #80808033;
82
- border-radius: .375rem;
83
- margin: .5rem 0;
84
- padding: 2rem;
85
- overflow-x: auto;
86
- }
87
-
88
- div.ProseMirror pre, div.ProseMirror code {
89
- white-space: pre;
90
- word-break: normal;
91
- word-spacing: normal;
92
- word-wrap: normal;
93
- hyphens: none;
94
- tab-size: 4;
95
- }
96
-
97
- div.ProseMirror pre code {
98
- font-weight: inherit;
99
- }
100
-
101
- div.ProseMirror hr {
102
- border-width: 1px;
103
- margin: 2em 0;
104
- }
105
-
106
- div.ProseMirror .prosekit-horizontal-rule {
107
- margin: 1em 0;
108
- padding: 1em 0;
109
- line-height: 1px;
110
- }
111
-
112
- div.ProseMirror .prosekit-horizontal-rule hr {
113
- margin: 0;
114
- }
115
-
116
- div.ProseMirror .tableWrapper {
117
- margin-top: .5em;
118
- margin-bottom: 1em;
119
- }
120
-
121
- div.ProseMirror .prosemirror-flat-list {
122
- line-height: 1.5;
123
- }
124
-
125
- div.ProseMirror .prosemirror-flat-list:before, div.ProseMirror .prosemirror-flat-list > .list-marker {
126
- top: .5rem;
127
- }
128
-
129
- div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h1):before, div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h1) > .list-marker {
130
- top: 1em;
131
- }
132
-
133
- div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h2):before, div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h2) > .list-marker {
134
- top: .6em;
135
- }
136
-
137
- div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h3):before, div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h3) > .list-marker {
138
- top: .25em;
139
- }
140
-
141
- div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h4):before, div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h4) > .list-marker {
142
- top: 0;
143
- }
144
-
145
- div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h5):before, div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h5) > .list-marker {
146
- top: -.1em;
147
- }
148
-
149
- div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h6):before, div.ProseMirror .prosemirror-flat-list:has( > div.list-content > h6) > .list-marker {
150
- top: -.1em;
151
- }
152
-
153
- div.ProseMirror .ProseMirror-selectednode {
154
- z-index: calc(infinity);
155
- }
156
-
157
- div.ProseMirror div[data-node-view-root="true"] {
158
- display: contents;
2
+ & {
3
+ /* Disable margin collapsing */
4
+ display: flex;
5
+ flex-direction: column;
6
+ }
7
+
8
+ & {
9
+ /* Set the default line height as same as block handle's height */
10
+ line-height: 1.5;
11
+ }
12
+
13
+ & p:first-child,
14
+ & h1:first-child,
15
+ & h2:first-child,
16
+ & h3:first-child,
17
+ & h4:first-child,
18
+ & h5:first-child,
19
+ & h6:first-child {
20
+ margin-top: 0;
21
+ }
22
+
23
+ & p:last-child,
24
+ & h1:last-child,
25
+ & h2:last-child,
26
+ & h3:last-child,
27
+ & h4:last-child,
28
+ & h5:last-child,
29
+ & h6:last-child {
30
+ margin-bottom: 0;
31
+ }
32
+
33
+ & h1,
34
+ & h2,
35
+ & h3,
36
+ & h4,
37
+ & h5,
38
+ & h6 {
39
+ padding-top: 0;
40
+ padding-bottom: 0;
41
+ border-style: none;
42
+ font-weight: 600;
43
+ line-height: 1.25;
44
+ }
45
+
46
+ & a {
47
+ font-weight: 500;
48
+ text-decoration: underline;
49
+ }
50
+
51
+ & p,
52
+ & ul,
53
+ & ol,
54
+ & pre {
55
+ margin: 0;
56
+ padding: 0.5rem 0;
57
+ line-height: 1.5;
58
+ }
59
+
60
+ & blockquote {
61
+ padding-left: 1em;
62
+ border-left: 0.25em solid hsl(0 0% 60% / 0.4);
63
+ }
64
+
65
+ & h1 {
66
+ margin: 1rem 0;
67
+ font-size: 2.25em;
68
+ }
69
+
70
+ & h2 {
71
+ margin: 1.75em 0 0.5em;
72
+ font-size: 1.75em;
73
+ }
74
+
75
+ & h3 {
76
+ margin: 1.5em 0 0.5em;
77
+ font-size: 1.375em;
78
+ }
79
+
80
+ & h4 {
81
+ margin: 1em 0;
82
+ font-size: 1.125em;
83
+ }
84
+
85
+ & h5 {
86
+ margin: 0.5em 0;
87
+ }
88
+
89
+ & h6 {
90
+ opacity: 0.8;
91
+ }
92
+
93
+ & img,
94
+ & video {
95
+ width: min-content;
96
+ max-width: 100%;
97
+ margin: 0;
98
+ }
99
+
100
+ & code {
101
+ font-weight: 600;
102
+ font-size: 0.875em;
103
+ }
104
+
105
+ & pre {
106
+ margin: 0.5rem 0;
107
+ padding: 2rem 2rem;
108
+ overflow-x: auto;
109
+ border: 1px solid hsl(0 0% 50% / 0.2);
110
+ border-radius: 0.375rem;
111
+ /* CSS variables `prosemirror-highlight` and `prosemirror-highlight-bg` are set by package `prosemirror-highlight` */
112
+ background-color: var(--prosemirror-highlight-bg, inherit);
113
+ color: var(--prosemirror-highlight, inherit);
114
+ }
115
+
116
+ & pre,
117
+ & code {
118
+ white-space: pre;
119
+ word-break: normal;
120
+ word-spacing: normal;
121
+ word-wrap: normal;
122
+ hyphens: none;
123
+ tab-size: 4;
124
+ }
125
+
126
+ & pre code {
127
+ font-weight: inherit;
128
+ }
129
+
130
+ & hr {
131
+ margin: 2em 0;
132
+ border-width: 1px;
133
+ }
134
+
135
+ & .prosekit-horizontal-rule {
136
+ margin: 1em 0;
137
+ padding: 1em 0;
138
+ /* Set a small line-height so that the block handle can align to the middle
139
+ of the horizontal rule */
140
+ line-height: 1px;
141
+
142
+ & hr {
143
+ margin: 0;
144
+ }
145
+ }
146
+
147
+ & .tableWrapper {
148
+ margin-top: 0.5em;
149
+ margin-bottom: 1em;
150
+ }
151
+
152
+ & .prosemirror-flat-list {
153
+ /* Use the same line-height as <p> */
154
+ line-height: 1.5;
155
+
156
+ &::before,
157
+ & > .list-marker {
158
+ /* Use the same padding as <p> */
159
+ top: 0.5rem;
160
+ }
161
+
162
+ &:has(> div.list-content > h1) {
163
+ &::before,
164
+ & > .list-marker {
165
+ top: 1em;
166
+ }
167
+ }
168
+ &:has(> div.list-content > h2) {
169
+ &::before,
170
+ & > .list-marker {
171
+ top: 0.6em;
172
+ }
173
+ }
174
+ &:has(> div.list-content > h3) {
175
+ &::before,
176
+ & > .list-marker {
177
+ top: 0.25em;
178
+ }
179
+ }
180
+ &:has(> div.list-content > h4) {
181
+ &::before,
182
+ & > .list-marker {
183
+ top: 0;
184
+ }
185
+ }
186
+ &:has(> div.list-content > h5) {
187
+ &::before,
188
+ & > .list-marker {
189
+ top: -0.1em;
190
+ }
191
+ }
192
+ &:has(> div.list-content > h6) {
193
+ &::before,
194
+ & > .list-marker {
195
+ top: -0.1em;
196
+ }
197
+ }
198
+ }
199
+
200
+ /*
201
+ In Chrome, when an editor is styled with a background color and a selected
202
+ node is dragged, the dragged element inherits this background color, along
203
+ with an additional shadow effect. This visual is not ideal, especially when
204
+ the dragged element lacks any margin or padding. To address this issue, we
205
+ adjust the z-index of the dragged element as a workaround, preventing it from
206
+ inheriting the background color.
207
+
208
+ See also https://stackoverflow.com/a/61812377
209
+ */
210
+ .ProseMirror-selectednode {
211
+ z-index: calc(infinity);
212
+ }
213
+
214
+ /*
215
+ Don't generate box for node view wrapper. This make it easier to style
216
+ the node views.
217
+ */
218
+ div[data-node-view-root="true"] {
219
+ display: contents;
220
+ }
159
221
  }
160
222
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/basic",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.5.1",
5
5
  "private": false,
6
6
  "description": "A quick starter for ProseKit",
7
7
  "author": {
@@ -41,16 +41,16 @@
41
41
  "dist"
42
42
  ],
43
43
  "dependencies": {
44
+ "@prosekit/extensions": "^0.9.1",
44
45
  "@prosekit/core": "^0.8.1",
45
- "@prosekit/extensions": "^0.9.0",
46
46
  "@prosekit/pm": "^0.1.10"
47
47
  },
48
48
  "devDependencies": {
49
- "tsdown": "^0.11.1",
49
+ "tsdown": "^0.12.4",
50
50
  "typescript": "~5.8.3",
51
- "vitest": "^3.1.3",
52
- "@prosekit/config-vitest": "0.0.0",
53
- "@prosekit/config-tsdown": "0.0.0"
51
+ "vitest": "^3.1.4",
52
+ "@prosekit/config-tsdown": "0.0.0",
53
+ "@prosekit/config-vitest": "0.0.0"
54
54
  },
55
55
  "publishConfig": {
56
56
  "dev": {}