@tiptap/extension-collaboration-cursor
Advanced tools
Comparing version 2.0.0-alpha.4 to 2.0.0-alpha.5
@@ -6,2 +6,10 @@ # Change Log | ||
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-collaboration-cursor@2.0.0-alpha.4...@tiptap/extension-collaboration-cursor@2.0.0-alpha.5) (2020-12-18) | ||
**Note:** Version bump only for package @tiptap/extension-collaboration-cursor | ||
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-collaboration-cursor@2.0.0-alpha.3...@tiptap/extension-collaboration-cursor@2.0.0-alpha.4) (2020-12-02) | ||
@@ -8,0 +16,0 @@ |
@@ -1,28 +0,3 @@ | ||
import { Extension, Command } from '@tiptap/core'; | ||
export interface CollaborationCursorOptions { | ||
provider: any; | ||
user: { | ||
[key: string]: any; | ||
}; | ||
render(user: { | ||
[key: string]: any; | ||
}): HTMLElement; | ||
onUpdate: (users: { | ||
clientId: string; | ||
[key: string]: any; | ||
}[]) => null; | ||
} | ||
declare const CollaborationCursor: Extension<CollaborationCursorOptions, { | ||
/** | ||
* Update details of the current user | ||
*/ | ||
user: (attributes: { | ||
[key: string]: any; | ||
}) => Command; | ||
}>; | ||
import { CollaborationCursor } from './collaboration-cursor'; | ||
export * from './collaboration-cursor'; | ||
export default CollaborationCursor; | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
CollaborationCursor: typeof CollaborationCursor; | ||
} | ||
} |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var core = require('@tiptap/core'); | ||
@@ -59,5 +61,2 @@ var yProsemirror = require('y-prosemirror'); | ||
if (event.status === 'connected') { | ||
// FIX: Reset the awareness state | ||
// PR: https://github.com/yjs/y-protocols/issues/7 | ||
this.options.provider.awareness.setLocalState({}); | ||
this.options.provider.awareness.setLocalStateField('user', this.options.user); | ||
@@ -77,3 +76,4 @@ } | ||
module.exports = CollaborationCursor; | ||
exports.CollaborationCursor = CollaborationCursor; | ||
exports.default = CollaborationCursor; | ||
//# sourceMappingURL=tiptap-extension-collaboration-cursor.cjs.js.map |
@@ -57,5 +57,2 @@ import { Extension } from '@tiptap/core'; | ||
if (event.status === 'connected') { | ||
// FIX: Reset the awareness state | ||
// PR: https://github.com/yjs/y-protocols/issues/7 | ||
this.options.provider.awareness.setLocalState({}); | ||
this.options.provider.awareness.setLocalStateField('user', this.options.user); | ||
@@ -76,2 +73,3 @@ } | ||
export default CollaborationCursor; | ||
export { CollaborationCursor }; | ||
//# sourceMappingURL=tiptap-extension-collaboration-cursor.esm.js.map |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@tiptap/core'), require('y-prosemirror')) : | ||
typeof define === 'function' && define.amd ? define(['@tiptap/core', 'y-prosemirror'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['@tiptap/extension-collaboration-cursor'] = factory(global.core, global.yProsemirror)); | ||
}(this, (function (core, yProsemirror) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('y-prosemirror')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'y-prosemirror'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/extension-collaboration-cursor'] = {}, global.core, global.yProsemirror)); | ||
}(this, (function (exports, core, yProsemirror) { 'use strict'; | ||
@@ -60,5 +60,2 @@ const awarenessStatesToArray = (states) => { | ||
if (event.status === 'connected') { | ||
// FIX: Reset the awareness state | ||
// PR: https://github.com/yjs/y-protocols/issues/7 | ||
this.options.provider.awareness.setLocalState({}); | ||
this.options.provider.awareness.setLocalStateField('user', this.options.user); | ||
@@ -78,5 +75,8 @@ } | ||
return CollaborationCursor; | ||
exports.CollaborationCursor = CollaborationCursor; | ||
exports.default = CollaborationCursor; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=tiptap-extension-collaboration-cursor.umd.js.map |
{ | ||
"name": "@tiptap/extension-collaboration-cursor", | ||
"description": "collaboration cursor extension for tiptap", | ||
"version": "2.0.0-alpha.4", | ||
"version": "2.0.0-alpha.5", | ||
"homepage": "https://tiptap.dev", | ||
@@ -28,5 +28,5 @@ "keywords": [ | ||
"dependencies": { | ||
"y-prosemirror": "^1.0.0" | ||
"y-prosemirror": "^1.0.5" | ||
}, | ||
"gitHead": "a884cb81de8783d0097741c1ddb97a82ea88ae0e" | ||
"gitHead": "0371cb0a5d803a44d93532aa34419ec7ffffdc24" | ||
} |
@@ -1,100 +0,5 @@ | ||
import { Extension, Command } from '@tiptap/core' | ||
import { yCursorPlugin } from 'y-prosemirror' | ||
import { CollaborationCursor } from './collaboration-cursor' | ||
export interface CollaborationCursorOptions { | ||
provider: any, | ||
user: { [key: string]: any }, | ||
render (user: { [key: string]: any }): HTMLElement, | ||
onUpdate: (users: { clientId: string, [key: string]: any }[]) => null, | ||
} | ||
export * from './collaboration-cursor' | ||
const awarenessStatesToArray = (states: Map<number, { [key: string]: any }>) => { | ||
return Array.from(states.entries()).map(([key, value]) => { | ||
return { | ||
clientId: key, | ||
...value.user, | ||
} | ||
}) | ||
} | ||
const CollaborationCursor = Extension.create({ | ||
name: 'collaborationCursor', | ||
defaultOptions: <CollaborationCursorOptions>{ | ||
provider: null, | ||
user: { | ||
name: null, | ||
color: null, | ||
}, | ||
render: user => { | ||
const cursor = document.createElement('span') | ||
cursor.classList.add('collaboration-cursor__caret') | ||
cursor.setAttribute('style', `border-color: ${user.color}`) | ||
const label = document.createElement('div') | ||
label.classList.add('collaboration-cursor__label') | ||
label.setAttribute('style', `background-color: ${user.color}`) | ||
label.insertBefore(document.createTextNode(user.name), null) | ||
cursor.insertBefore(label, null) | ||
return cursor | ||
}, | ||
onUpdate: () => null, | ||
}, | ||
addCommands() { | ||
return { | ||
/** | ||
* Update details of the current user | ||
*/ | ||
user: (attributes: { [key: string]: any }): Command => () => { | ||
this.options.user = attributes | ||
this.options.provider.awareness.setLocalStateField('user', this.options.user) | ||
return true | ||
}, | ||
} | ||
}, | ||
addProseMirrorPlugins() { | ||
return [ | ||
yCursorPlugin((() => { | ||
this.options.provider.awareness.setLocalStateField('user', this.options.user) | ||
this.options.provider.awareness.on('change', () => { | ||
this.options.onUpdate(awarenessStatesToArray(this.options.provider.awareness.states)) | ||
}) | ||
this.options.provider.awareness.on('update', () => { | ||
this.options.onUpdate(awarenessStatesToArray(this.options.provider.awareness.states)) | ||
}) | ||
this.options.provider.on('status', (event: { status: string }) => { | ||
if (event.status === 'connected') { | ||
// FIX: Reset the awareness state | ||
// PR: https://github.com/yjs/y-protocols/issues/7 | ||
this.options.provider.awareness.setLocalState({}) | ||
this.options.provider.awareness.setLocalStateField('user', this.options.user) | ||
} | ||
}) | ||
this.options.onUpdate(awarenessStatesToArray(this.options.provider.awareness.states)) | ||
return this.options.provider.awareness | ||
})(), | ||
// @ts-ignore | ||
{ | ||
cursorBuilder: this.options.render, | ||
}), | ||
] | ||
}, | ||
}) | ||
export default CollaborationCursor | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
CollaborationCursor: typeof CollaborationCursor, | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1366308
16
1203
Updatedy-prosemirror@^1.0.5