@prosekit/basic 0.0.0-next-20230709094459 → 0.0.0-next-20240421132240

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.
@@ -0,0 +1,122 @@
1
+ import { Attrs } from 'prosemirror-model';
2
+ import { DedentListOptions } from 'prosemirror-flat-list';
3
+ import { Extension } from '@prosekit/core';
4
+ import { HeadingAttrs } from '@prosekit/extensions/heading';
5
+ import { ImageAttrs } from '@prosekit/extensions/image';
6
+ import { IndentListOptions } from 'prosemirror-flat-list';
7
+ import { LinkAttrs } from '@prosekit/extensions/link';
8
+ import { ListAttributes } from 'prosemirror-flat-list';
9
+ import { MarkType } from 'prosemirror-model';
10
+ import { Node as Node_2 } from 'prosemirror-model';
11
+ import { NodeRange } from 'prosemirror-model';
12
+ import { NodeType } from 'prosemirror-model';
13
+ import { Options } from 'tsup';
14
+ import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
15
+ import { UnwrapListOptions } from 'prosemirror-flat-list';
16
+
17
+ /**
18
+ * @public
19
+ */
20
+ export declare type BasicExtension = ReturnType<typeof defineBasicExtension>;
21
+
22
+ export declare namespace default_alias {
23
+ let plugins: {
24
+ 'postcss-nesting': {};
25
+ };
26
+ }
27
+
28
+ export declare const default_alias_1: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
29
+
30
+ export declare const default_alias_2: {
31
+ test: {
32
+ environment: "jsdom";
33
+ };
34
+ };
35
+
36
+ /**
37
+ * A basic extension that includes some common functionality. You can copy this
38
+ * function and customize it to your needs.
39
+ * @public
40
+ */
41
+ export declare function defineBasicExtension(): Extension< {
42
+ NODES: "blockquote" | "table" | "text" | "doc" | "paragraph" | "heading" | "image" | "list" | "tableRow" | "tableCell" | "tableHeaderCell";
43
+ MARKS: "code" | "link" | "bold" | "strike" | "italic" | "underline";
44
+ COMMAND_ARGS: {
45
+ setHeading: [attrs?: HeadingAttrs | undefined];
46
+ insertHeading: [attrs?: HeadingAttrs | undefined];
47
+ toggleHeading: [attrs?: HeadingAttrs | undefined];
48
+ undo: [];
49
+ redo: [];
50
+ dedentList: [options?: DedentListOptions | undefined];
51
+ indentList: [options?: IndentListOptions | undefined];
52
+ moveList: [direction: "up" | "down"];
53
+ splitList: [];
54
+ toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
55
+ toggleList: [attrs: ListAttributes];
56
+ unwrapList: [options?: UnwrapListOptions | undefined];
57
+ wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
58
+ insertList: [attrs?: ListAttributes | undefined];
59
+ toggleItalic: [];
60
+ toggleBold: [];
61
+ toggleUnderline: [];
62
+ toggleStrike: [];
63
+ toggleCode: [];
64
+ addLink: [attrs: LinkAttrs];
65
+ removeLink: [];
66
+ toggleLink: [attrs: LinkAttrs];
67
+ expandLink: [];
68
+ insertImage: [attrs?: ImageAttrs | undefined];
69
+ insertTable: [{
70
+ row: number;
71
+ col: number;
72
+ header: boolean;
73
+ }];
74
+ exitTable: [];
75
+ insertText: [{
76
+ text: string;
77
+ from?: number | undefined;
78
+ to?: number | undefined;
79
+ }];
80
+ insertNode: [options: {
81
+ node: Node_2;
82
+ pos?: number | undefined;
83
+ type?: undefined;
84
+ attrs?: undefined;
85
+ } | {
86
+ node?: undefined;
87
+ pos?: number | undefined;
88
+ type: string;
89
+ attrs?: Attrs | undefined;
90
+ }];
91
+ wrap: [{
92
+ nodeType: NodeType;
93
+ attrs?: Attrs | null | undefined;
94
+ }];
95
+ setBlockType: [options: {
96
+ type: string | NodeType;
97
+ attrs?: Attrs | null | undefined;
98
+ from?: number | undefined;
99
+ to?: number | undefined;
100
+ }];
101
+ setNodeAttrs: [options: {
102
+ type: string | NodeType;
103
+ attrs: Attrs;
104
+ pos?: number | undefined;
105
+ }];
106
+ selectAll: [];
107
+ addMark: [options: {
108
+ type: string | MarkType;
109
+ attrs?: Attrs | null | undefined;
110
+ from?: number | undefined;
111
+ to?: number | undefined;
112
+ }];
113
+ removeMark: [options: {
114
+ type: string | MarkType;
115
+ attrs?: Attrs | null | undefined;
116
+ from?: number | undefined;
117
+ to?: number | undefined;
118
+ }];
119
+ };
120
+ }>;
121
+
122
+ export { }
@@ -1,34 +1,2 @@
1
- import * as _prosekit_core from '@prosekit/core';
2
- import * as prosemirror_model from 'prosemirror-model';
3
-
4
- /** @public */
5
- declare function addBasicExtension(): _prosekit_core.Extension<{
6
- NODES: "doc" | "text" | "heading" | "list" | "paragraph";
7
- MARKS: "italic";
8
- COMMAND_ARGS: {
9
- toggleItalic: [];
10
- insertText: [{
11
- text: string;
12
- from?: number | undefined;
13
- to?: number | undefined;
14
- }];
15
- insertNode: [{
16
- node: prosemirror_model.Node;
17
- pos?: number | undefined;
18
- }];
19
- wrap: [{
20
- nodeType: prosemirror_model.NodeType;
21
- attrs?: prosemirror_model.Attrs | null | undefined;
22
- }];
23
- setBlockType: [{
24
- nodeType: prosemirror_model.NodeType;
25
- attrs?: prosemirror_model.Attrs | null | undefined;
26
- from?: number | undefined;
27
- to?: number | undefined;
28
- }];
29
- selectAll: [];
30
- };
31
- }>;
32
- type BasicExtension = ReturnType<typeof addBasicExtension>;
33
-
34
- export { BasicExtension, addBasicExtension };
1
+ export { defineBasicExtension } from './_tsup-dts-rollup';
2
+ export { BasicExtension } from './_tsup-dts-rollup';
@@ -1,29 +1,49 @@
1
1
  // src/index.ts
2
2
  import {
3
- addBaseKeymap,
4
- addBaseCommands,
5
- addDoc,
6
- addParagraph,
7
- addText,
8
- defineExtension,
9
- Priority,
10
- withPriority
3
+ defineBaseCommands,
4
+ defineBaseKeymap,
5
+ defineDoc,
6
+ defineHistory,
7
+ defineParagraph,
8
+ defineText,
9
+ union
11
10
  } from "@prosekit/core";
12
- import { addHeading } from "@prosekit/extensions/heading";
13
- import { addItalic } from "@prosekit/extensions/italic";
14
- import { addList } from "@prosekit/extensions/list";
15
- function addBasicExtension() {
16
- return defineExtension([
17
- addDoc(),
18
- addText(),
19
- addHeading(),
20
- addList(),
21
- addBaseKeymap(),
22
- addBaseCommands(),
23
- addItalic(),
24
- withPriority(addParagraph(), Priority.high)
11
+ import { defineBlockquote } from "@prosekit/extensions/blockquote";
12
+ import { defineBold } from "@prosekit/extensions/bold";
13
+ import { defineCode } from "@prosekit/extensions/code";
14
+ import { defineDropCursor } from "@prosekit/extensions/drop-cursor";
15
+ import { defineHeading } from "@prosekit/extensions/heading";
16
+ import { defineImage } from "@prosekit/extensions/image";
17
+ import { defineItalic } from "@prosekit/extensions/italic";
18
+ import { defineLink } from "@prosekit/extensions/link";
19
+ import { defineList } from "@prosekit/extensions/list";
20
+ import { defineStrike } from "@prosekit/extensions/strike";
21
+ import { defineTable } from "@prosekit/extensions/table";
22
+ import { defineUnderline } from "@prosekit/extensions/underline";
23
+ import { defineVirtualSelection } from "@prosekit/extensions/virtual-selection";
24
+ function defineBasicExtension() {
25
+ return union([
26
+ defineDoc(),
27
+ defineText(),
28
+ defineHeading(),
29
+ defineHistory(),
30
+ defineList(),
31
+ defineBlockquote(),
32
+ defineBaseKeymap(),
33
+ defineBaseCommands(),
34
+ defineItalic(),
35
+ defineBold(),
36
+ defineUnderline(),
37
+ defineStrike(),
38
+ defineCode(),
39
+ defineLink(),
40
+ defineImage(),
41
+ defineParagraph(),
42
+ defineDropCursor(),
43
+ defineVirtualSelection(),
44
+ defineTable()
25
45
  ]);
26
46
  }
27
47
  export {
28
- addBasicExtension
48
+ defineBasicExtension
29
49
  };
package/dist/style.css CHANGED
@@ -1,4 +1,4 @@
1
- /* ../../node_modules/.pnpm/prosemirror-view@1.31.5/node_modules/prosemirror-view/style/prosemirror.css */
1
+ /* ../../node_modules/.pnpm/prosemirror-view@1.33.4/node_modules/prosemirror-view/style/prosemirror.css */
2
2
  .ProseMirror {
3
3
  position: relative;
4
4
  }
@@ -25,6 +25,9 @@
25
25
  .ProseMirror-hideselection {
26
26
  caret-color: transparent;
27
27
  }
28
+ .ProseMirror [draggable][contenteditable=false] {
29
+ user-select: text;
30
+ }
28
31
  .ProseMirror-selectednode {
29
32
  outline: 2px solid #8cf;
30
33
  }
@@ -49,9 +52,7 @@ img.ProseMirror-separator {
49
52
 
50
53
  /* ../pm/src/view/style/prosemirror.css */
51
54
 
52
- /* ../core/src/style.css */
53
-
54
- /* ../../node_modules/.pnpm/prosemirror-flat-list@0.3.15/node_modules/prosemirror-flat-list/dist/style.css */
55
+ /* ../../node_modules/.pnpm/prosemirror-flat-list@0.5.0/node_modules/prosemirror-flat-list/dist/style.css */
55
56
  .prosemirror-flat-list {
56
57
  padding: 0;
57
58
  margin-top: 0;
@@ -78,25 +79,30 @@ img.ProseMirror-separator {
78
79
  .prosemirror-flat-list[data-list-kind=bullet] {
79
80
  list-style: disc;
80
81
  }
82
+ .prosemirror-flat-list[data-list-kind=ordered] {
83
+ counter-increment: prosemirror-flat-list-counter;
84
+ }
85
+ .prosemirror-flat-list[data-list-kind=ordered] > * {
86
+ contain: style;
87
+ }
81
88
  .prosemirror-flat-list[data-list-kind=ordered]::before {
82
89
  position: absolute;
83
90
  right: 100%;
84
91
  font-variant-numeric: tabular-nums;
85
92
  content: counter(prosemirror-flat-list-counter, decimal) ". ";
86
93
  }
87
- @supports (-moz-appearance: none) {
88
- .prosemirror-flat-list[data-list-kind=ordered] {
89
- contain: style;
90
- counter-increment: prosemirror-flat-list-counter;
91
- }
94
+ .prosemirror-flat-list[data-list-kind=ordered]:first-child,
95
+ :not(.prosemirror-flat-list[data-list-kind=ordered]) + .prosemirror-flat-list[data-list-kind=ordered] {
96
+ counter-reset: prosemirror-flat-list-counter;
92
97
  }
93
- @supports not (-moz-appearance: none) {
94
- .prosemirror-flat-list[data-list-kind=ordered] {
95
- counter-reset: prosemirror-flat-list-counter;
96
- counter-increment: prosemirror-flat-list-counter;
98
+ @supports (counter-set: prosemirror-flat-list-counter 1) {
99
+ [data-list-order]:is(.prosemirror-flat-list[data-list-kind=ordered]:first-child, :not(.prosemirror-flat-list[data-list-kind=ordered]) + .prosemirror-flat-list[data-list-kind=ordered]) {
100
+ counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
97
101
  }
98
- .prosemirror-flat-list[data-list-kind=ordered] + .prosemirror-flat-list[data-list-kind=ordered] {
99
- counter-reset: none;
102
+ }
103
+ @supports not (counter-set: prosemirror-flat-list-counter 1) {
104
+ [data-list-order]:is(.prosemirror-flat-list[data-list-kind=ordered]:first-child, :not(.prosemirror-flat-list[data-list-kind=ordered]) + .prosemirror-flat-list[data-list-kind=ordered]) {
105
+ counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
100
106
  }
101
107
  }
102
108
  .prosemirror-flat-list[data-list-kind=task] > .list-marker {
@@ -130,10 +136,61 @@ img.ProseMirror-separator {
130
136
  opacity: 40%;
131
137
  pointer-events: none;
132
138
  }
133
- .prosemirror-flat-list[data-list-kind=toggle][data-list-collapsable][data-list-collapsed] > .list-content > *:nth-child(n + 2) {
139
+ .prosemirror-flat-list[data-list-kind=toggle][data-list-collapsable][data-list-collapsed] > .list-content > *:nth-child(n+2) {
134
140
  display: none;
135
141
  }
136
142
 
137
143
  /* ../extensions/src/list/style.css */
138
144
 
145
+ /* ../extensions/src/table/style.css */
146
+ .ProseMirror .tableWrapper {
147
+ overflow-x: auto;
148
+ }
149
+ .ProseMirror table {
150
+ border-collapse: collapse;
151
+ table-layout: fixed;
152
+ width: 100%;
153
+ overflow: hidden;
154
+ }
155
+ .ProseMirror td,
156
+ .ProseMirror th {
157
+ vertical-align: top;
158
+ box-sizing: border-box;
159
+ position: relative;
160
+ border-width: 1px;
161
+ }
162
+ .ProseMirror .column-resize-handle {
163
+ position: absolute;
164
+ right: -2px;
165
+ top: 0;
166
+ bottom: 0;
167
+ width: 4px;
168
+ z-index: 20;
169
+ background-color: HighlightText;
170
+ pointer-events: none;
171
+ }
172
+ .ProseMirror.resize-cursor {
173
+ cursor: ew-resize;
174
+ cursor: col-resize;
175
+ }
176
+ .ProseMirror .selectedCell {
177
+ background-color: Highlight;
178
+ }
179
+
180
+ /* ../extensions/src/placeholder/style.css */
181
+ .prosekit-placeholder::before {
182
+ position: absolute;
183
+ opacity: 30%;
184
+ pointer-events: none;
185
+ height: 0;
186
+ content: attr(data-placeholder);
187
+ }
188
+
189
+ /* ../extensions/src/virtual-selection/style.css */
190
+ .prosekit-virtual-selection {
191
+ background-color: Highlight;
192
+ box-shadow: 0 0 0 3px Highlight;
193
+ border-radius: 2px;
194
+ }
195
+
139
196
  /* src/style.css */
@@ -0,0 +1,137 @@
1
+ /* src/typography.css */
2
+ div.ProseMirror {
3
+ display: flex;
4
+ flex-direction: column;
5
+ }
6
+ div.ProseMirror p:first-child,
7
+ div.ProseMirror h1:first-child,
8
+ div.ProseMirror h2:first-child,
9
+ div.ProseMirror h3:first-child,
10
+ div.ProseMirror h4:first-child,
11
+ div.ProseMirror h5:first-child,
12
+ div.ProseMirror h6:first-child {
13
+ margin-top: 0;
14
+ }
15
+ div.ProseMirror p:last-child,
16
+ div.ProseMirror h1:last-child,
17
+ div.ProseMirror h2:last-child,
18
+ div.ProseMirror h3:last-child,
19
+ div.ProseMirror h4:last-child,
20
+ div.ProseMirror h5:last-child,
21
+ div.ProseMirror h6:last-child {
22
+ margin-bottom: 0;
23
+ }
24
+ div.ProseMirror h1,
25
+ div.ProseMirror h2,
26
+ div.ProseMirror h3,
27
+ div.ProseMirror h4,
28
+ div.ProseMirror h5,
29
+ div.ProseMirror h6 {
30
+ font-weight: 600;
31
+ line-height: 1.25;
32
+ padding-top: 0;
33
+ padding-bottom: 0;
34
+ border-style: none;
35
+ }
36
+ div.ProseMirror a {
37
+ text-decoration: underline;
38
+ font-weight: 500;
39
+ }
40
+ div.ProseMirror p,
41
+ div.ProseMirror ul,
42
+ div.ProseMirror ol,
43
+ div.ProseMirror pre {
44
+ padding: 0.5rem 0;
45
+ line-height: 1.5;
46
+ }
47
+ div.ProseMirror blockquote {
48
+ padding-left: 1em;
49
+ border-left: 0.25em solid hsla(0, 0%, 60%, 0.4);
50
+ }
51
+ div.ProseMirror h1 {
52
+ margin: 1rem 0;
53
+ font-size: 2.25em;
54
+ }
55
+ div.ProseMirror h2 {
56
+ margin: 1.75em 0 0.5em;
57
+ font-size: 1.75em;
58
+ }
59
+ div.ProseMirror h3 {
60
+ margin: 1.5em 0 0.5em;
61
+ font-size: 1.375em;
62
+ }
63
+ div.ProseMirror h4 {
64
+ margin: 1em 0;
65
+ font-size: 1.125em;
66
+ }
67
+ div.ProseMirror h5 {
68
+ margin: 0.5em 0;
69
+ }
70
+ div.ProseMirror h6 {
71
+ opacity: 0.8;
72
+ }
73
+ div.ProseMirror img,
74
+ div.ProseMirror video {
75
+ margin: 0.4em 0;
76
+ width: min-content;
77
+ max-width: 100%;
78
+ }
79
+ div.ProseMirror code {
80
+ font-size: 0.875em;
81
+ font-weight: 600;
82
+ }
83
+ div.ProseMirror pre {
84
+ margin: 0.5rem 0;
85
+ padding: 2rem 2rem;
86
+ overflow-x: auto;
87
+ border-radius: 0.375rem;
88
+ }
89
+ div.ProseMirror pre,
90
+ div.ProseMirror code {
91
+ white-space: pre;
92
+ word-spacing: normal;
93
+ word-break: normal;
94
+ word-wrap: normal;
95
+ tab-size: 4;
96
+ hyphens: none;
97
+ }
98
+ div.ProseMirror pre code {
99
+ font-weight: inherit;
100
+ }
101
+ div.ProseMirror hr {
102
+ margin: 2em 0;
103
+ }
104
+ div.ProseMirror .prosemirror-flat-list {
105
+ line-height: 1.5;
106
+ }
107
+ div.ProseMirror .prosemirror-flat-list::before,
108
+ div.ProseMirror .prosemirror-flat-list > .list-marker {
109
+ top: 0.5rem;
110
+ }
111
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h1)::before,
112
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h1) > .list-marker {
113
+ top: 1em;
114
+ }
115
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h2)::before,
116
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h2) > .list-marker {
117
+ top: 0.6em;
118
+ }
119
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h3)::before,
120
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h3) > .list-marker {
121
+ top: 0.25em;
122
+ }
123
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h4)::before,
124
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h4) > .list-marker {
125
+ top: 0;
126
+ }
127
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h5)::before,
128
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h5) > .list-marker {
129
+ top: -0.1em;
130
+ }
131
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h6)::before,
132
+ div.ProseMirror .prosemirror-flat-list:has(> div.list-content > h6) > .list-marker {
133
+ top: -0.1em;
134
+ }
135
+ div.ProseMirror .ProseMirror-selectednode {
136
+ z-index: calc(infinity);
137
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/basic",
3
3
  "type": "module",
4
- "version": "0.0.0-next-20230709094459",
4
+ "version": "0.0.0-next-20240421132240",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -32,20 +32,26 @@
32
32
  },
33
33
  "./style.css": {
34
34
  "default": "./dist/style.css"
35
+ },
36
+ "./typography.css": {
37
+ "default": "./dist/typography.css"
35
38
  }
36
39
  },
37
40
  "files": [
38
41
  "dist"
39
42
  ],
40
43
  "dependencies": {
41
- "@prosekit/core": "0.0.0-next-20230709094459",
42
- "@prosekit/extensions": "0.0.0-next-20230709094459"
44
+ "@prosekit/core": "0.0.0-next-20240421132240",
45
+ "@prosekit/extensions": "0.0.0-next-20240421132240",
46
+ "@prosekit/pm": "0.0.0-next-20240421132240"
43
47
  },
44
48
  "devDependencies": {
45
49
  "@prosekit/dev": "*",
46
- "tsup": "^7.1.0",
47
- "typescript": "^5.1.6",
48
- "vitest": "^0.33.0"
50
+ "postcss": "^8.4.38",
51
+ "postcss-nesting": "^12.1.1",
52
+ "tsup": "^8.0.2",
53
+ "typescript": "^5.4.5",
54
+ "vitest": "^1.5.0"
49
55
  },
50
56
  "scripts": {
51
57
  "build:tsup": "tsup",
package/src/index.ts DELETED
@@ -1,29 +0,0 @@
1
- import {
2
- addBaseKeymap,
3
- addBaseCommands,
4
- addDoc,
5
- addParagraph,
6
- addText,
7
- defineExtension,
8
- Priority,
9
- withPriority,
10
- } from '@prosekit/core'
11
- import { addHeading } from '@prosekit/extensions/heading'
12
- import { addItalic } from '@prosekit/extensions/italic'
13
- import { addList } from '@prosekit/extensions/list'
14
-
15
- /** @public */
16
- export function addBasicExtension() {
17
- return defineExtension([
18
- addDoc(),
19
- addText(),
20
- addHeading(),
21
- addList(),
22
- addBaseKeymap(),
23
- addBaseCommands(),
24
- addItalic(),
25
- withPriority(addParagraph(), Priority.high),
26
- ])
27
- }
28
-
29
- export type BasicExtension = ReturnType<typeof addBasicExtension>