@tiptap/extension-table-cell 2.6.5 → 2.7.0-pre.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.
@@ -1,8 +1,6 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model';
2
1
  import { NodeView as ProseMirrorNodeView } from '@tiptap/pm/view';
3
2
  import { Editor as CoreEditor } from './Editor.js';
4
- import { Node } from './Node.js';
5
- import { DecorationWithType, NodeViewRendererOptions, NodeViewRendererProps } from './types.js';
3
+ import { NodeViewRendererOptions, NodeViewRendererProps } from './types.js';
6
4
  /**
7
5
  * Node views are used to customize the rendered DOM structure of a node.
8
6
  * @see https://tiptap.dev/guide/node-views
@@ -11,10 +9,13 @@ export declare class NodeView<Component, NodeEditor extends CoreEditor = CoreEdi
11
9
  component: Component;
12
10
  editor: NodeEditor;
13
11
  options: Options;
14
- extension: Node;
15
- node: ProseMirrorNode;
16
- decorations: DecorationWithType[];
17
- getPos: any;
12
+ extension: NodeViewRendererProps['extension'];
13
+ node: NodeViewRendererProps['node'];
14
+ decorations: NodeViewRendererProps['decorations'];
15
+ innerDecorations: NodeViewRendererProps['innerDecorations'];
16
+ view: NodeViewRendererProps['view'];
17
+ getPos: NodeViewRendererProps['getPos'];
18
+ HTMLAttributes: NodeViewRendererProps['HTMLAttributes'];
18
19
  isDragging: boolean;
19
20
  constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
20
21
  mount(): void;
@@ -22,10 +23,21 @@ export declare class NodeView<Component, NodeEditor extends CoreEditor = CoreEdi
22
23
  get contentDOM(): HTMLElement | null;
23
24
  onDragStart(event: DragEvent): void;
24
25
  stopEvent(event: Event): boolean;
26
+ /**
27
+ * Called when a DOM [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) or a selection change happens within the view.
28
+ * @return `false` if the editor should re-read the selection or re-parse the range around the mutation
29
+ * @return `true` if it can safely be ignored.
30
+ */
25
31
  ignoreMutation(mutation: MutationRecord | {
26
32
  type: 'selection';
27
33
  target: Element;
28
34
  }): boolean;
29
- updateAttributes(attributes: {}): void;
35
+ /**
36
+ * Update the attributes of the prosemirror node.
37
+ */
38
+ updateAttributes(attributes: Record<string, any>): void;
39
+ /**
40
+ * Delete the node.
41
+ */
30
42
  deleteNode(): void;
31
43
  }
@@ -11,6 +11,8 @@ export * from './NodePos.js';
11
11
  export * from './NodeView.js';
12
12
  export * from './PasteRule.js';
13
13
  export * from './pasteRules/index.js';
14
+ export * from './plugins/DropPlugin.js';
15
+ export * from './plugins/PastePlugin.js';
14
16
  export * from './Tracker.js';
15
17
  export * from './types.js';
16
18
  export * from './utilities/index.js';
@@ -0,0 +1,3 @@
1
+ import { Plugin } from '@tiptap/pm/state';
2
+ import { Slice } from 'packages/pm/model';
3
+ export declare const DropPlugin: (onDrop: (e: DragEvent, slice: Slice, moved: boolean) => void) => Plugin<any>;
@@ -0,0 +1,3 @@
1
+ import { Slice } from '@tiptap/pm/model';
2
+ import { Plugin } from '@tiptap/pm/state';
3
+ export declare const PastePlugin: (onPaste: (e: ClipboardEvent, slice: Slice) => void) => Plugin<any>;
@@ -1,6 +1,6 @@
1
- import { Mark as ProseMirrorMark, Node as ProseMirrorNode, NodeType, ParseOptions } from '@tiptap/pm/model';
1
+ import { Mark as ProseMirrorMark, Node as ProseMirrorNode, NodeType, ParseOptions, Slice } from '@tiptap/pm/model';
2
2
  import { EditorState, Transaction } from '@tiptap/pm/state';
3
- import { Decoration, EditorProps, EditorView, NodeView } from '@tiptap/pm/view';
3
+ import { Decoration, EditorProps, EditorView, NodeView, NodeViewConstructor } from '@tiptap/pm/view';
4
4
  import { Editor } from './Editor.js';
5
5
  import { Extension } from './Extension.js';
6
6
  import { Commands, ExtensionConfig, MarkConfig, NodeConfig } from './index.js';
@@ -79,7 +79,24 @@ export interface EditorOptions {
79
79
  };
80
80
  enableInputRules: EnableRules;
81
81
  enablePasteRules: EnableRules;
82
- enableCoreExtensions: boolean;
82
+ /**
83
+ * Determines whether core extensions are enabled.
84
+ *
85
+ * If set to `false`, all core extensions will be disabled.
86
+ * To disable specific core extensions, provide an object where the keys are the extension names and the values are `false`.
87
+ * Extensions not listed in the object will remain enabled.
88
+ *
89
+ * @example
90
+ * // Disable all core extensions
91
+ * enabledCoreExtensions: false
92
+ *
93
+ * @example
94
+ * // Disable only the keymap core extension
95
+ * enabledCoreExtensions: { keymap: false }
96
+ *
97
+ * @default true
98
+ */
99
+ enableCoreExtensions?: boolean | Partial<Record<'editable' | 'clipboardTextSerializer' | 'commands' | 'focusEvents' | 'keymap' | 'tabindex', false>>;
83
100
  /**
84
101
  * If `true`, the editor will check the content for errors on initialization.
85
102
  * Emitting the `contentError` event if the content is invalid.
@@ -100,6 +117,8 @@ export interface EditorOptions {
100
117
  onFocus: (props: EditorEvents['focus']) => void;
101
118
  onBlur: (props: EditorEvents['blur']) => void;
102
119
  onDestroy: (props: EditorEvents['destroy']) => void;
120
+ onPaste: (e: ClipboardEvent, slice: Slice) => void;
121
+ onDrop: (e: DragEvent, slice: Slice, moved: boolean) => void;
103
122
  }
104
123
  export type HTMLContent = string;
105
124
  export type JSONContent = {
@@ -170,19 +189,18 @@ export type ValuesOf<T> = T[keyof T];
170
189
  export type KeysWithTypeOf<T, Type> = {
171
190
  [P in keyof T]: T[P] extends Type ? P : never;
172
191
  }[keyof T];
192
+ export type Simplify<T> = {
193
+ [KeyType in keyof T]: T[KeyType];
194
+ } & {};
173
195
  export type DecorationWithType = Decoration & {
174
196
  type: NodeType;
175
197
  };
176
- export type NodeViewProps = {
177
- editor: Editor;
178
- node: ProseMirrorNode;
179
- decorations: DecorationWithType[];
198
+ export type NodeViewProps = Simplify<Omit<NodeViewRendererProps, 'decorations'> & {
199
+ decorations: readonly DecorationWithType[];
180
200
  selected: boolean;
181
- extension: Node;
182
- getPos: () => number;
183
201
  updateAttributes: (attributes: Record<string, any>) => void;
184
202
  deleteNode: () => void;
185
- };
203
+ }>;
186
204
  export interface NodeViewRendererOptions {
187
205
  stopEvent: ((props: {
188
206
  event: Event;
@@ -196,14 +214,16 @@ export interface NodeViewRendererOptions {
196
214
  contentDOMElementTag: string;
197
215
  }
198
216
  export type NodeViewRendererProps = {
217
+ node: Parameters<NodeViewConstructor>[0];
218
+ view: Parameters<NodeViewConstructor>[1];
219
+ getPos: () => number;
220
+ decorations: Parameters<NodeViewConstructor>[3];
221
+ innerDecorations: Parameters<NodeViewConstructor>[4];
199
222
  editor: Editor;
200
- node: ProseMirrorNode;
201
- getPos: (() => number) | boolean;
202
- HTMLAttributes: Record<string, any>;
203
- decorations: Decoration[];
204
223
  extension: Node;
224
+ HTMLAttributes: Record<string, any>;
205
225
  };
206
- export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView | {};
226
+ export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView;
207
227
  export type AnyCommands = Record<string, (...args: any[]) => Command>;
208
228
  export type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, {}>>>>;
209
229
  export type RawCommands = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-table-cell",
3
3
  "description": "table cell extension for tiptap",
4
- "version": "2.6.5",
4
+ "version": "2.7.0-pre.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -29,10 +29,10 @@
29
29
  "dist"
30
30
  ],
31
31
  "devDependencies": {
32
- "@tiptap/core": "^2.6.5"
32
+ "@tiptap/core": "^2.7.0-pre.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@tiptap/core": "^2.6.5"
35
+ "@tiptap/core": "^2.7.0-pre.0"
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",