44 */
55
66import { t } from '@nextcloud/l10n'
7- import { CollaborationCursor as TiptapCollaborationCursor } from '@tiptap/extension-collaboration-cursor '
7+ import { CollaborationCaret as TiptapCollaborationCaret } from '@tiptap/extension-collaboration-caret '
88
99export interface AwarenessUser {
1010 color : string
@@ -14,18 +14,18 @@ export interface AwarenessUser {
1414/**
1515 * @param clientId The Yjs client ID
1616 */
17- function showCursorLabel ( clientId : number ) {
17+ function showCaretLabel ( clientId : number ) {
1818 setTimeout ( ( ) => {
1919 const el = document . getElementById (
20- `collaboration-cursor__label__ ${ clientId } ` ,
20+ `collaboration-carets__label__ ${ clientId } ` ,
2121 )
2222 if ( ! el ) {
2323 return
2424 }
2525
26- el . classList . add ( 'collaboration-cursor__label__active ' )
26+ el . classList . add ( 'collaboration-carets__label__active ' )
2727 setTimeout ( ( ) => {
28- el ?. classList . remove ( 'collaboration-cursor__label__active ' )
28+ el ?. classList . remove ( 'collaboration-carets__label__active ' )
2929 } , 50 )
3030 } , 50 )
3131}
@@ -38,26 +38,30 @@ function getTimestamp() {
3838}
3939
4040/**
41- * Render the cursor decoration
41+ * Render the caret decoration
4242 *
4343 * @param user the users awareness data
4444 * @param clientId not part of the tiptap type signature but provided by y-prosemirror
4545 */
4646function render ( user : AwarenessUser , clientId ?: number ) : HTMLElement {
4747 const cursor = document . createElement ( 'span' )
48- cursor . classList . add ( 'collaboration-cursor__caret' )
48+
49+ cursor . classList . add ( 'collaboration-carets__caret' )
4950 cursor . setAttribute ( 'style' , `border-color: ${ user . color } ` )
51+
5052 const label = document . createElement ( 'div' )
51- label . classList . add ( 'collaboration-cursor__label' )
52- label . id = `collaboration-cursor__label__${ clientId } `
53+ label . id = `collaboration-carets__label__${ clientId } `
54+
55+ label . classList . add ( 'collaboration-carets__label' )
5356 label . setAttribute ( 'style' , `background-color: ${ user . color } ` )
5457 const text = document . createTextNode ( user . name || t ( 'text' , 'Guest' ) )
5558 label . insertBefore ( text , null )
5659 cursor . insertBefore ( label , null )
60+
5761 return cursor
5862}
5963
60- const CollaborationCursor = TiptapCollaborationCursor . extend ( {
64+ const CollaborationCaret = TiptapCollaborationCaret . extend ( {
6165 addOptions ( ) {
6266 return {
6367 ...this . parent ?.( ) ,
@@ -74,16 +78,16 @@ const CollaborationCursor = TiptapCollaborationCursor.extend({
7478 ) => {
7579 if ( origin !== 'local' ) {
7680 for ( const clientId of [ ...added , ...updated ] ) {
77- if ( clientId !== this . options . user . clientId ) {
78- showCursorLabel ( clientId )
81+ if ( clientId !== this . options . user . clientID ) {
82+ showCaretLabel ( clientId )
7983 }
8084 }
8185 }
8286 } ,
8387 )
8488 } ,
8589
86- // Flag own cursor as active on undoable changes to the document state
90+ // Flag own caret as active on undoable changes to the document state
8791 onTransaction ( { transaction, editor } ) {
8892 const addToHistory = transaction . getMeta ( 'addToHistory' ) ?? true
8993 const pointer = transaction . getMeta ( 'pointer' )
@@ -97,4 +101,4 @@ const CollaborationCursor = TiptapCollaborationCursor.extend({
97101 } ,
98102} )
99103
100- export default CollaborationCursor
104+ export default CollaborationCaret
0 commit comments