@prosekit/core 0.2.6 → 0.2.7

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.
@@ -513,7 +513,14 @@ declare class Editor<E extends Extension = any> {
513
513
  * Whether the editor is focused.
514
514
  */
515
515
  get focused(): boolean;
516
- mount(place: HTMLElement | null | undefined | void): void;
516
+ /**
517
+ * Mount the editor to the given HTML element.
518
+ * Pass `null` or `undefined` to unmount the editor.
519
+ */
520
+ mount(place: HTMLElement | null | undefined): void;
521
+ /**
522
+ * Unmount the editor. This is equivalent to `mount(null)`.
523
+ */
517
524
  unmount(): void;
518
525
  /**
519
526
  * Focus the editor.
@@ -531,6 +538,15 @@ declare class Editor<E extends Extension = any> {
531
538
  export { Editor }
532
539
  export { Editor as Editor_alias_1 }
533
540
 
541
+ /**
542
+ * @internal
543
+ */
544
+ declare class EditorNotFoundError extends ProseKitError {
545
+ constructor();
546
+ }
547
+ export { EditorNotFoundError }
548
+ export { EditorNotFoundError as EditorNotFoundError_alias_1 }
549
+
534
550
  /**
535
551
  * @public
536
552
  */
@@ -1122,6 +1138,8 @@ export { Priority as Priority_alias_1 }
1122
1138
 
1123
1139
  /**
1124
1140
  * Base class for all ProseKit errors.
1141
+ *
1142
+ * @internal
1125
1143
  */
1126
1144
  declare class ProseKitError extends Error {
1127
1145
  }
@@ -11,6 +11,7 @@ export { EditorOptions } from './_tsup-dts-rollup';
11
11
  export { union } from './_tsup-dts-rollup';
12
12
  export { withPriority } from './_tsup-dts-rollup';
13
13
  export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
14
+ export { EditorNotFoundError_alias_1 as EditorNotFoundError } from './_tsup-dts-rollup';
14
15
  export { defineBaseCommands } from './_tsup-dts-rollup';
15
16
  export { defineCommands } from './_tsup-dts-rollup';
16
17
  export { defineDefaultState } from './_tsup-dts-rollup';
@@ -8,6 +8,13 @@ import "@prosekit/pm/model";
8
8
  // src/error.ts
9
9
  var ProseKitError = class extends Error {
10
10
  };
11
+ var EditorNotFoundError = class extends ProseKitError {
12
+ constructor() {
13
+ super(
14
+ "Unable to find editor. Pass it as an argument or call this function inside a ProseKit component."
15
+ );
16
+ }
17
+ };
11
18
 
12
19
  // src/utils/get-mark-type.ts
13
20
  function getMarkType(schema, type) {
@@ -1038,6 +1045,10 @@ var Editor = class _Editor {
1038
1045
  var _a, _b;
1039
1046
  return (_b = (_a = this.instance.view) == null ? void 0 : _a.hasFocus()) != null ? _b : false;
1040
1047
  }
1048
+ /**
1049
+ * Mount the editor to the given HTML element.
1050
+ * Pass `null` or `undefined` to unmount the editor.
1051
+ */
1041
1052
  mount(place) {
1042
1053
  if (!place) {
1043
1054
  return this.unmount();
@@ -1045,6 +1056,9 @@ var Editor = class _Editor {
1045
1056
  this.instance.mount(place);
1046
1057
  this.afterMounted.forEach((callback) => callback());
1047
1058
  }
1059
+ /**
1060
+ * Unmount the editor. This is equivalent to `mount(null)`.
1061
+ */
1048
1062
  unmount() {
1049
1063
  if (this.mounted) {
1050
1064
  this.instance.unmount();
@@ -1724,6 +1738,7 @@ function withSkipCodeBlock(command) {
1724
1738
  }
1725
1739
  export {
1726
1740
  Editor,
1741
+ EditorNotFoundError,
1727
1742
  Facet,
1728
1743
  OBJECT_REPLACEMENT_CHARACTER,
1729
1744
  Priority,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.2.6",
4
+ "version": "0.2.7",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -38,13 +38,13 @@
38
38
  "@prosekit/pm": "^0.1.1",
39
39
  "clsx": "^2.1.0",
40
40
  "orderedmap": "^2.1.1",
41
- "type-fest": "^4.9.0"
41
+ "type-fest": "^4.10.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@prosekit/dev": "*",
45
45
  "tsup": "^8.0.1",
46
46
  "typescript": "^5.3.3",
47
- "vitest": "^1.2.0"
47
+ "vitest": "^1.2.1"
48
48
  },
49
49
  "scripts": {
50
50
  "build:tsup": "tsup",
package/src/index.ts DELETED
@@ -1,106 +0,0 @@
1
- export { addMark } from './commands/add-mark'
2
- export { insertNode } from './commands/insert-node'
3
- export { removeMark } from './commands/remove-mark'
4
- export { setBlockType } from './commands/set-block-type'
5
- export { setNodeAttrs } from './commands/set-node-attrs'
6
- export { toggleMark } from './commands/toggle-mark'
7
- export { toggleNode } from './commands/toggle-node'
8
- export { Editor, createEditor, type EditorOptions } from './editor/editor'
9
- export { union } from './editor/union'
10
- export { withPriority } from './editor/with-priority'
11
- export { ProseKitError } from './error'
12
- export { defineBaseCommands, defineCommands } from './extensions/command'
13
- export {
14
- defineDefaultState,
15
- type DefaultStateOptions,
16
- } from './extensions/default-state'
17
- export { defineDoc } from './extensions/doc'
18
- export {
19
- defineDocChangeHandler,
20
- type DocChangeHandler,
21
- } from './extensions/events/doc-change'
22
- export {
23
- defineFocusChangeHandler,
24
- type FocusChangeHandler,
25
- } from './extensions/events/focus'
26
- export {
27
- defineMountHandler,
28
- defineUnmountHandler,
29
- defineUpdateHandler,
30
- type MountHandler,
31
- type UnmountHandler,
32
- type UpdateHandler,
33
- } from './extensions/events/plugin-view'
34
- export { defineHistory } from './extensions/history'
35
- export { defineInputRule } from './extensions/input-rules'
36
- export {
37
- defineBaseKeymap,
38
- defineKeymap,
39
- keymapFacet,
40
- type Keymap,
41
- type KeymapPayload,
42
- } from './extensions/keymap'
43
- export {
44
- defineMarkAttr,
45
- defineMarkSpec,
46
- type MarkAttrOptions,
47
- type MarkSpecOptions,
48
- } from './extensions/mark-spec'
49
- export {
50
- defineNodeAttr,
51
- defineNodeSpec,
52
- type NodeAttrOptions,
53
- type NodeSpecOptions,
54
- } from './extensions/node-spec'
55
- export { defineNodeView, type NodeViewOptions } from './extensions/node-view'
56
- export {
57
- defineNodeViewFactory,
58
- type NodeViewFactoryOptions,
59
- } from './extensions/node-view-effect'
60
- export { defineParagraph } from './extensions/paragraph'
61
- export {
62
- definePlugin,
63
- pluginFacet,
64
- type PluginPayload,
65
- } from './extensions/plugin'
66
- export { defineText } from './extensions/text'
67
- export { Facet, type FacetOptions } from './facets/facet'
68
- export type { BaseNodeViewOptions } from './types/base-node-view-options'
69
- export { type CommandArgs } from './types/command'
70
- export {
71
- type Extension,
72
- type ExtractCommandAppliers,
73
- type ExtractCommandCreators,
74
- type ExtractMarks,
75
- type ExtractNodes,
76
- type SimplifyExtension,
77
- } from './types/extension'
78
- export { type ExtensionTyping } from './types/extension-typing'
79
- export type { NodeJSON, SelectionJSON, StateJSON } from './types/model'
80
- export { Priority } from './types/priority'
81
- export { type SimplifyUnion } from './types/simplify-union'
82
- export { clsx } from './utils/clsx'
83
- export { defaultBlockAt } from './utils/default-block-at'
84
- export { getId as _getId } from './utils/get-id'
85
- export { getMarkType } from './utils/get-mark-type'
86
- export { getNodeType } from './utils/get-node-type'
87
- export { isInCodeBlock } from './utils/is-in-code-block'
88
- export {
89
- jsonFromElement,
90
- jsonFromHTML,
91
- jsonFromNode,
92
- jsonFromState,
93
- nodeFromElement,
94
- nodeFromHTML,
95
- nodeFromJSON,
96
- stateFromJSON,
97
- } from './utils/parse'
98
- export {
99
- isAllSelection,
100
- isMark,
101
- isNodeSelection,
102
- isProseMirrorNode,
103
- isTextSelection,
104
- } from './utils/type-assertion'
105
- export * from './utils/unicode'
106
- export { withSkipCodeBlock } from './utils/with-skip-code-block'