@tiptap/extension-collaboration-caret 3.11.1 → 3.12.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/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/collaboration-caret.ts +1 -4
package/dist/index.cjs
CHANGED
|
@@ -80,8 +80,7 @@ var CollaborationCaret = import_core.Extension.create({
|
|
|
80
80
|
addCommands() {
|
|
81
81
|
return {
|
|
82
82
|
updateUser: (attributes) => () => {
|
|
83
|
-
this.options.user
|
|
84
|
-
this.options.provider.awareness.setLocalStateField("user", this.options.user);
|
|
83
|
+
this.options.provider.awareness.setLocalStateField("user", attributes);
|
|
85
84
|
return true;
|
|
86
85
|
},
|
|
87
86
|
user: (attributes) => ({ editor }) => {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/collaboration-caret.ts"],"sourcesContent":["import { CollaborationCaret } from './collaboration-caret.js'\n\nexport * from './collaboration-caret.js'\n\nexport default CollaborationCaret\n","import { Extension } from '@tiptap/core'\nimport type { DecorationAttrs } from '@tiptap/pm/view'\nimport { defaultSelectionBuilder, yCursorPlugin } from '@tiptap/y-tiptap'\n\ntype CollaborationCaretStorage = {\n users: { clientId: number; [key: string]: any }[]\n}\n\nexport interface CollaborationCaretOptions {\n /**\n * The Hocuspocus provider instance. This can also be a TiptapCloudProvider instance.\n * @type {HocuspocusProvider | TiptapCloudProvider}\n * @example new HocuspocusProvider()\n */\n provider: any\n\n /**\n * The user details object – feel free to add properties to this object as needed\n * @example { name: 'John Doe', color: '#305500' }\n */\n user: Record<string, any>\n\n /**\n * A function that returns a DOM element for the cursor.\n * @param user The user details object\n * @example\n * render: user => {\n * const cursor = document.createElement('span')\n * cursor.classList.add('collaboration-carets__caret')\n * cursor.setAttribute('style', `border-color: ${user.color}`)\n *\n * const label = document.createElement('div')\n * label.classList.add('collaboration-carets__label')\n * label.setAttribute('style', `background-color: ${user.color}`)\n * label.insertBefore(document.createTextNode(user.name), null)\n *\n * cursor.insertBefore(label, null)\n * return cursor\n * }\n */\n render(user: Record<string, any>): HTMLElement\n\n /**\n * A function that returns a ProseMirror DecorationAttrs object for the selection.\n * @param user The user details object\n * @example\n * selectionRender: user => {\n * return {\n * nodeName: 'span',\n * class: 'collaboration-carets__selection',\n * style: `background-color: ${user.color}`,\n * 'data-user': user.name,\n * }\n */\n selectionRender(user: Record<string, any>): DecorationAttrs\n\n /**\n * @deprecated The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n onUpdate: (users: { clientId: number; [key: string]: any }[]) => null\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n collaborationCaret: {\n /**\n * Update details of the current user\n * @example editor.commands.updateUser({ name: 'John Doe', color: '#305500' })\n */\n updateUser: (attributes: Record<string, any>) => ReturnType\n /**\n * Update details of the current user\n *\n * @deprecated The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n user: (attributes: Record<string, any>) => ReturnType\n }\n }\n\n interface Storage {\n collaborationCaret: CollaborationCaretStorage\n }\n}\n\nconst awarenessStatesToArray = (states: Map<number, Record<string, any>>) => {\n return Array.from(states.entries()).map(([key, value]) => {\n return {\n clientId: key,\n ...value.user,\n }\n })\n}\n\nconst defaultOnUpdate = () => null\n\n/**\n * This extension allows you to add collaboration carets to your editor.\n * @see https://tiptap.dev/api/extensions/collaboration-caret\n */\nexport const CollaborationCaret = Extension.create<CollaborationCaretOptions, CollaborationCaretStorage>({\n name: 'collaborationCaret',\n\n priority: 999,\n\n addOptions() {\n return {\n provider: null,\n user: {\n name: null,\n color: null,\n },\n render: user => {\n const cursor = document.createElement('span')\n\n cursor.classList.add('collaboration-carets__caret')\n cursor.setAttribute('style', `border-color: ${user.color}`)\n\n const label = document.createElement('div')\n\n label.classList.add('collaboration-carets__label')\n label.setAttribute('style', `background-color: ${user.color}`)\n label.insertBefore(document.createTextNode(user.name), null)\n cursor.insertBefore(label, null)\n\n return cursor\n },\n selectionRender: defaultSelectionBuilder,\n onUpdate: defaultOnUpdate,\n }\n },\n\n onCreate() {\n if (this.options.onUpdate !== defaultOnUpdate) {\n console.warn(\n '[tiptap warn]: DEPRECATED: The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret',\n )\n }\n if (!this.options.provider) {\n throw new Error('The \"provider\" option is required for the CollaborationCaret extension')\n }\n },\n\n addStorage() {\n return {\n users: [],\n }\n },\n\n addCommands() {\n return {\n updateUser: attributes => () => {\n this.options.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/collaboration-caret.ts"],"sourcesContent":["import { CollaborationCaret } from './collaboration-caret.js'\n\nexport * from './collaboration-caret.js'\n\nexport default CollaborationCaret\n","import { Extension } from '@tiptap/core'\nimport type { DecorationAttrs } from '@tiptap/pm/view'\nimport { defaultSelectionBuilder, yCursorPlugin } from '@tiptap/y-tiptap'\n\ntype CollaborationCaretStorage = {\n users: { clientId: number; [key: string]: any }[]\n}\n\nexport interface CollaborationCaretOptions {\n /**\n * The Hocuspocus provider instance. This can also be a TiptapCloudProvider instance.\n * @type {HocuspocusProvider | TiptapCloudProvider}\n * @example new HocuspocusProvider()\n */\n provider: any\n\n /**\n * The user details object – feel free to add properties to this object as needed\n * @example { name: 'John Doe', color: '#305500' }\n */\n user: Record<string, any>\n\n /**\n * A function that returns a DOM element for the cursor.\n * @param user The user details object\n * @example\n * render: user => {\n * const cursor = document.createElement('span')\n * cursor.classList.add('collaboration-carets__caret')\n * cursor.setAttribute('style', `border-color: ${user.color}`)\n *\n * const label = document.createElement('div')\n * label.classList.add('collaboration-carets__label')\n * label.setAttribute('style', `background-color: ${user.color}`)\n * label.insertBefore(document.createTextNode(user.name), null)\n *\n * cursor.insertBefore(label, null)\n * return cursor\n * }\n */\n render(user: Record<string, any>): HTMLElement\n\n /**\n * A function that returns a ProseMirror DecorationAttrs object for the selection.\n * @param user The user details object\n * @example\n * selectionRender: user => {\n * return {\n * nodeName: 'span',\n * class: 'collaboration-carets__selection',\n * style: `background-color: ${user.color}`,\n * 'data-user': user.name,\n * }\n */\n selectionRender(user: Record<string, any>): DecorationAttrs\n\n /**\n * @deprecated The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n onUpdate: (users: { clientId: number; [key: string]: any }[]) => null\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n collaborationCaret: {\n /**\n * Update details of the current user\n * @example editor.commands.updateUser({ name: 'John Doe', color: '#305500' })\n */\n updateUser: (attributes: Record<string, any>) => ReturnType\n /**\n * Update details of the current user\n *\n * @deprecated The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n user: (attributes: Record<string, any>) => ReturnType\n }\n }\n\n interface Storage {\n collaborationCaret: CollaborationCaretStorage\n }\n}\n\nconst awarenessStatesToArray = (states: Map<number, Record<string, any>>) => {\n return Array.from(states.entries()).map(([key, value]) => {\n return {\n clientId: key,\n ...value.user,\n }\n })\n}\n\nconst defaultOnUpdate = () => null\n\n/**\n * This extension allows you to add collaboration carets to your editor.\n * @see https://tiptap.dev/api/extensions/collaboration-caret\n */\nexport const CollaborationCaret = Extension.create<CollaborationCaretOptions, CollaborationCaretStorage>({\n name: 'collaborationCaret',\n\n priority: 999,\n\n addOptions() {\n return {\n provider: null,\n user: {\n name: null,\n color: null,\n },\n render: user => {\n const cursor = document.createElement('span')\n\n cursor.classList.add('collaboration-carets__caret')\n cursor.setAttribute('style', `border-color: ${user.color}`)\n\n const label = document.createElement('div')\n\n label.classList.add('collaboration-carets__label')\n label.setAttribute('style', `background-color: ${user.color}`)\n label.insertBefore(document.createTextNode(user.name), null)\n cursor.insertBefore(label, null)\n\n return cursor\n },\n selectionRender: defaultSelectionBuilder,\n onUpdate: defaultOnUpdate,\n }\n },\n\n onCreate() {\n if (this.options.onUpdate !== defaultOnUpdate) {\n console.warn(\n '[tiptap warn]: DEPRECATED: The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret',\n )\n }\n if (!this.options.provider) {\n throw new Error('The \"provider\" option is required for the CollaborationCaret extension')\n }\n },\n\n addStorage() {\n return {\n users: [],\n }\n },\n\n addCommands() {\n return {\n updateUser: attributes => () => {\n this.options.provider.awareness.setLocalStateField('user', attributes)\n return true\n },\n user:\n attributes =>\n ({ editor }) => {\n console.warn(\n '[tiptap warn]: DEPRECATED: The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret',\n )\n\n return editor.commands.updateUser(attributes)\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [\n yCursorPlugin(\n (() => {\n this.options.provider.awareness.setLocalStateField('user', this.options.user)\n\n this.storage.users = awarenessStatesToArray(this.options.provider.awareness.states)\n\n this.options.provider.awareness.on('update', () => {\n this.storage.users = awarenessStatesToArray(this.options.provider.awareness.states)\n })\n\n return this.options.provider.awareness\n })(),\n {\n cursorBuilder: this.options.render,\n selectionBuilder: this.options.selectionRender,\n },\n ),\n ]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA0B;AAE1B,sBAAuD;AAkFvD,IAAM,yBAAyB,CAAC,WAA6C;AAC3E,SAAO,MAAM,KAAK,OAAO,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACxD,WAAO;AAAA,MACL,UAAU;AAAA,MACV,GAAG,MAAM;AAAA,IACX;AAAA,EACF,CAAC;AACH;AAEA,IAAM,kBAAkB,M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,SACG,MAAM;AACL,eAAK,QAAQ,SAAS,UAAU,mBAAmB,QAAQ,KAAK,QAAQ,IAAI;AAE5E,eAAK,QAAQ,QAAQ,uBAAuB,KAAK,QAAQ,SAAS,UAAU,MAAM;AAElF,eAAK,QAAQ,SAAS,UAAU,GAAG,UAAU,MAAM;AACjD,iBAAK,QAAQ,QAAQ,uBAAuB,KAAK,QAAQ,SAAS,UAAU,MAAM;AAAA,UACpF,CAAC;AAED,iBAAO,KAAK,QAAQ,SAAS;AAAA,QAC/B,GAAG;AAAA,QACH;AAAA,UACE,eAAe,KAAK,QAAQ;AAAA,UAC5B,kBAAkB,KAAK,QAAQ;AAAA,QACjC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ADvLD,IAAO,gBAAQ;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -53,8 +53,7 @@ var CollaborationCaret = Extension.create({
|
|
|
53
53
|
addCommands() {
|
|
54
54
|
return {
|
|
55
55
|
updateUser: (attributes) => () => {
|
|
56
|
-
this.options.user
|
|
57
|
-
this.options.provider.awareness.setLocalStateField("user", this.options.user);
|
|
56
|
+
this.options.provider.awareness.setLocalStateField("user", attributes);
|
|
58
57
|
return true;
|
|
59
58
|
},
|
|
60
59
|
user: (attributes) => ({ editor }) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/collaboration-caret.ts","../src/index.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport type { DecorationAttrs } from '@tiptap/pm/view'\nimport { defaultSelectionBuilder, yCursorPlugin } from '@tiptap/y-tiptap'\n\ntype CollaborationCaretStorage = {\n users: { clientId: number; [key: string]: any }[]\n}\n\nexport interface CollaborationCaretOptions {\n /**\n * The Hocuspocus provider instance. This can also be a TiptapCloudProvider instance.\n * @type {HocuspocusProvider | TiptapCloudProvider}\n * @example new HocuspocusProvider()\n */\n provider: any\n\n /**\n * The user details object – feel free to add properties to this object as needed\n * @example { name: 'John Doe', color: '#305500' }\n */\n user: Record<string, any>\n\n /**\n * A function that returns a DOM element for the cursor.\n * @param user The user details object\n * @example\n * render: user => {\n * const cursor = document.createElement('span')\n * cursor.classList.add('collaboration-carets__caret')\n * cursor.setAttribute('style', `border-color: ${user.color}`)\n *\n * const label = document.createElement('div')\n * label.classList.add('collaboration-carets__label')\n * label.setAttribute('style', `background-color: ${user.color}`)\n * label.insertBefore(document.createTextNode(user.name), null)\n *\n * cursor.insertBefore(label, null)\n * return cursor\n * }\n */\n render(user: Record<string, any>): HTMLElement\n\n /**\n * A function that returns a ProseMirror DecorationAttrs object for the selection.\n * @param user The user details object\n * @example\n * selectionRender: user => {\n * return {\n * nodeName: 'span',\n * class: 'collaboration-carets__selection',\n * style: `background-color: ${user.color}`,\n * 'data-user': user.name,\n * }\n */\n selectionRender(user: Record<string, any>): DecorationAttrs\n\n /**\n * @deprecated The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n onUpdate: (users: { clientId: number; [key: string]: any }[]) => null\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n collaborationCaret: {\n /**\n * Update details of the current user\n * @example editor.commands.updateUser({ name: 'John Doe', color: '#305500' })\n */\n updateUser: (attributes: Record<string, any>) => ReturnType\n /**\n * Update details of the current user\n *\n * @deprecated The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n user: (attributes: Record<string, any>) => ReturnType\n }\n }\n\n interface Storage {\n collaborationCaret: CollaborationCaretStorage\n }\n}\n\nconst awarenessStatesToArray = (states: Map<number, Record<string, any>>) => {\n return Array.from(states.entries()).map(([key, value]) => {\n return {\n clientId: key,\n ...value.user,\n }\n })\n}\n\nconst defaultOnUpdate = () => null\n\n/**\n * This extension allows you to add collaboration carets to your editor.\n * @see https://tiptap.dev/api/extensions/collaboration-caret\n */\nexport const CollaborationCaret = Extension.create<CollaborationCaretOptions, CollaborationCaretStorage>({\n name: 'collaborationCaret',\n\n priority: 999,\n\n addOptions() {\n return {\n provider: null,\n user: {\n name: null,\n color: null,\n },\n render: user => {\n const cursor = document.createElement('span')\n\n cursor.classList.add('collaboration-carets__caret')\n cursor.setAttribute('style', `border-color: ${user.color}`)\n\n const label = document.createElement('div')\n\n label.classList.add('collaboration-carets__label')\n label.setAttribute('style', `background-color: ${user.color}`)\n label.insertBefore(document.createTextNode(user.name), null)\n cursor.insertBefore(label, null)\n\n return cursor\n },\n selectionRender: defaultSelectionBuilder,\n onUpdate: defaultOnUpdate,\n }\n },\n\n onCreate() {\n if (this.options.onUpdate !== defaultOnUpdate) {\n console.warn(\n '[tiptap warn]: DEPRECATED: The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret',\n )\n }\n if (!this.options.provider) {\n throw new Error('The \"provider\" option is required for the CollaborationCaret extension')\n }\n },\n\n addStorage() {\n return {\n users: [],\n }\n },\n\n addCommands() {\n return {\n updateUser: attributes => () => {\n this.options.
|
|
1
|
+
{"version":3,"sources":["../src/collaboration-caret.ts","../src/index.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport type { DecorationAttrs } from '@tiptap/pm/view'\nimport { defaultSelectionBuilder, yCursorPlugin } from '@tiptap/y-tiptap'\n\ntype CollaborationCaretStorage = {\n users: { clientId: number; [key: string]: any }[]\n}\n\nexport interface CollaborationCaretOptions {\n /**\n * The Hocuspocus provider instance. This can also be a TiptapCloudProvider instance.\n * @type {HocuspocusProvider | TiptapCloudProvider}\n * @example new HocuspocusProvider()\n */\n provider: any\n\n /**\n * The user details object – feel free to add properties to this object as needed\n * @example { name: 'John Doe', color: '#305500' }\n */\n user: Record<string, any>\n\n /**\n * A function that returns a DOM element for the cursor.\n * @param user The user details object\n * @example\n * render: user => {\n * const cursor = document.createElement('span')\n * cursor.classList.add('collaboration-carets__caret')\n * cursor.setAttribute('style', `border-color: ${user.color}`)\n *\n * const label = document.createElement('div')\n * label.classList.add('collaboration-carets__label')\n * label.setAttribute('style', `background-color: ${user.color}`)\n * label.insertBefore(document.createTextNode(user.name), null)\n *\n * cursor.insertBefore(label, null)\n * return cursor\n * }\n */\n render(user: Record<string, any>): HTMLElement\n\n /**\n * A function that returns a ProseMirror DecorationAttrs object for the selection.\n * @param user The user details object\n * @example\n * selectionRender: user => {\n * return {\n * nodeName: 'span',\n * class: 'collaboration-carets__selection',\n * style: `background-color: ${user.color}`,\n * 'data-user': user.name,\n * }\n */\n selectionRender(user: Record<string, any>): DecorationAttrs\n\n /**\n * @deprecated The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n onUpdate: (users: { clientId: number; [key: string]: any }[]) => null\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n collaborationCaret: {\n /**\n * Update details of the current user\n * @example editor.commands.updateUser({ name: 'John Doe', color: '#305500' })\n */\n updateUser: (attributes: Record<string, any>) => ReturnType\n /**\n * Update details of the current user\n *\n * @deprecated The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret\n */\n user: (attributes: Record<string, any>) => ReturnType\n }\n }\n\n interface Storage {\n collaborationCaret: CollaborationCaretStorage\n }\n}\n\nconst awarenessStatesToArray = (states: Map<number, Record<string, any>>) => {\n return Array.from(states.entries()).map(([key, value]) => {\n return {\n clientId: key,\n ...value.user,\n }\n })\n}\n\nconst defaultOnUpdate = () => null\n\n/**\n * This extension allows you to add collaboration carets to your editor.\n * @see https://tiptap.dev/api/extensions/collaboration-caret\n */\nexport const CollaborationCaret = Extension.create<CollaborationCaretOptions, CollaborationCaretStorage>({\n name: 'collaborationCaret',\n\n priority: 999,\n\n addOptions() {\n return {\n provider: null,\n user: {\n name: null,\n color: null,\n },\n render: user => {\n const cursor = document.createElement('span')\n\n cursor.classList.add('collaboration-carets__caret')\n cursor.setAttribute('style', `border-color: ${user.color}`)\n\n const label = document.createElement('div')\n\n label.classList.add('collaboration-carets__label')\n label.setAttribute('style', `background-color: ${user.color}`)\n label.insertBefore(document.createTextNode(user.name), null)\n cursor.insertBefore(label, null)\n\n return cursor\n },\n selectionRender: defaultSelectionBuilder,\n onUpdate: defaultOnUpdate,\n }\n },\n\n onCreate() {\n if (this.options.onUpdate !== defaultOnUpdate) {\n console.warn(\n '[tiptap warn]: DEPRECATED: The \"onUpdate\" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret',\n )\n }\n if (!this.options.provider) {\n throw new Error('The \"provider\" option is required for the CollaborationCaret extension')\n }\n },\n\n addStorage() {\n return {\n users: [],\n }\n },\n\n addCommands() {\n return {\n updateUser: attributes => () => {\n this.options.provider.awareness.setLocalStateField('user', attributes)\n return true\n },\n user:\n attributes =>\n ({ editor }) => {\n console.warn(\n '[tiptap warn]: DEPRECATED: The \"user\" command is deprecated. Please use \"updateUser\" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret',\n )\n\n return editor.commands.updateUser(attributes)\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [\n yCursorPlugin(\n (() => {\n this.options.provider.awareness.setLocalStateField('user', this.options.user)\n\n this.storage.users = awarenessStatesToArray(this.options.provider.awareness.states)\n\n this.options.provider.awareness.on('update', () => {\n this.storage.users = awarenessStatesToArray(this.options.provider.awareness.states)\n })\n\n return this.options.provider.awareness\n })(),\n {\n cursorBuilder: this.options.render,\n selectionBuilder: this.options.selectionRender,\n },\n ),\n ]\n },\n})\n","import { CollaborationCaret } from './collaboration-caret.js'\n\nexport * from './collaboration-caret.js'\n\nexport default CollaborationCaret\n"],"mappings":";AAAA,SAAS,iBAAiB;AAE1B,SAAS,yBAAyB,qBAAqB;AAkFvD,IAAM,yBAAyB,CAAC,WAA6C;AAC3E,SAAO,MAAM,KAAK,OAAO,QAAQ,CAAC,EAAE,IAAI,CAAC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AAA,QACF;AAEA,eAAO,OAAO,SAAS,WAAW,UAAU;AAAA,MAC9C;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,wBAAwB;AACtB,WAAO;AAAA,MACL;AAAA,SACG,MAAM;AACL,eAAK,QAAQ,SAAS,UAAU,mBAAmB,QAAQ,KAAK,QAAQ,IAAI;AAE5E,eAAK,QAAQ,QAAQ,uBAAuB,KAAK,QAAQ,SAAS,UAAU,MAAM;AAElF,eAAK,QAAQ,SAAS,UAAU,GAAG,UAAU,MAAM;AACjD,iBAAK,QAAQ,QAAQ,uBAAuB,KAAK,QAAQ,SAAS,UAAU,MAAM;AAAA,UACpF,CAAC;AAED,iBAAO,KAAK,QAAQ,SAAS;AAAA,QAC/B,GAAG;AAAA,QACH;AAAA,UACE,eAAe,KAAK,QAAQ;AAAA,UAC5B,kBAAkB,KAAK,QAAQ;AAAA,QACjC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ACvLD,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-collaboration-caret",
|
|
3
3
|
"description": "collaboration caret extension for tiptap",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.12.1",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@tiptap/y-tiptap": "^3.0.0",
|
|
35
|
-
"@tiptap/core": "^3.
|
|
36
|
-
"@tiptap/pm": "^3.
|
|
35
|
+
"@tiptap/core": "^3.12.1",
|
|
36
|
+
"@tiptap/pm": "^3.12.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@tiptap/y-tiptap": "^3.0.0",
|
|
40
|
-
"@tiptap/core": "^3.
|
|
41
|
-
"@tiptap/pm": "^3.
|
|
40
|
+
"@tiptap/core": "^3.12.1",
|
|
41
|
+
"@tiptap/pm": "^3.12.1"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
|
@@ -149,10 +149,7 @@ export const CollaborationCaret = Extension.create<CollaborationCaretOptions, Co
|
|
|
149
149
|
addCommands() {
|
|
150
150
|
return {
|
|
151
151
|
updateUser: attributes => () => {
|
|
152
|
-
this.options.user
|
|
153
|
-
|
|
154
|
-
this.options.provider.awareness.setLocalStateField('user', this.options.user)
|
|
155
|
-
|
|
152
|
+
this.options.provider.awareness.setLocalStateField('user', attributes)
|
|
156
153
|
return true
|
|
157
154
|
},
|
|
158
155
|
user:
|