Skip to content

Commit d0faf1b

Browse files
committed
fix: rename CollaborationCursor to CollaborationCaret
The extension got renamed upstream. Signed-off-by: Jonas <jonas@freesources.org>
1 parent e06db05 commit d0faf1b

6 files changed

Lines changed: 30 additions & 26 deletions

File tree

src/components/Editor.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ import { provideEditorWidth } from '../composables/useEditorWidth.ts'
104104
import { provideSaveService } from '../composables/useSaveService.ts'
105105
import { provideSyncService } from '../composables/useSyncService.ts'
106106
import { useSyntaxHighlighting } from '../composables/useSyntaxHighlighting.ts'
107-
import { CollaborationCursor } from '../extensions/index.js'
107+
import { CollaborationCaret } from '../extensions/index.js'
108108
import { exposeForDebugging, removeFromDebugging } from '../helpers/debug.js'
109109
import { logger } from '../helpers/logger.js'
110110
import { setInitialYjsState } from '../helpers/setInitialYjsState.js'
@@ -240,7 +240,7 @@ export default defineComponent({
240240
const extensions = [
241241
Autofocus.configure({ fileId: props.fileId }),
242242
Collaboration.configure({ document: ydoc }),
243-
CollaborationCursor.configure({ provider: { awareness } }),
243+
CollaborationCaret.configure({ provider: { awareness } }),
244244
]
245245
const editor = isRichEditor
246246
? createRichEditor({
@@ -929,7 +929,7 @@ export default defineComponent({
929929
}
930930
931931
/* Give a remote user a caret */
932-
.collaboration-cursor__caret {
932+
.collaboration-carets__caret {
933933
position: relative;
934934
margin-left: -1px;
935935
margin-right: -1px;
@@ -940,7 +940,7 @@ export default defineComponent({
940940
}
941941
942942
/* Render the username above the caret */
943-
.collaboration-cursor__label {
943+
.collaboration-carets__label {
944944
position: absolute;
945945
top: -1.4em;
946946
left: -1px;
@@ -955,11 +955,11 @@ export default defineComponent({
955955
white-space: nowrap;
956956
opacity: 0;
957957
958-
&.collaboration-cursor__label__active {
958+
&.collaboration-carets__label__active {
959959
opacity: 1;
960960
}
961961
962-
&:not(.collaboration-cursor__label__active) {
962+
&:not(.collaboration-carets__label__active) {
963963
transition: opacity 0.2s 5s;
964964
}
965965
}

src/composables/useEditorMethods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import type { Editor } from '@tiptap/core'
77
import escapeHtml from 'escape-html'
8-
import type { AwarenessUser } from '../extensions/CollaborationCursor.ts'
8+
import type { AwarenessUser } from '../extensions/CollaborationCaret.ts'
99
import Markdown from '../extensions/Markdown.js'
1010
import markdownit from '../markdownit/index.js'
1111
import { isUser, type Session } from '../services/SyncService'

src/css/print.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@
135135
}
136136
}
137137

138-
.collaboration-cursor__caret,
139-
.collaboration-cursor__label {
138+
.collaboration-carets__caret,
139+
.collaboration-carets__label {
140140
display: none;
141141
}
142142
}

src/css/prosemirror.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ div.ProseMirror {
3737
user-select: text;
3838
font-size: var(--default-font-size);
3939

40-
&:not(.collaboration-cursor__caret) {
40+
&:not(.collaboration-carets__caret) {
4141
border: none !important;
4242
}
4343

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { 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

99
export 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
*/
4646
function 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

src/extensions/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import CollaborationCursor from './CollaborationCursor.ts'
6+
import CollaborationCaret from './CollaborationCaret.ts'
77
import Emoji from './Emoji.js'
88
import FocusTrap from './FocusTrap.js'
99
import KeepSyntax from './KeepSyntax.js'
@@ -14,7 +14,7 @@ import RichText from './RichText.js'
1414
import UserColor from './UserColor.js'
1515

1616
export {
17-
CollaborationCursor,
17+
CollaborationCaret,
1818
Emoji,
1919
FocusTrap,
2020
KeepSyntax,

0 commit comments

Comments
 (0)