Skip to content

Commit 9202684

Browse files
Merge pull request #7437 from nextcloud/renovate/main-major-tiptap
fix(deps): update tiptap to v3 (main) (major)
2 parents 24bf40c + eda03bf commit 9202684

25 files changed

+9438
-27562
lines changed

cypress/e2e/nodes/ListItem.spec.js

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

6-
/* eslint-disable import/no-named-as-default */
7-
import ListItem from '@tiptap/extension-list-item'
8-
import OrderedList from '@tiptap/extension-ordered-list'
6+
import { ListItem, OrderedList } from '@tiptap/extension-list'
97
/* eslint-enable import/no-named-as-default */
108
import Markdown from './../../../src/extensions/Markdown.js'
119
import BulletList from './../../../src/nodes/BulletList.js'

package-lock.json

Lines changed: 9294 additions & 27469 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,35 @@
4545
"@nextcloud/sharing": "^0.3.0",
4646
"@nextcloud/vue": "^8.34.0",
4747
"@quartzy/markdown-it-mentions": "^0.2.0",
48-
"@tiptap/core": "^2.27.1",
49-
"@tiptap/extension-blockquote": "^2.27.1",
50-
"@tiptap/extension-bold": "^2.27.1",
51-
"@tiptap/extension-bullet-list": "^2.27.1",
52-
"@tiptap/extension-character-count": "^2.27.1",
53-
"@tiptap/extension-code": "^2.27.1",
54-
"@tiptap/extension-code-block": "^2.27.1",
55-
"@tiptap/extension-code-block-lowlight": "^2.27.1",
56-
"@tiptap/extension-collaboration": "^2.27.1",
57-
"@tiptap/extension-collaboration-cursor": "^2.26.2",
58-
"@tiptap/extension-document": "^2.27.1",
59-
"@tiptap/extension-drag-handle": "^2.27.1",
60-
"@tiptap/extension-drag-handle-vue-2": "^2.27.1",
61-
"@tiptap/extension-dropcursor": "^2.27.1",
62-
"@tiptap/extension-gapcursor": "^2.27.1",
63-
"@tiptap/extension-hard-break": "^2.27.1",
64-
"@tiptap/extension-heading": "^2.27.1",
65-
"@tiptap/extension-history": "^2.27.1",
66-
"@tiptap/extension-horizontal-rule": "^2.27.1",
67-
"@tiptap/extension-image": "^2.27.1",
68-
"@tiptap/extension-italic": "^2.27.1",
69-
"@tiptap/extension-link": "^2.27.1",
70-
"@tiptap/extension-list-item": "^2.27.1",
71-
"@tiptap/extension-mention": "^2.27.1",
72-
"@tiptap/extension-ordered-list": "^2.27.1",
73-
"@tiptap/extension-paragraph": "^2.27.1",
74-
"@tiptap/extension-placeholder": "^2.27.1",
75-
"@tiptap/extension-strike": "^2.27.1",
76-
"@tiptap/extension-table": "^2.27.1",
77-
"@tiptap/extension-table-cell": "^2.27.1",
78-
"@tiptap/extension-table-header": "^2.27.1",
79-
"@tiptap/extension-table-row": "^2.27.1",
80-
"@tiptap/extension-task-item": "^2.27.1",
81-
"@tiptap/extension-task-list": "^2.27.1",
82-
"@tiptap/extension-text": "^2.27.1",
83-
"@tiptap/extension-typography": "^2.27.1",
84-
"@tiptap/extension-underline": "^2.27.1",
85-
"@tiptap/pm": "^2.27.1",
86-
"@tiptap/suggestion": "^2.27.1",
87-
"@tiptap/vue-2": "^2.27.1",
48+
"@tiptap/core": "^3.10.5",
49+
"@tiptap/extension-blockquote": "^3.10.5",
50+
"@tiptap/extension-bold": "^3.10.5",
51+
"@tiptap/extension-code": "^3.10.5",
52+
"@tiptap/extension-code-block": "^3.10.5",
53+
"@tiptap/extension-code-block-lowlight": "^3.10.5",
54+
"@tiptap/extension-collaboration": "^3.10.5",
55+
"@tiptap/extension-collaboration-caret": "^3.10.5",
56+
"@tiptap/extension-document": "^3.10.5",
57+
"@tiptap/extension-drag-handle": "^3.10.5",
58+
"@tiptap/extension-drag-handle-vue-2": "^3.10.5",
59+
"@tiptap/extension-hard-break": "^3.10.5",
60+
"@tiptap/extension-heading": "^3.10.5",
61+
"@tiptap/extension-horizontal-rule": "^3.10.5",
62+
"@tiptap/extension-image": "^3.10.5",
63+
"@tiptap/extension-italic": "^3.10.5",
64+
"@tiptap/extension-link": "^3.10.5",
65+
"@tiptap/extension-list": "^3.10.5",
66+
"@tiptap/extension-mention": "^3.10.5",
67+
"@tiptap/extension-paragraph": "^3.10.5",
68+
"@tiptap/extension-strike": "^3.10.5",
69+
"@tiptap/extension-table": "^3.10.5",
70+
"@tiptap/extension-text": "^3.10.5",
71+
"@tiptap/extension-typography": "^3.10.5",
72+
"@tiptap/extension-underline": "^3.10.5",
73+
"@tiptap/extensions": "^3.10.5",
74+
"@tiptap/pm": "^3.10.5",
75+
"@tiptap/suggestion": "^3.10.5",
76+
"@tiptap/vue-2": "^3.10.5",
8877
"@vueuse/shared": "^11.3.0",
8978
"debounce": "^3.0.0",
9079
"escape-html": "^1.0.3",

src/EditorFactory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const createRichEditor = ({
5353
})
5454
}
5555

56-
const createPlainEditor = ({ language, extensions = [] } = {}) => {
56+
const createPlainEditor = ({ language = 'plaintext', extensions = [] } = {}) => {
5757
return new Editor({
5858
editorProps,
5959
extensions: [

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/components/Editor/MarkdownContentEditor.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import MainContainer from './MainContainer.vue'
2727
import Wrapper from './Wrapper.vue'
2828
/* eslint-disable import/no-named-as-default */
2929
import { getCurrentUser } from '@nextcloud/auth'
30-
import History from '@tiptap/extension-history'
30+
import { UndoRedo } from '@tiptap/extensions'
3131
import { provide, watch } from 'vue'
3232
import { provideEditor } from '../../composables/useEditor.ts'
3333
import { editorFlagsKey } from '../../composables/useEditorFlags.ts'
@@ -89,7 +89,7 @@ export default {
8989
setup(props) {
9090
const extensions = [
9191
RichText.configure({
92-
extensions: [History],
92+
extensions: [UndoRedo],
9393
}),
9494
FocusTrap,
9595
]

src/composables/useEditorMethods.ts

Lines changed: 2 additions & 2 deletions
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'
@@ -28,7 +28,7 @@ export const useEditorMethods = (editor: Editor) => {
2828
: `<pre>${escapeHtml(content)}</pre>`
2929
editor
3030
.chain()
31-
.setContent(html, addToHistory)
31+
.setContent(html, { emitUpdate: addToHistory })
3232
.command(({ tr }) => {
3333
tr.setMeta('addToHistory', addToHistory)
3434
return true

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: 19 additions & 15 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,27 +78,27 @@ 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.provider.awareness.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')
9094
const updated = transaction.docChanged
9195
if (updated && addToHistory && !pointer) {
9296
editor.commands.updateUser({
93-
...this.options.user,
97+
...this.options.provider.awareness.getLocalState().user,
9498
lastUpdate: getTimestamp(),
9599
})
96100
}
97101
},
98102
})
99103

100-
export default CollaborationCursor
104+
export default CollaborationCaret

0 commit comments

Comments
 (0)