@tiptap/y-tiptap 3.0.0-beta.1 → 3.0.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiptap/y-tiptap",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "Tiptap prosemirror bindings for Yjs",
5
5
  "main": "./dist/y-tiptap.cjs",
6
6
  "module": "./src/y-tiptap.js",
@@ -49,7 +49,9 @@
49
49
  "lib0": "^0.2.100"
50
50
  },
51
51
  "peerDependencies": {
52
- "@tiptap/pm": "3.0.0-beta.3",
52
+ "prosemirror-model": "^1.7.1",
53
+ "prosemirror-state": "^1.2.3",
54
+ "prosemirror-view": "^1.9.10",
53
55
  "y-protocols": "^1.0.1",
54
56
  "yjs": "^13.5.38"
55
57
  },
@@ -60,7 +62,11 @@
60
62
  "http-server": "^0.12.3",
61
63
  "jsdom": "^15.1.1",
62
64
  "prosemirror-example-setup": "^1.2.1",
63
- "@tiptap/pm": "3.0.0-beta.3",
65
+ "prosemirror-model": "^1.18.1",
66
+ "prosemirror-schema-basic": "^1.2.0",
67
+ "prosemirror-state": "^1.4.1",
68
+ "prosemirror-transform": "^1.6.0",
69
+ "prosemirror-view": "^1.26.2",
64
70
  "rollup": "^2.59.0",
65
71
  "standard": "^17.0.0",
66
72
  "typescript": "^5.4.5",
package/dist/src/lib.d.ts DELETED
@@ -1,117 +0,0 @@
1
- /**
2
- * Utility method to convert a Prosemirror Doc Node into a Y.Doc.
3
- *
4
- * This can be used when importing existing content to Y.Doc for the first time,
5
- * note that this should not be used to rehydrate a Y.Doc from a database once
6
- * collaboration has begun as all history will be lost
7
- *
8
- * @param {Node} doc
9
- * @param {string} xmlFragment
10
- * @return {Y.Doc}
11
- */
12
- export function prosemirrorToYDoc(doc: Node, xmlFragment?: string): Y.Doc;
13
- /**
14
- * Utility method to update an empty Y.XmlFragment with content from a Prosemirror Doc Node.
15
- *
16
- * This can be used when importing existing content to Y.Doc for the first time,
17
- * note that this should not be used to rehydrate a Y.Doc from a database once
18
- * collaboration has begun as all history will be lost
19
- *
20
- * Note: The Y.XmlFragment does not need to be part of a Y.Doc document at the time that this
21
- * method is called, but it must be added before any other operations are performed on it.
22
- *
23
- * @param {Node} doc prosemirror document.
24
- * @param {Y.XmlFragment} [xmlFragment] If supplied, an xml fragment to be
25
- * populated from the prosemirror state; otherwise a new XmlFragment will be created.
26
- * @return {Y.XmlFragment}
27
- */
28
- export function prosemirrorToYXmlFragment(doc: Node, xmlFragment?: Y.XmlFragment): Y.XmlFragment;
29
- /**
30
- * Utility method to convert Prosemirror compatible JSON into a Y.Doc.
31
- *
32
- * This can be used when importing existing content to Y.Doc for the first time,
33
- * note that this should not be used to rehydrate a Y.Doc from a database once
34
- * collaboration has begun as all history will be lost
35
- *
36
- * @param {Schema} schema
37
- * @param {any} state
38
- * @param {string} xmlFragment
39
- * @return {Y.Doc}
40
- */
41
- export function prosemirrorJSONToYDoc(schema: Schema, state: any, xmlFragment?: string): Y.Doc;
42
- /**
43
- * Utility method to convert Prosemirror compatible JSON to a Y.XmlFragment
44
- *
45
- * This can be used when importing existing content to Y.Doc for the first time,
46
- * note that this should not be used to rehydrate a Y.Doc from a database once
47
- * collaboration has begun as all history will be lost
48
- *
49
- * @param {Schema} schema
50
- * @param {any} state
51
- * @param {Y.XmlFragment} [xmlFragment] If supplied, an xml fragment to be
52
- * populated from the prosemirror state; otherwise a new XmlFragment will be created.
53
- * @return {Y.XmlFragment}
54
- */
55
- export function prosemirrorJSONToYXmlFragment(schema: Schema, state: any, xmlFragment?: Y.XmlFragment): Y.XmlFragment;
56
- /**
57
- * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead
58
- *
59
- * Utility method to convert a Y.Doc to a Prosemirror Doc node.
60
- *
61
- * @param {Schema} schema
62
- * @param {Y.Doc} ydoc
63
- * @return {Node}
64
- */
65
- export function yDocToProsemirror(schema: Schema, ydoc: Y.Doc): Node;
66
- /**
67
- *
68
- * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead
69
- *
70
- * Utility method to convert a Y.XmlFragment to a Prosemirror Doc node.
71
- *
72
- * @param {Schema} schema
73
- * @param {Y.XmlFragment} xmlFragment
74
- * @return {Node}
75
- */
76
- export function yXmlFragmentToProsemirror(schema: Schema, xmlFragment: Y.XmlFragment): Node;
77
- /**
78
- *
79
- * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead
80
- *
81
- * Utility method to convert a Y.Doc to Prosemirror compatible JSON.
82
- *
83
- * @param {Y.Doc} ydoc
84
- * @param {string} xmlFragment
85
- * @return {Record<string, any>}
86
- */
87
- export function yDocToProsemirrorJSON(ydoc: Y.Doc, xmlFragment?: string): Record<string, any>;
88
- /**
89
- * @deprecated Use `yXmlFragmentToProseMirrorRootNode` instead
90
- *
91
- * Utility method to convert a Y.Doc to Prosemirror compatible JSON.
92
- *
93
- * @param {Y.XmlFragment} xmlFragment The fragment, which must be part of a Y.Doc.
94
- * @return {Record<string, any>}
95
- */
96
- export function yXmlFragmentToProsemirrorJSON(xmlFragment: Y.XmlFragment): Record<string, any>;
97
- export function setMeta(view: any, key: any, value: any): void;
98
- export function absolutePositionToRelativePosition(pos: number, type: Y.XmlFragment, mapping: ProsemirrorMapping): any;
99
- export function relativePositionToAbsolutePosition(y: Y.Doc, documentType: Y.XmlFragment, relPos: any, mapping: ProsemirrorMapping): null | number;
100
- export function yXmlFragmentToProseMirrorFragment(yXmlFragment: Y.XmlFragment, schema: Schema): Fragment;
101
- export function yXmlFragmentToProseMirrorRootNode(yXmlFragment: Y.XmlFragment, schema: Schema): Node;
102
- export function initProseMirrorDoc(yXmlFragment: Y.XmlFragment, schema: Schema): {
103
- doc: Node;
104
- meta: {
105
- mapping: Map<any, any>;
106
- isOMark: Map<any, any>;
107
- };
108
- mapping: Map<any, any>;
109
- };
110
- /**
111
- * Either a node if type is YXmlElement or an Array of text nodes if YXmlText
112
- */
113
- export type ProsemirrorMapping = Map<Y.AbstractType<any>, Node | Array<Node>>;
114
- import { Node } from 'prosemirror-model';
115
- import * as Y from 'yjs';
116
- import { Schema } from 'prosemirror-model';
117
- import { Fragment } from 'prosemirror-model';
@@ -1,17 +0,0 @@
1
- export function defaultAwarenessStateFilter(currentClientId: number, userClientId: number, _user: any): boolean;
2
- export function defaultCursorBuilder(user: any): HTMLElement;
3
- export function defaultSelectionBuilder(user: any): import('prosemirror-view').DecorationAttrs;
4
- export function createDecorations(state: any, awareness: Awareness, awarenessFilter: (arg0: number, arg1: number, arg2: any) => boolean, createCursor: (user: {
5
- name: string;
6
- color: string;
7
- }, clientId: number) => Element, createSelection: (user: {
8
- name: string;
9
- color: string;
10
- }, clientId: number) => import('prosemirror-view').DecorationAttrs): any;
11
- export function yCursorPlugin(awareness: Awareness, { awarenessStateFilter, cursorBuilder, selectionBuilder, getSelection }?: {
12
- awarenessStateFilter?: (arg0: any, arg1: any, arg2: any) => boolean;
13
- cursorBuilder?: (user: any, clientId: number) => HTMLElement;
14
- selectionBuilder?: (user: any, clientId: number) => import('prosemirror-view').DecorationAttrs;
15
- getSelection?: (arg0: any) => any;
16
- }, cursorStateField?: string): any;
17
- import { Awareness } from "y-protocols/awareness";
@@ -1,19 +0,0 @@
1
- /**
2
- * The unique prosemirror plugin key for syncPlugin
3
- *
4
- * @public
5
- */
6
- export const ySyncPluginKey: PluginKey<any>;
7
- /**
8
- * The unique prosemirror plugin key for undoPlugin
9
- *
10
- * @public
11
- */
12
- export const yUndoPluginKey: PluginKey<any>;
13
- /**
14
- * The unique prosemirror plugin key for cursorPlugin
15
- *
16
- * @public
17
- */
18
- export const yCursorPluginKey: PluginKey<any>;
19
- import { PluginKey } from '@tiptap/pm/state';
@@ -1,125 +0,0 @@
1
- export function createEmptyMeta(): {
2
- mapping: Map<any, any>;
3
- isOMark: Map<any, any>;
4
- };
5
- export function isVisible(item: Y.Item, snapshot?: Y.Snapshot): boolean;
6
- export function ySyncPlugin(yXmlFragment: Y.XmlFragment, { colors, colorMapping, permanentUserData, onFirstRender, mapping }?: YSyncOpts): any;
7
- export function getRelativeSelection(pmbinding: ProsemirrorBinding, state: import('prosemirror-state').EditorState): {
8
- type: any;
9
- anchor: any;
10
- head: any;
11
- };
12
- /**
13
- * Binding for prosemirror.
14
- *
15
- * @protected
16
- */
17
- export class ProsemirrorBinding {
18
- /**
19
- * @param {Y.XmlFragment} yXmlFragment The bind source
20
- * @param {ProsemirrorMapping} mapping
21
- */
22
- constructor(yXmlFragment: Y.XmlFragment, mapping?: ProsemirrorMapping);
23
- type: Y.XmlFragment;
24
- /**
25
- * this will be set once the view is created
26
- * @type {any}
27
- */
28
- prosemirrorView: any;
29
- mux: import("lib0/mutex").mutex;
30
- mapping: ProsemirrorMapping;
31
- /**
32
- * Is overlapping mark - i.e. mark does not exclude itself.
33
- *
34
- * @type {Map<import('prosemirror-model').MarkType, boolean>}
35
- */
36
- isOMark: Map<import('prosemirror-model').MarkType, boolean>;
37
- _observeFunction: any;
38
- /**
39
- * @type {Y.Doc}
40
- */
41
- doc: Y.Doc;
42
- /**
43
- * current selection as relative positions in the Yjs model
44
- */
45
- beforeTransactionSelection: {
46
- type: any;
47
- anchor: any;
48
- head: any;
49
- };
50
- beforeAllTransactions: () => void;
51
- afterAllTransactions: () => void;
52
- _domSelectionInView: boolean;
53
- /**
54
- * Create a transaction for changing the prosemirror state.
55
- *
56
- * @returns
57
- */
58
- get _tr(): any;
59
- _isLocalCursorInView(): boolean;
60
- _isDomSelectionInView(): boolean;
61
- /**
62
- * @param {Y.Snapshot} snapshot
63
- * @param {Y.Snapshot} prevSnapshot
64
- */
65
- renderSnapshot(snapshot: Y.Snapshot, prevSnapshot: Y.Snapshot): void;
66
- unrenderSnapshot(): void;
67
- _forceRerender(): void;
68
- /**
69
- * @param {Y.Snapshot|Uint8Array} snapshot
70
- * @param {Y.Snapshot|Uint8Array} prevSnapshot
71
- * @param {Object} pluginState
72
- */
73
- _renderSnapshot(snapshot: Y.Snapshot | Uint8Array, prevSnapshot: Y.Snapshot | Uint8Array, pluginState: any): void;
74
- /**
75
- * @param {Array<Y.YEvent<any>>} events
76
- * @param {Y.Transaction} transaction
77
- */
78
- _typeChanged(events: Array<Y.YEvent<any>>, transaction: Y.Transaction): void;
79
- /**
80
- * @param {import('prosemirror-model').Node} doc
81
- */
82
- _prosemirrorChanged(doc: import('prosemirror-model').Node): void;
83
- /**
84
- * View is ready to listen to changes. Register observers.
85
- * @param {any} prosemirrorView
86
- */
87
- initView(prosemirrorView: any): void;
88
- destroy(): void;
89
- }
90
- export function createNodeFromYElement(el: Y.XmlElement, schema: any, meta: BindingMetadata, snapshot?: Y.Snapshot, prevSnapshot?: Y.Snapshot, computeYChange?: (arg0: 'removed' | 'added', arg1: Y.ID) => any): PModel.Node | null;
91
- export function yattr2markname(attrName: string): string;
92
- export function attributesToMarks(attrs: {
93
- [x: string]: any;
94
- }, schema: import('prosemirror-model').Schema): PModel.Mark[];
95
- export function updateYFragment(y: {
96
- transact: Function;
97
- }, yDomFragment: Y.XmlFragment, pNode: any, meta: BindingMetadata): void;
98
- export type BindingMetadata = {
99
- mapping: ProsemirrorMapping;
100
- /**
101
- * - is overlapping mark
102
- */
103
- isOMark: Map<import('prosemirror-model').MarkType, boolean>;
104
- };
105
- /**
106
- * Either a node if type is YXmlElement or an Array of text nodes if YXmlText
107
- */
108
- export type ProsemirrorMapping = Map<Y.AbstractType<any>, PModel.Node | Array<PModel.Node>>;
109
- export type ColorDef = {
110
- light: string;
111
- dark: string;
112
- };
113
- export type YSyncOpts = {
114
- colors?: Array<ColorDef>;
115
- colorMapping?: Map<string, ColorDef>;
116
- permanentUserData?: Y.PermanentUserData | null;
117
- mapping?: ProsemirrorMapping;
118
- /**
119
- * Fired when the content from Yjs is initially rendered to ProseMirror
120
- */
121
- onFirstRender?: Function;
122
- };
123
- export type NormalizedPNodeContent = Array<Array<PModel.Node> | PModel.Node>;
124
- import * as Y from 'yjs';
125
- import * as PModel from 'prosemirror-model';
@@ -1,15 +0,0 @@
1
- export function undo(state: any): boolean;
2
- export function redo(state: any): boolean;
3
- export const defaultProtectedNodes: Set<string>;
4
- export function defaultDeleteFilter(item: any, protectedNodes: any): boolean;
5
- export function yUndoPlugin({ protectedNodes, trackedOrigins, undoManager }?: {
6
- protectedNodes?: Set<string>;
7
- trackedOrigins?: any[];
8
- undoManager?: any;
9
- }): Plugin<{
10
- undoManager: any;
11
- prevSel: any;
12
- hasUndoOps: boolean;
13
- hasRedoOps: boolean;
14
- }>;
15
- import { Plugin } from '@tiptap/pm/state';
@@ -1 +0,0 @@
1
- export function hashOfJSON(json: any): string;
@@ -1,5 +0,0 @@
1
- export * from "./plugins/cursor-plugin.js";
2
- export * from "./plugins/undo-plugin.js";
3
- export * from "./plugins/keys.js";
4
- export { ySyncPlugin, isVisible, getRelativeSelection, ProsemirrorBinding, updateYFragment } from "./plugins/sync-plugin.js";
5
- export { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, setMeta, prosemirrorJSONToYDoc, yDocToProsemirrorJSON, yDocToProsemirror, prosemirrorToYDoc, prosemirrorJSONToYXmlFragment, yXmlFragmentToProsemirrorJSON, yXmlFragmentToProsemirror, prosemirrorToYXmlFragment, yXmlFragmentToProseMirrorRootNode, yXmlFragmentToProseMirrorFragment, initProseMirrorDoc } from "./lib.js";