@prosekit/core 0.1.8 → 0.2.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.
- package/dist/_tsup-dts-rollup.d.ts +27 -8
- package/dist/prosekit-core.d.ts +2 -1
- package/dist/prosekit-core.js +10 -20
- package/package.json +3 -6
- package/src/index.ts +2 -1
- package/dist/style.css +0 -55
@@ -19,6 +19,7 @@ import { NodeSelection } from '@prosekit/pm/state';
|
|
19
19
|
import type { NodeSpec } from '@prosekit/pm/model';
|
20
20
|
import { NodeType } from '@prosekit/pm/model';
|
21
21
|
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
22
|
+
import { NodeView } from '@prosekit/pm/view';
|
22
23
|
import { NodeViewConstructor } from '@prosekit/pm/view';
|
23
24
|
import { Options } from 'tsup';
|
24
25
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
@@ -93,6 +94,32 @@ export declare abstract class BaseExtension<T extends ExtensionTyping = Extensio
|
|
93
94
|
abstract schema: Schema | null;
|
94
95
|
}
|
95
96
|
|
97
|
+
/**
|
98
|
+
* Some basic props for custom node views.
|
99
|
+
*
|
100
|
+
* @public
|
101
|
+
*/
|
102
|
+
declare interface BaseNodeViewOptions {
|
103
|
+
/**
|
104
|
+
* The wrapping DOM element for the node view. Defaults to `div` for block nodes and `span` for inline nodes.
|
105
|
+
*/
|
106
|
+
as?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
|
107
|
+
/**
|
108
|
+
* The wrapping DOM element for the node view's content. Defaults to `div` for block nodes and `span` for inline nodes.
|
109
|
+
*/
|
110
|
+
contentAs?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
|
111
|
+
update?: NodeView['update'];
|
112
|
+
ignoreMutation?: NodeView['ignoreMutation'];
|
113
|
+
selectNode?: NodeView['selectNode'];
|
114
|
+
deselectNode?: NodeView['deselectNode'];
|
115
|
+
setSelection?: NodeView['setSelection'];
|
116
|
+
stopEvent?: NodeView['stopEvent'];
|
117
|
+
destroy?: NodeView['destroy'];
|
118
|
+
onUpdate?: () => void;
|
119
|
+
}
|
120
|
+
export { BaseNodeViewOptions }
|
121
|
+
export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
|
122
|
+
|
96
123
|
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
97
124
|
|
98
125
|
export declare interface CommandApplier<Args extends any[] = any[]> {
|
@@ -380,14 +407,6 @@ declare class Editor<E extends Extension = any> {
|
|
380
407
|
mount(place: HTMLElement | null | undefined | void): void;
|
381
408
|
unmount(): void;
|
382
409
|
use(extension: Extension): VoidFunction;
|
383
|
-
/**
|
384
|
-
* @deprecated
|
385
|
-
*/
|
386
|
-
isNodeActive(nodeType: string | NodeType, attrs?: Attrs): boolean;
|
387
|
-
/**
|
388
|
-
* @deprecated
|
389
|
-
*/
|
390
|
-
isMarkActive(markType: string | MarkType, attrs?: Attrs): boolean;
|
391
410
|
get nodes(): Record<ExtractNodes<E>, NodeBuilder>;
|
392
411
|
get marks(): Record<ExtractMarks<E>, MarkBuilder>;
|
393
412
|
}
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
export { _getId } from './_tsup-dts-rollup';
|
2
1
|
export { addMark } from './_tsup-dts-rollup';
|
3
2
|
export { insertNode } from './_tsup-dts-rollup';
|
4
3
|
export { removeMark } from './_tsup-dts-rollup';
|
@@ -37,6 +36,7 @@ export { defineText } from './_tsup-dts-rollup';
|
|
37
36
|
export { defineUpdateHandler } from './_tsup-dts-rollup';
|
38
37
|
export { Facet } from './_tsup-dts-rollup';
|
39
38
|
export { FacetOptions } from './_tsup-dts-rollup';
|
39
|
+
export { BaseNodeViewOptions } from './_tsup-dts-rollup';
|
40
40
|
export { CommandArgs } from './_tsup-dts-rollup';
|
41
41
|
export { Extension } from './_tsup-dts-rollup';
|
42
42
|
export { ExtractCommandAppliers } from './_tsup-dts-rollup';
|
@@ -50,6 +50,7 @@ export { SelectionJSON } from './_tsup-dts-rollup';
|
|
50
50
|
export { StateJSON } from './_tsup-dts-rollup';
|
51
51
|
export { Priority } from './_tsup-dts-rollup';
|
52
52
|
export { SimplifyUnion } from './_tsup-dts-rollup';
|
53
|
+
export { _getId } from './_tsup-dts-rollup';
|
53
54
|
export { getMarkType } from './_tsup-dts-rollup';
|
54
55
|
export { getNodeType } from './_tsup-dts-rollup';
|
55
56
|
export { jsonFromElement } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
// src/utils/get-id.ts
|
2
|
-
var id = 0;
|
3
|
-
function getId() {
|
4
|
-
id = (id + 1) % Number.MAX_SAFE_INTEGER;
|
5
|
-
return `id:${id}`;
|
6
|
-
}
|
7
|
-
|
8
1
|
// src/commands/add-mark.ts
|
9
2
|
import "@prosekit/pm/model";
|
10
3
|
import "@prosekit/pm/state";
|
@@ -670,6 +663,9 @@ function updateExtension(prevInputs, prevConverters, extension, mode) {
|
|
670
663
|
return { schemaInput, stateInput, viewInput, commandInput };
|
671
664
|
}
|
672
665
|
|
666
|
+
// src/editor/builder.ts
|
667
|
+
import "@prosekit/pm/model";
|
668
|
+
|
673
669
|
// src/utils/type-assertion.ts
|
674
670
|
import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
675
671
|
import {
|
@@ -716,7 +712,6 @@ function hasMark(marks, mark) {
|
|
716
712
|
}
|
717
713
|
|
718
714
|
// src/editor/builder.ts
|
719
|
-
import "@prosekit/pm/model";
|
720
715
|
function createNodeBuilder(getState, type) {
|
721
716
|
const builder = (...args) => buildNode(type, args);
|
722
717
|
builder.isActive = (attrs) => {
|
@@ -1029,18 +1024,6 @@ var Editor = class _Editor {
|
|
1029
1024
|
this.instance.updateExtension(extension, "add");
|
1030
1025
|
return () => this.instance.updateExtension(extension, "remove");
|
1031
1026
|
}
|
1032
|
-
/**
|
1033
|
-
* @deprecated
|
1034
|
-
*/
|
1035
|
-
isNodeActive(nodeType, attrs) {
|
1036
|
-
return isNodeActive(this.view.state, nodeType, attrs);
|
1037
|
-
}
|
1038
|
-
/**
|
1039
|
-
* @deprecated
|
1040
|
-
*/
|
1041
|
-
isMarkActive(markType, attrs) {
|
1042
|
-
return isMarkActive(this.view.state, markType, attrs);
|
1043
|
-
}
|
1044
1027
|
get nodes() {
|
1045
1028
|
return this.instance.nodeBuilders;
|
1046
1029
|
}
|
@@ -1429,6 +1412,13 @@ var updateHandlerFacet = Facet.define({
|
|
1429
1412
|
singleton: true
|
1430
1413
|
});
|
1431
1414
|
var pluginKey = new PluginKey2("prosekit-event-handler");
|
1415
|
+
|
1416
|
+
// src/utils/get-id.ts
|
1417
|
+
var id = 0;
|
1418
|
+
function getId() {
|
1419
|
+
id = (id + 1) % Number.MAX_SAFE_INTEGER;
|
1420
|
+
return `id:${id}`;
|
1421
|
+
}
|
1432
1422
|
export {
|
1433
1423
|
Editor,
|
1434
1424
|
Facet,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.2.0",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -29,16 +29,13 @@
|
|
29
29
|
"types": "./dist/prosekit-core.d.ts",
|
30
30
|
"import": "./dist/prosekit-core.js",
|
31
31
|
"default": "./dist/prosekit-core.js"
|
32
|
-
},
|
33
|
-
"./style.css": {
|
34
|
-
"default": "./dist/style.css"
|
35
32
|
}
|
36
33
|
},
|
37
34
|
"files": [
|
38
35
|
"dist"
|
39
36
|
],
|
40
37
|
"dependencies": {
|
41
|
-
"@prosekit/pm": "^0.1.
|
38
|
+
"@prosekit/pm": "^0.1.1",
|
42
39
|
"orderedmap": "^2.1.1",
|
43
40
|
"type-fest": "^4.8.3"
|
44
41
|
},
|
@@ -46,7 +43,7 @@
|
|
46
43
|
"@prosekit/dev": "*",
|
47
44
|
"tsup": "^8.0.1",
|
48
45
|
"typescript": "^5.3.3",
|
49
|
-
"vitest": "^1.0
|
46
|
+
"vitest": "^1.1.0"
|
50
47
|
},
|
51
48
|
"scripts": {
|
52
49
|
"build:tsup": "tsup",
|
package/src/index.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
export { getId as _getId } from './utils/get-id'
|
2
1
|
export { addMark } from './commands/add-mark'
|
3
2
|
export { insertNode } from './commands/insert-node'
|
4
3
|
export { removeMark } from './commands/remove-mark'
|
@@ -38,6 +37,7 @@ export {
|
|
38
37
|
export { defineText } from './extensions/text'
|
39
38
|
export { defineUpdateHandler } from './extensions/update-handler'
|
40
39
|
export { Facet, type FacetOptions } from './facets/facet'
|
40
|
+
export type { BaseNodeViewOptions } from './types/base-node-view-options'
|
41
41
|
export { type CommandArgs } from './types/command'
|
42
42
|
export {
|
43
43
|
type Extension,
|
@@ -51,6 +51,7 @@ export { type ExtensionTyping } from './types/extension-typing'
|
|
51
51
|
export type { NodeJSON, SelectionJSON, StateJSON } from './types/model'
|
52
52
|
export { Priority } from './types/priority'
|
53
53
|
export { type SimplifyUnion } from './types/simplify-union'
|
54
|
+
export { getId as _getId } from './utils/get-id'
|
54
55
|
export { getMarkType } from './utils/get-mark-type'
|
55
56
|
export { getNodeType } from './utils/get-node-type'
|
56
57
|
export {
|
package/dist/style.css
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
/* ../../node_modules/.pnpm/prosemirror-view@1.32.6/node_modules/prosemirror-view/style/prosemirror.css */
|
2
|
-
.ProseMirror {
|
3
|
-
position: relative;
|
4
|
-
}
|
5
|
-
.ProseMirror {
|
6
|
-
word-wrap: break-word;
|
7
|
-
white-space: pre-wrap;
|
8
|
-
white-space: break-spaces;
|
9
|
-
-webkit-font-variant-ligatures: none;
|
10
|
-
font-variant-ligatures: none;
|
11
|
-
font-feature-settings: "liga" 0;
|
12
|
-
}
|
13
|
-
.ProseMirror pre {
|
14
|
-
white-space: pre-wrap;
|
15
|
-
}
|
16
|
-
.ProseMirror li {
|
17
|
-
position: relative;
|
18
|
-
}
|
19
|
-
.ProseMirror-hideselection *::selection {
|
20
|
-
background: transparent;
|
21
|
-
}
|
22
|
-
.ProseMirror-hideselection *::-moz-selection {
|
23
|
-
background: transparent;
|
24
|
-
}
|
25
|
-
.ProseMirror-hideselection {
|
26
|
-
caret-color: transparent;
|
27
|
-
}
|
28
|
-
.ProseMirror [draggable][contenteditable=false] {
|
29
|
-
user-select: text;
|
30
|
-
}
|
31
|
-
.ProseMirror-selectednode {
|
32
|
-
outline: 2px solid #8cf;
|
33
|
-
}
|
34
|
-
li.ProseMirror-selectednode {
|
35
|
-
outline: none;
|
36
|
-
}
|
37
|
-
li.ProseMirror-selectednode:after {
|
38
|
-
content: "";
|
39
|
-
position: absolute;
|
40
|
-
left: -32px;
|
41
|
-
right: -2px;
|
42
|
-
top: -2px;
|
43
|
-
bottom: -2px;
|
44
|
-
border: 2px solid #8cf;
|
45
|
-
pointer-events: none;
|
46
|
-
}
|
47
|
-
img.ProseMirror-separator {
|
48
|
-
display: inline !important;
|
49
|
-
border: none !important;
|
50
|
-
margin: 0 !important;
|
51
|
-
}
|
52
|
-
|
53
|
-
/* ../pm/src/view/style/prosemirror.css */
|
54
|
-
|
55
|
-
/* src/style.css */
|