@tiptap/y-tiptap 1.0.0 → 2.0.0-beta.1

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/src/lib.d.ts CHANGED
@@ -101,13 +101,17 @@ export function yXmlFragmentToProseMirrorFragment(yXmlFragment: Y.XmlFragment, s
101
101
  export function yXmlFragmentToProseMirrorRootNode(yXmlFragment: Y.XmlFragment, schema: Schema): Node;
102
102
  export function initProseMirrorDoc(yXmlFragment: Y.XmlFragment, schema: Schema): {
103
103
  doc: Node;
104
- mapping: ProsemirrorMapping;
104
+ meta: {
105
+ mapping: Map<any, any>;
106
+ isOMark: Map<any, any>;
107
+ };
108
+ mapping: Map<any, any>;
105
109
  };
106
110
  /**
107
111
  * Either a node if type is YXmlElement or an Array of text nodes if YXmlText
108
112
  */
109
113
  export type ProsemirrorMapping = Map<Y.AbstractType<any>, Node | Array<Node>>;
110
- import { Node } from '@tiptap/pm/model';
114
+ import { Node } from 'prosemirror-model';
111
115
  import * as Y from 'yjs';
112
- import { Schema } from '@tiptap/pm/model';
113
- import { Fragment } from '@tiptap/pm/model';
116
+ import { Schema } from 'prosemirror-model';
117
+ import { Fragment } from 'prosemirror-model';
@@ -1,17 +1,17 @@
1
1
  export function defaultAwarenessStateFilter(currentClientId: number, userClientId: number, _user: any): boolean;
2
2
  export function defaultCursorBuilder(user: any): HTMLElement;
3
- export function defaultSelectionBuilder(user: any): import('@tiptap/pm/view').DecorationAttrs;
4
- export function createDecorations(state: any, awareness: Awareness, awarenessFilter: (arg0: number, arg1: number, arg2: any) => boolean, createCursor: (arg0: {
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
5
  name: string;
6
6
  color: string;
7
- }) => Element, createSelection: (arg0: {
7
+ }, clientId: number) => Element, createSelection: (user: {
8
8
  name: string;
9
9
  color: string;
10
- }) => import('@tiptap/pm/view').DecorationAttrs): any;
10
+ }, clientId: number) => import('prosemirror-view').DecorationAttrs): any;
11
11
  export function yCursorPlugin(awareness: Awareness, { awarenessStateFilter, cursorBuilder, selectionBuilder, getSelection }?: {
12
12
  awarenessStateFilter?: (arg0: any, arg1: any, arg2: any) => boolean;
13
- cursorBuilder?: (arg0: any) => HTMLElement;
14
- selectionBuilder?: (arg0: any) => import('@tiptap/pm/view').DecorationAttrs;
13
+ cursorBuilder?: (user: any, clientId: number) => HTMLElement;
14
+ selectionBuilder?: (user: any, clientId: number) => import('prosemirror-view').DecorationAttrs;
15
15
  getSelection?: (arg0: any) => any;
16
16
  }, cursorStateField?: string): any;
17
17
  import { Awareness } from "y-protocols/awareness";
@@ -1,7 +1,11 @@
1
- export const MarkPrefix: "_mark_";
1
+ export function createEmptyMeta(): {
2
+ mapping: Map<any, any>;
3
+ isOMark: Map<any, any>;
4
+ };
2
5
  export function isVisible(item: Y.Item, snapshot?: Y.Snapshot): boolean;
3
6
  export function ySyncPlugin(yXmlFragment: Y.XmlFragment, { colors, colorMapping, permanentUserData, onFirstRender, mapping }?: YSyncOpts): any;
4
- export function getRelativeSelection(pmbinding: any, state: any): {
7
+ export function getRelativeSelection(pmbinding: ProsemirrorBinding, state: import('prosemirror-state').EditorState): {
8
+ type: any;
5
9
  anchor: any;
6
10
  head: any;
7
11
  };
@@ -24,6 +28,12 @@ export class ProsemirrorBinding {
24
28
  prosemirrorView: any;
25
29
  mux: import("lib0/mutex").mutex;
26
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>;
27
37
  _observeFunction: any;
28
38
  /**
29
39
  * @type {Y.Doc}
@@ -33,6 +43,7 @@ export class ProsemirrorBinding {
33
43
  * current selection as relative positions in the Yjs model
34
44
  */
35
45
  beforeTransactionSelection: {
46
+ type: any;
36
47
  anchor: any;
37
48
  head: any;
38
49
  };
@@ -65,7 +76,10 @@ export class ProsemirrorBinding {
65
76
  * @param {Y.Transaction} transaction
66
77
  */
67
78
  _typeChanged(events: Array<Y.YEvent<any>>, transaction: Y.Transaction): void;
68
- _prosemirrorChanged(doc: any): void;
79
+ /**
80
+ * @param {import('prosemirror-model').Node} doc
81
+ */
82
+ _prosemirrorChanged(doc: import('prosemirror-model').Node): void;
69
83
  /**
70
84
  * View is ready to listen to changes. Register observers.
71
85
  * @param {any} prosemirrorView
@@ -73,10 +87,21 @@ export class ProsemirrorBinding {
73
87
  initView(prosemirrorView: any): void;
74
88
  destroy(): void;
75
89
  }
76
- export function createNodeFromYElement(el: Y.XmlElement, schema: any, mapping: ProsemirrorMapping, snapshot?: Y.Snapshot, prevSnapshot?: Y.Snapshot, computeYChange?: (arg0: 'removed' | 'added', arg1: Y.ID) => any): PModel.Node | null;
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[];
77
95
  export function updateYFragment(y: {
78
96
  transact: Function;
79
- }, yDomFragment: Y.XmlFragment, pNode: any, mapping: ProsemirrorMapping): void;
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
+ };
80
105
  /**
81
106
  * Either a node if type is YXmlElement or an Array of text nodes if YXmlText
82
107
  */
@@ -97,4 +122,4 @@ export type YSyncOpts = {
97
122
  };
98
123
  export type NormalizedPNodeContent = Array<Array<PModel.Node> | PModel.Node>;
99
124
  import * as Y from 'yjs';
100
- import * as PModel from '@tiptap/pm/model';
125
+ import * as PModel from 'prosemirror-model';
@@ -0,0 +1 @@
1
+ export function hashOfJSON(json: any): string;