From e2e358c74869c09c032d8f23f56fd2228ac1c1a9 Mon Sep 17 00:00:00 2001 From: AlphaX-Qortal Date: Wed, 22 Jan 2025 13:20:12 +0100 Subject: [PATCH] Added TipTap Mention --- package-lock.json | 31 +++++++++++++++++++ package.json | 1 + plugins/plugins/core/components/ChatPage.js | 10 ++++-- .../plugins/core/components/ChatScroller.js | 5 +-- .../node-management/node-management.src.js | 3 +- plugins/plugins/core/q-chat/q-chat.src.js | 2 ++ 6 files changed, 47 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21e69491..e599b9bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@tiptap/core": "2.0.4", "@tiptap/extension-highlight": "2.0.4", "@tiptap/extension-image": "2.0.4", + "@tiptap/extension-mention": "2.0.0", "@tiptap/extension-placeholder": "2.0.4", "@tiptap/extension-underline": "2.0.4", "@tiptap/html": "2.0.4", @@ -3398,6 +3399,21 @@ "@tiptap/core": "^2.0.0" } }, + "node_modules/@tiptap/extension-mention": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-mention/-/extension-mention-2.0.0.tgz", + "integrity": "sha512-HN+MqyRA9E6pfO1Yck8qCINaXJh5+ypET4Iahp+6JGNih7coQ4oqeY+rsPJ2ksVv2VXWUpUWZblvBrluxjmLng==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0", + "@tiptap/suggestion": "2.0.0" + } + }, "node_modules/@tiptap/extension-placeholder": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@tiptap/extension-placeholder/-/extension-placeholder-2.0.4.tgz", @@ -3812,6 +3828,21 @@ "prosemirror-view": "^1.33.8" } }, + "node_modules/@tiptap/suggestion": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tiptap/suggestion/-/suggestion-2.0.0.tgz", + "integrity": "sha512-U4POIQXKOJu/1a81W2A0COVx0ncAh9VxyMx3DkSZd/gPxjXbWIq1EKcb+TJOo+317fA9WVtWYKRCkFRMv5f24g==", + "license": "MIT", + "peer": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, "node_modules/@tootallnate/once": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", diff --git a/package.json b/package.json index 0dd8e519..8f50e19c 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@tiptap/core": "2.0.4", "@tiptap/extension-highlight": "2.0.4", "@tiptap/extension-image": "2.0.4", + "@tiptap/extension-mention": "2.0.0", "@tiptap/extension-placeholder": "2.0.4", "@tiptap/extension-underline": "2.0.4", "@tiptap/html": "2.0.4", diff --git a/plugins/plugins/core/components/ChatPage.js b/plugins/plugins/core/components/ChatPage.js index 6c53c9a9..2e2406b1 100644 --- a/plugins/plugins/core/components/ChatPage.js +++ b/plugins/plugins/core/components/ChatPage.js @@ -15,6 +15,7 @@ import StarterKit from '@tiptap/starter-kit' import Underline from '@tiptap/extension-underline' import Placeholder from '@tiptap/extension-placeholder' import Highlight from '@tiptap/extension-highlight' +import Mention from '@tiptap/extension-mention' import WebWorker from 'web-worker:./computePowWorker.js' import WebWorkerFile from 'web-worker:./computePowWorkerFile.js' import WebWorkerSortMessages from 'web-worker:./webworkerSortMessages.js' @@ -344,7 +345,7 @@ class ChatPage extends LitElement { } ${+this.repliedToMessageObj.version > 1 ? html` - ${unsafeHTML(generateHTML(this.repliedToMessageObj.message, [StarterKit, Underline, Highlight]))} + ${unsafeHTML(generateHTML(this.repliedToMessageObj.message, [StarterKit, Underline, Highlight, Mention]))} ` : '' } @@ -361,7 +362,7 @@ class ChatPage extends LitElement {

${translate("chatpage.cchange25")}

- ${unsafeHTML(generateHTML(this.editedMessageObj.message, [StarterKit, Underline, Highlight]))} + ${unsafeHTML(generateHTML(this.editedMessageObj.message, [StarterKit, Underline, Highlight, Mention]))}
this.closeEditMessageContainer()}> @@ -1070,6 +1071,7 @@ class ChatPage extends LitElement { StarterKit, Underline, Highlight, + Mention, Placeholder.configure({ placeholder: `${placeholderString}` }), @@ -1108,6 +1110,7 @@ class ChatPage extends LitElement { StarterKit, Underline, Highlight, + Mention, Placeholder.configure({ placeholder: `${placeholderString}` }), @@ -1143,6 +1146,7 @@ class ChatPage extends LitElement { StarterKit, Underline, Highlight, + Mention, Placeholder.configure({ placeholder: `${placeholderString}` }), @@ -1178,6 +1182,7 @@ class ChatPage extends LitElement { StarterKit, Underline, Highlight, + Mention, Placeholder.configure({ placeholder: `${placeholderString}` }), @@ -1213,6 +1218,7 @@ class ChatPage extends LitElement { StarterKit, Underline, Highlight, + Mention, Placeholder.configure({ placeholder: `${placeholderString}` }), diff --git a/plugins/plugins/core/components/ChatScroller.js b/plugins/plugins/core/components/ChatScroller.js index 9054ff9b..c5ebbeb0 100644 --- a/plugins/plugins/core/components/ChatScroller.js +++ b/plugins/plugins/core/components/ChatScroller.js @@ -9,6 +9,7 @@ import { chatStyles } from './plugins-css' import isElectron from 'is-electron' import axios from 'axios' import Highlight from '@tiptap/extension-highlight' +import Mention from '@tiptap/extension-mention' import ShortUniqueId from 'short-unique-id' import StarterKit from '@tiptap/starter-kit' import Underline from '@tiptap/extension-underline' @@ -1086,7 +1087,7 @@ class MessageTemplate extends LitElement { const parsedMessageObj = JSON.parse(this.messageObj.decodedMessage) if (+parsedMessageObj.version > 1 && parsedMessageObj.messageText) { - messageVersion2 = generateHTML(parsedMessageObj.messageText, [StarterKit, Underline, Highlight]) + messageVersion2 = generateHTML(parsedMessageObj.messageText, [StarterKit, Underline, Highlight, Mention]) messageVersion2WithLink = processText(messageVersion2) } @@ -1256,7 +1257,7 @@ class MessageTemplate extends LitElement { if (repliedToData && repliedToData.decodedMessage && repliedToData.decodedMessage.messageText) { try { - repliedToMessageText = generateHTML(repliedToData.decodedMessage.messageText, [StarterKit, Underline, Highlight]) + repliedToMessageText = generateHTML(repliedToData.decodedMessage.messageText, [StarterKit, Underline, Highlight, Mention]) } catch (error) { /* empty */ } } diff --git a/plugins/plugins/core/node-management/node-management.src.js b/plugins/plugins/core/node-management/node-management.src.js index b1c2eeeb..85eedf3b 100644 --- a/plugins/plugins/core/node-management/node-management.src.js +++ b/plugins/plugins/core/node-management/node-management.src.js @@ -480,7 +480,8 @@ class NodeManagement extends LitElement { updateMintingAccounts() { this.mintingAccounts = [] parentEpml.request('apiCall', { - url: `/admin/mintingaccounts` + url: `/admin/mintingaccounts?apiKey=${this.getApiKey()}`, + method: 'GET' }).then((res) => { this.mintingAccounts = res }) diff --git a/plugins/plugins/core/q-chat/q-chat.src.js b/plugins/plugins/core/q-chat/q-chat.src.js index 7f4ede43..29f1f073 100644 --- a/plugins/plugins/core/q-chat/q-chat.src.js +++ b/plugins/plugins/core/q-chat/q-chat.src.js @@ -19,6 +19,7 @@ import StarterKit from '@tiptap/starter-kit' import Underline from '@tiptap/extension-underline' import Placeholder from '@tiptap/extension-placeholder' import Highlight from '@tiptap/extension-highlight' +import Mention from '@tiptap/extension-mention' import ShortUniqueId from 'short-unique-id' import snackbar from '../components/snackbar' import '../components/ChatWelcomePage' @@ -577,6 +578,7 @@ class Chat extends LitElement { StarterKit, Underline, Highlight, + Mention, Placeholder.configure({ placeholder: 'Write something …' }),