diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..a8b6f1a4 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": ["eslint:recommended", "plugin:lit/recommended", "plugin:wc/recommended"], + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module" + }, + "rules": { + "no-mixed-spaces-and-tabs": 0 + } +} diff --git a/package.json b/package.json index 6f6fd7ba..619213de 100644 --- a/package.json +++ b/package.json @@ -37,13 +37,15 @@ "os-locale": "3.0.0" }, "devDependencies": { + "@electron/notarize": "1.2.3", "electron": "22.0.0", "electron-builder": "23.6.0", "electron-packager": "17.1.1", - "@electron/notarize": "1.2.3", + "eslint-plugin-lit": "1.8.0", + "eslint-plugin-wc": "1.4.0", "shelljs": "0.8.5" }, "engines": { "node": ">=16.17.1" } -} \ No newline at end of file +} diff --git a/qortal-ui-plugins/package.json b/qortal-ui-plugins/package.json index 6df19b76..0f04dae9 100644 --- a/qortal-ui-plugins/package.json +++ b/qortal-ui-plugins/package.json @@ -24,6 +24,7 @@ "@tiptap/extension-image": "2.0.0-beta.209", "@tiptap/extension-placeholder": "2.0.0-beta.209", "@tiptap/extension-underline": "2.0.0-beta.209", + "@tiptap/extension-highlight": "2.0.0-beta.209", "@tiptap/html": "2.0.0-beta.209", "@tiptap/starter-kit": "2.0.0-beta.209", "asmcrypto.js": "2.3.2", diff --git a/qortal-ui-plugins/plugins/core/components/ChatPage.js b/qortal-ui-plugins/plugins/core/components/ChatPage.js index e37b2722..415d30c3 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatPage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatPage.js @@ -8,6 +8,7 @@ import { generateHTML } from '@tiptap/core' 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 {unsafeHTML} from 'lit/directives/unsafe-html.js'; import { Editor, Extension } from '@tiptap/core' @@ -161,7 +162,6 @@ class ChatPage extends LitElement { align-items: center; height: auto; padding: 5px 5px 5px 7px; - overflow-y: hidden; } .chat-text-area .typing-area .emoji-button { @@ -305,7 +305,6 @@ class ChatPage extends LitElement { justify-content: center; min-height: 60px; max-height: 100%; - overflow: hidden; } .chat-text-area .typing-area { @@ -360,6 +359,13 @@ class ChatPage extends LitElement { padding: 0px; } + .repliedTo-message p mark { + background-color: #ffe066; + border-radius: 0.25em; + box-decoration-break: clone; + padding: 0.125em 0; + } + .reply-icon { width: 20px; color: var(--mdc-theme-primary); @@ -863,6 +869,7 @@ class ChatPage extends LitElement { this.webWorker = null; this.webWorkerImage = null; this.currentEditor = '_chatEditorDOM' + this.initialChat = this.initialChat.bind(this) } _toggle(value) { @@ -932,7 +939,8 @@ class ChatPage extends LitElement {

${this.repliedToMessageObj.senderName ? this.repliedToMessageObj.senderName : this.repliedToMessageObj.sender}

${unsafeHTML(generateHTML(this.repliedToMessageObj.message, [ StarterKit, - Underline + Underline, + Highlight // other extensions … ]))} @@ -953,7 +961,8 @@ class ChatPage extends LitElement {

${translate("chatpage.cchange25")}

${unsafeHTML(generateHTML(this.editedMessageObj.message, [ StarterKit, - Underline + Underline, + Highlight // other extensions … ]))} @@ -1249,10 +1258,14 @@ class ChatPage extends LitElement { const elementChatImageId = this.shadowRoot.getElementById('chatTextCaption').shadowRoot.getElementById('newChat') console.log({elementChatId, elementChatImageId }) this.editor = new Editor({ + onUpdate: ()=> { + this.shadowRoot.getElementById('_chatEditorDOM').getMessageSize(this.editor.getJSON()) + }, element: elementChatId, extensions: [ StarterKit, Underline, + Highlight, Placeholder.configure({ placeholder: 'Write something …', }), @@ -1271,10 +1284,14 @@ class ChatPage extends LitElement { }) this.editorImage = new Editor({ + onUpdate: ()=> { + this.shadowRoot.getElementById('chatTextCaption').getMessageSize(this.editorImage.getJSON()) + }, element: elementChatImageId, extensions: [ StarterKit, Underline, + Highlight, Placeholder.configure({ placeholder: 'Write something …', }), @@ -1293,6 +1310,7 @@ class ChatPage extends LitElement { }}) ] }) + document.addEventListener('keydown', this.initialChat); } disconnectedCallback() { @@ -1302,8 +1320,29 @@ class ChatPage extends LitElement { this.webWorkerImage.terminate(); this.editor.destroy() this.editorImage.destroy() + document.removeEventListener('keydown', this.initialChat); } + initialChat(e) { + console.log('hello1', this.editor) + if (this.editor && !this.editor.isFocused && this.currentEditor === '_chatEditorDOM') { + console.log('hello2') + // WARNING: Deprecated methods from KeyBoard Event + if (e.code === "Space" || e.keyCode === 32 || e.which === 32) { + // this.chatEditor.insertText(' '); + } else if (inputKeyCodes.includes(e.keyCode)) { + console.log('hello3') + this.editor.commands.insertContent(e.key) + // this.chatEditor.insertText(e.key); + this.editor.commands.focus('end') + } else { + this.editor.commands.focus('end') + } + } + + + } + async userSearch() { const nameValue = this.shadowRoot.getElementById('sendTo').value; if (!nameValue) { @@ -1543,6 +1582,15 @@ class ChatPage extends LitElement { if (this.openForwardOpen === true) { } } + if (changedProperties && changedProperties.has('isLoading')) { + if (this.isLoading === true && this.currentEditor === '_chatEditorDOM') { + this.editor.setEditable(false) + } + if (this.isLoading === false && this.currentEditor === '_chatEditorDOM') { + this.editor.setEditable(true) + } + } + } async getName (recipient) { diff --git a/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js b/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js index c4ae9c4e..5e41b669 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js +++ b/qortal-ui-plugins/plugins/core/components/ChatScroller-css.js @@ -511,6 +511,13 @@ export const chatStyles = css` padding: 0px; } + #messageContent p mark { + background-color: #ffe066; + border-radius: 0.25em; + box-decoration-break: clone; + padding: 0.125em 0; + } + #messageContent > * + * { margin-top: 0.75em; outline: none; diff --git a/qortal-ui-plugins/plugins/core/components/ChatScroller.js b/qortal-ui-plugins/plugins/core/components/ChatScroller.js index e2212e19..2d46acb9 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatScroller.js +++ b/qortal-ui-plugins/plugins/core/components/ChatScroller.js @@ -21,6 +21,7 @@ import { EmojiPicker } from 'emoji-picker-js'; import { generateHTML } from '@tiptap/core' import StarterKit from '@tiptap/starter-kit' import Underline from '@tiptap/extension-underline'; +import Highlight from '@tiptap/extension-highlight' const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }) let toggledMessage = {} @@ -386,7 +387,8 @@ class MessageTemplate extends LitElement { messageVersion2 = generateHTML(parsedMessageObj.messageText, [ StarterKit, - Underline + Underline, + Highlight // other extensions … ]) } @@ -576,7 +578,8 @@ class MessageTemplate extends LitElement {

${unsafeHTML(generateHTML(repliedToData.decodedMessage.messageText, [ StarterKit, - Underline + Underline, + Highlight // other extensions … ]))} diff --git a/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js b/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js index 8b6d4d08..9c98b1c4 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js +++ b/qortal-ui-plugins/plugins/core/components/ChatTextEditor.js @@ -44,13 +44,12 @@ class ChatTextEditor extends LitElement { align-items: center; height: auto; width: 100%; - overflow-y: hidden; + } .chatbar-container { width: 100%; display: flex; height: auto; - overflow: hidden; } .chatbar-caption { @@ -263,7 +262,7 @@ class ChatTextEditor extends LitElement { } .chatbar-buttons { visibility: hidden; - transition: all .2s; + transition: all 0.2s; } .chatbar-container:hover .chatbar-buttons { visibility: visible; @@ -279,11 +278,35 @@ class ChatTextEditor extends LitElement { font-size: 18px; margin-block-start: 0px; margin-block-end: 0px; + overflow-wrap: anywhere; } .ProseMirror { width: 100%; box-sizing: border-box; +} + +.ProseMirror mark { + background-color: #ffe066; + border-radius: 0.25em; + box-decoration-break: clone; + padding: 0.125em 0; +} + +.material-icons { + font-family: 'Material Icons'; + font-weight: normal; + font-style: normal; + font-size: 24px; + /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + } ` @@ -308,7 +331,7 @@ class ChatTextEditor extends LitElement { } render() { - console.log('this.editor', this.editor) + console.log('this.editor', this.chatMessageSize) let scrollHeightBool = false; try { console.log('this.chatMessageInput', this.chatMessageInput) @@ -319,13 +342,14 @@ class ChatTextEditor extends LitElement { scrollHeightBool = false; } return html` - +

+ +
1000 ) { - // parentEpml.request('showSnackBar', get("chatpage.cchange29")); - // return; - // }; - // this.chatMessageSize = 0; + if(this.editor.isEmpty) return + this.getMessageSize(this.editor.getJSON()) + if (this.chatMessageSize > 1000 ) { + parentEpml.request('showSnackBar', get("chatpage.cchange29")); + return; + } + this.chatMessageSize = 0; this._sendMessage(props, this.editor.getJSON()); } getMessageSize(message){ + console.log({message}) try { - const messageText = message; - // Format and Sanitize Message - const sanitizedMessage = messageText.replace(/ /gi, ' ').replace(//gi, '\n'); - const trimmedMessage = sanitizedMessage.trim(); + + const trimmedMessage = message let messageObject = {}; if (this.repliedToMessageObj) { @@ -599,7 +630,7 @@ class ChatTextEditor extends LitElement { messageText: trimmedMessage, images: [''], repliedTo: chatReference, - version: 1 + version: 2 } } else if (this.editedMessageObj) { let message = ""; @@ -622,14 +653,14 @@ class ChatTextEditor extends LitElement { identifier: '123456' }], repliedTo: '', - version: 1 + version: 2 }; } else { messageObject = { messageText: trimmedMessage, images: [''], repliedTo: '', - version: 1 + version: 2 }; } diff --git a/qortal-ui-plugins/plugins/core/components/UserInfo/UserInfo.js b/qortal-ui-plugins/plugins/core/components/UserInfo/UserInfo.js index c31b4515..02bcfac3 100644 --- a/qortal-ui-plugins/plugins/core/components/UserInfo/UserInfo.js +++ b/qortal-ui-plugins/plugins/core/components/UserInfo/UserInfo.js @@ -52,13 +52,6 @@ export class UserInfo extends LitElement { return imageHTMLRes; } - updated(changedProperties) { - if (changedProperties && changedProperties.has('selectedHead')) { - if (this.selectedHead) { - console.log(this.selectedHead, "selected head") - } - } - } render() { let avatarImg = ""; diff --git a/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js b/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js index 7d0e4d27..af66fd00 100644 --- a/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js +++ b/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js @@ -119,10 +119,15 @@ class Chat extends LitElement { const elementChatId = this.shadowRoot.getElementById('messageBox').shadowRoot.getElementById('privateMessage') console.log({elementChatId}) this.editor = new Editor({ + onUpdate: ()=> { + console.log('q-chat editor', this.editor) + this.shadowRoot.getElementById('messageBox').getMessageSize(this.editor.getJSON()) + }, element: elementChatId, extensions: [ StarterKit, Underline, + Highlight, Placeholder.configure({ placeholder: 'Write something …', }),