add paste to minting key

This commit is contained in:
AlphaX-Projects 2023-04-02 15:11:20 +02:00 committed by GitHub
parent 6cb927d42f
commit 70c61f264a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,8 +36,9 @@ class NodeManagement extends LitElement {
tempMintingAccount: { type: Object }, tempMintingAccount: { type: Object },
nodeConfig: { type: Object }, nodeConfig: { type: Object },
nodeDomain: { type: String }, nodeDomain: { type: String },
myElementId: { type: String },
theme: { type: String, reflect: true } theme: { type: String, reflect: true }
}; }
} }
static get styles() { static get styles() {
@ -124,27 +125,28 @@ class NodeManagement extends LitElement {
} }
constructor() { constructor() {
super(); super()
this.upTime = ""; this.upTime = ""
this.mintingAccounts = []; this.mintingAccounts = []
this.peers = []; this.peers = []
this.addPeerLoading = false; this.addPeerLoading = false
this.confPeerLoading = false; this.confPeerLoading = false
this.addMintingAccountLoading = false; this.addMintingAccountLoading = false
this.removeMintingAccountLoading = false; this.removeMintingAccountLoading = false
this.addMintingAccountKey = ""; this.addMintingAccountKey = ""
this.addPeerMessage = ""; this.addPeerMessage = ""
this.confPeerMessage = ""; this.confPeerMessage = ""
this.addMintingAccountMessage = ""; this.addMintingAccountMessage = ""
this.tempMintingAccount = {}; this.tempMintingAccount = {}
this.config = { this.config = {
user: { user: {
node: {}, node: {},
}, },
}; };
this.nodeConfig = {}; this.nodeConfig = {}
this.nodeDomain = ""; this.nodeDomain = ""
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'; this.myElementId = ''
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
} }
render() { render() {
@ -285,13 +287,16 @@ class NodeManagement extends LitElement {
// Call updateMintingAccounts // Call updateMintingAccounts
this.updateMintingAccounts() this.updateMintingAccounts()
window.addEventListener("contextmenu", (event) => { window.addEventListener('contextmenu', (event) => {
event.preventDefault(); event.preventDefault()
this.isTextMenuOpen = true
this._textMenu(event) this._textMenu(event)
}) })
window.addEventListener("click", () => { window.addEventListener('click', () => {
if (this.isTextMenuOpen) {
parentEpml.request('closeCopyTextMenu', null) parentEpml.request('closeCopyTextMenu', null)
}
}) })
window.addEventListener('storage', () => { window.addEventListener('storage', () => {
@ -309,8 +314,35 @@ class NodeManagement extends LitElement {
}) })
window.onkeyup = (e) => { window.onkeyup = (e) => {
if (e.keyCode === 27) parentEpml.request('closeCopyTextMenu', null) if (e.keyCode === 27) {
parentEpml.request('closeCopyTextMenu', null)
} }
}
this.shadowRoot.getElementById('addMintingAccountKey').addEventListener('contextmenu', (event) => {
const getSelectedText = () => {
var text = ''
if (typeof window.getSelection != 'undefined') {
text = window.getSelection().toString()
} else if (typeof this.shadowRoot.selection != 'undefined' && this.shadowRoot.selection.type == 'Text') {
text = this.shadowRoot.selection.createRange().text
}
return text
}
const checkSelectedTextAndShowMenu = () => {
let selectedText = getSelectedText()
if (selectedText && typeof selectedText === 'string') {
} else {
this.myElementId = ''
this.pasteMenu(event, 'addMintingAccountKey')
this.myElementId = this.shadowRoot.getElementById('addMintingAccountKey')
this.isPasteMenuOpen = true
event.preventDefault()
event.stopPropagation()
}
}
checkSelectedTextAndShowMenu()
})
// Calculate HH MM SS from Milliseconds... // Calculate HH MM SS from Milliseconds...
const convertMsToTime = (milliseconds) => { const convertMsToTime = (milliseconds) => {
@ -369,7 +401,8 @@ class NodeManagement extends LitElement {
setTimeout(getNodeConfig, 1000); setTimeout(getNodeConfig, 1000);
}; };
let configLoaded = false; let configLoaded = false
parentEpml.ready().then(() => { parentEpml.ready().then(() => {
parentEpml.subscribe("config", async c => { parentEpml.subscribe("config", async c => {
if (!configLoaded) { if (!configLoaded) {
@ -381,11 +414,23 @@ class NodeManagement extends LitElement {
} }
this.config = JSON.parse(c); this.config = JSON.parse(c);
}) })
parentEpml.subscribe('copy_menu_switch', async value => {
if (value === 'false' && window.getSelection().toString().length !== 0) this.clearSelection(); parentEpml.subscribe('copy_menu_switch', async (value) => {
if (value === 'false' && this.isTextMenuOpen === true) {
this.clearSelection()
this.isTextMenuOpen = false
}
}) })
});
parentEpml.imReady(); parentEpml.subscribe('frame_paste_menu_switch', async res => {
res = JSON.parse(res)
if (res.isOpen === false && this.isPasteMenuOpen === true) {
this.pasteToTextBox(this.myElementId)
this.isPasteMenuOpen = false
}
})
})
parentEpml.imReady()
} }
changeTheme() { changeTheme() {
@ -513,22 +558,33 @@ class NodeManagement extends LitElement {
}); });
} }
_textMenu(event) { pasteToTextBox(elementId) {
window.focus()
const getSelectedText = () => { navigator.clipboard.readText().then((clipboardText) => {
var text = ""; elementId.value += clipboardText
if (typeof window.getSelection != "undefined") { elementId.focus()
text = window.getSelection().toString(); })
} else if (typeof this.shadowRoot.selection != "undefined" && this.shadowRoot.selection.type == "Text") {
text = this.shadowRoot.selection.createRange().text;
} }
return text;
pasteMenu(event, elementId) {
let eventObject = { pageX: event.pageX, pageY: event.pageY, clientX: event.clientX, clientY: event.clientY, elementId }
parentEpml.request('openFramePasteMenu', eventObject)
}
_textMenu(event) {
const getSelectedText = () => {
var text = ''
if (typeof window.getSelection != 'undefined') {
text = window.getSelection().toString()
} else if (typeof this.shadowRoot.selection != 'undefined' && this.shadowRoot.selection.type == 'Text') {
text = this.shadowRoot.selection.createRange().text
}
return text
} }
const checkSelectedTextAndShowMenu = () => { const checkSelectedTextAndShowMenu = () => {
let selectedText = getSelectedText(); let selectedText = getSelectedText()
if (selectedText && typeof selectedText === 'string') { if (selectedText && typeof selectedText === 'string') {
let _eve = { pageX: event.pageX, pageY: event.pageY, clientX: event.clientX, clientY: event.clientY } let _eve = { pageX: event.pageX, pageY: event.pageY, clientX: event.clientX, clientY: event.clientY }
let textMenuObject = { selectedText: selectedText, eventObject: _eve, isFrame: true } let textMenuObject = { selectedText: selectedText, eventObject: _eve, isFrame: true }
@ -536,7 +592,6 @@ class NodeManagement extends LitElement {
parentEpml.request('openCopyTextMenu', textMenuObject) parentEpml.request('openCopyTextMenu', textMenuObject)
} }
} }
checkSelectedTextAndShowMenu() checkSelectedTextAndShowMenu()
} }