mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-11-01 21:27:51 +00:00
Change to general copy paste
This commit is contained in:
@@ -11,12 +11,12 @@ const options = {
|
||||
}
|
||||
|
||||
const aliases = {
|
||||
'qortal-ui-crypto': 'node_modules/qortal-ui-crypto/api.js'
|
||||
'qortal-ui-crypto': '../../crypto/api.js'
|
||||
}
|
||||
|
||||
const apiComponents = {
|
||||
api: {
|
||||
file: 'api/api.js',
|
||||
file: '../../crypto/api.js',
|
||||
className: 'api'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { installRouter } from 'pwa-helpers/router.js'
|
||||
import { connect } from 'pwa-helpers'
|
||||
import { store } from '../store.js'
|
||||
import { doNavigate } from '../redux/app/app-actions.js'
|
||||
import isElectron from 'is-electron'
|
||||
import '../plugins/streams.js'
|
||||
|
||||
import { loadPlugins } from '../plugins/load-plugins.js'
|
||||
@@ -11,9 +12,6 @@ import '../styles/app-styles.js'
|
||||
import './login-view/login-view.js'
|
||||
import './app-view.js'
|
||||
|
||||
import copyTextMenu from '../functional-components/copy-text-menu.js'
|
||||
import framePasteMenu from '../functional-components/frame-paste-menu.js'
|
||||
|
||||
installRouter((location) => store.dispatch(doNavigate(location)))
|
||||
|
||||
class MainApp extends connect(store)(LitElement) {
|
||||
@@ -66,46 +64,14 @@ class MainApp extends connect(store)(LitElement) {
|
||||
super.connectedCallback()
|
||||
this.initial = 0
|
||||
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault();
|
||||
this._textMenu(event);
|
||||
})
|
||||
|
||||
window.addEventListener('click', () => {
|
||||
copyTextMenu.close()
|
||||
framePasteMenu.close()
|
||||
})
|
||||
|
||||
window.onkeyup = (e) => {
|
||||
if (e.keyCode === 27) {
|
||||
copyTextMenu.close()
|
||||
framePasteMenu.close()
|
||||
}
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
_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 selectedText = getSelectedText()
|
||||
if (selectedText && typeof selectedText === 'string') {
|
||||
|
||||
const textMenuObject = { selectedText, eventObject: event }
|
||||
copyTextMenu.open(textMenuObject)
|
||||
}
|
||||
}
|
||||
|
||||
checkSelectedTextAndShowMenu()
|
||||
}
|
||||
}
|
||||
|
||||
window.customElements.define('main-app', MainApp)
|
||||
|
||||
@@ -10,7 +10,8 @@ class ShowPlugin extends connect(store)(LitElement) {
|
||||
app: { type: Object },
|
||||
pluginConfig: { type: Object },
|
||||
url: { type: String },
|
||||
linkParam: { type: String }
|
||||
linkParam: { type: String },
|
||||
registeredUrls: { type: Array }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +51,19 @@ class ShowPlugin extends connect(store)(LitElement) {
|
||||
`
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.registeredUrls = []
|
||||
}
|
||||
|
||||
render() {
|
||||
const plugArr = []
|
||||
|
||||
const plugSrc = (myPlug) => {
|
||||
return myPlug === undefined ? 'about:blank' : `${window.location.origin}/plugin/${myPlug.domain}/${myPlug.page}${this.linkParam}`
|
||||
}
|
||||
|
||||
const plugArr = []
|
||||
this.app.registeredUrls.forEach(myPlugArr => {
|
||||
this.registeredUrls.forEach(myPlugArr => {
|
||||
myPlugArr.menus.length === 0 ? plugArr.push(myPlugArr) : myPlugArr.menus.forEach(i => plugArr.push(myPlugArr, i))
|
||||
})
|
||||
|
||||
@@ -75,6 +82,7 @@ class ShowPlugin extends connect(store)(LitElement) {
|
||||
type: 'WINDOW',
|
||||
source: this.shadowRoot.getElementById('showPluginFrame').contentWindow
|
||||
})
|
||||
|
||||
addPluginRoutes(showingPluginEpml)
|
||||
showingPluginEpml.imReady()
|
||||
this.showingPluginEpml = showingPluginEpml
|
||||
@@ -94,23 +102,35 @@ class ShowPlugin extends connect(store)(LitElement) {
|
||||
}
|
||||
|
||||
stateChanged(state) {
|
||||
this.app = state.app
|
||||
this.config = state.config
|
||||
|
||||
const split = state.app.url.split('/')
|
||||
const newRegisteredUrls = state.app.registeredUrls
|
||||
|
||||
let newUrl, newLinkParam
|
||||
|
||||
if (newRegisteredUrls !== this.registeredUrls) {
|
||||
this.registeredUrls = newRegisteredUrls
|
||||
}
|
||||
|
||||
if (split[0] === '' && split[1] === 'app' && split[2] === undefined) {
|
||||
this.url = 'wallet'
|
||||
this.linkParam = ''
|
||||
newUrl = 'wallet'
|
||||
newLinkParam = ''
|
||||
} else if (split.length === 5 && split[1] === 'app') {
|
||||
this.url = split[2]
|
||||
this.linkParam = split[3] === undefined ? '' : '?' + split[3] + '/' + split[4]
|
||||
newUrl = split[2]
|
||||
newLinkParam = split[3] === undefined ? '' : '?' + split[3] + '/' + split[4]
|
||||
} else if (split[1] === 'app') {
|
||||
this.url = split[2]
|
||||
this.linkParam = ''
|
||||
newUrl = split[2]
|
||||
newLinkParam = ''
|
||||
} else {
|
||||
this.url = '404'
|
||||
this.linkParam = ''
|
||||
newUrl = '404'
|
||||
newLinkParam = ''
|
||||
}
|
||||
|
||||
if (newUrl !== this.url) {
|
||||
this.url = newUrl
|
||||
}
|
||||
|
||||
if (newLinkParam !== this.linkParam) {
|
||||
this.linkParam = newLinkParam
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ import {
|
||||
loadStateFromLocalStorage,
|
||||
saveStateToLocalStorage,
|
||||
} from '../localStorageHelpers.js'
|
||||
import copyTextMenu from '../functional-components/copy-text-menu.js'
|
||||
import framePasteMenu from '../functional-components/frame-paste-menu.js'
|
||||
|
||||
const createTransaction = api.createTransaction
|
||||
const processTransaction = api.processTransaction
|
||||
@@ -39,10 +37,6 @@ const sendRvn = api.sendRvn
|
||||
const sendArrr = api.sendArrr
|
||||
|
||||
export const routes = {
|
||||
hello: async (req) => {
|
||||
return 'Hello from awesomeness'
|
||||
},
|
||||
|
||||
registerUrl: async (req) => {
|
||||
store.dispatch(doAddPluginUrl(req.data))
|
||||
},
|
||||
@@ -95,27 +89,6 @@ export const routes = {
|
||||
return saveStateToLocalStorage(req.data.key, req.data.dataObj)
|
||||
},
|
||||
|
||||
openCopyTextMenu: async (req) => {
|
||||
const textMenuObject = {
|
||||
selectedText: req.data.selectedText,
|
||||
eventObject: req.data.eventObject,
|
||||
isFrame: req.data.isFrame,
|
||||
}
|
||||
copyTextMenu.open(textMenuObject)
|
||||
},
|
||||
|
||||
closeCopyTextMenu: async (req) => {
|
||||
copyTextMenu.close()
|
||||
},
|
||||
|
||||
openFramePasteMenu: async (req) => {
|
||||
framePasteMenu.open(req.data)
|
||||
},
|
||||
|
||||
closeFramePasteMenu: async (req) => {
|
||||
framePasteMenu.close()
|
||||
},
|
||||
|
||||
apiCall: async (req) => {
|
||||
const url = req.data.url
|
||||
delete req.data.url
|
||||
|
||||
@@ -7,8 +7,6 @@ const SELECTED_ADDRESS_STREAM_NAME = 'selected_address'
|
||||
const APP_INFO_STATE = 'app_info_state'
|
||||
const CHAT_HEADS_STREAM_NAME = 'chat_heads'
|
||||
const NODE_CONFIG_STREAM_NAME = 'node_config'
|
||||
const COPY_MENU_SWITCH = 'copy_menu_switch'
|
||||
const FRAME_PASTE_MENU_SWITCH = 'frame_paste_menu_switch'
|
||||
const CHAT_LAST_SEEN = 'chat_last_seen'
|
||||
|
||||
export const loggedInStream = new EpmlStream(LOGIN_STREAM_NAME, () => store.getState().app.loggedIn)
|
||||
@@ -17,8 +15,6 @@ export const selectedAddressStream = new EpmlStream(SELECTED_ADDRESS_STREAM_NAME
|
||||
export const appInfoStateStream = new EpmlStream(APP_INFO_STATE, () => store.getState().app.appInfo)
|
||||
export const chatHeadsStateStream = new EpmlStream(CHAT_HEADS_STREAM_NAME, () => store.getState().app.chatHeads)
|
||||
export const nodeConfigStream = new EpmlStream(NODE_CONFIG_STREAM_NAME, () => store.getState().app.nodeConfig)
|
||||
export const copyMenuSwitchStream = new EpmlStream(COPY_MENU_SWITCH, () => store.getState().app.copyMenuSwitch)
|
||||
export const framePasteMenuSwitchStream = new EpmlStream(FRAME_PASTE_MENU_SWITCH, () => store.getState().app.framePasteMenuSwitch)
|
||||
export const chatLastSeenStream = new EpmlStream(CHAT_LAST_SEEN, () => store.getState().app.chatLastSeen)
|
||||
|
||||
|
||||
@@ -32,7 +28,7 @@ store.subscribe(() => {
|
||||
if (oldState.app.loggedIn !== state.app.loggedIn) {
|
||||
loggedInStream.emit(state.app.loggedIn)
|
||||
}
|
||||
// This one may be a little on the heavy side...AHHH, NEED TO MOVE STORAGE OF ENCRYPTED SEED. DONE <3
|
||||
|
||||
if (oldState.config !== state.config) {
|
||||
configStream.emit(state.config)
|
||||
}
|
||||
@@ -41,13 +37,6 @@ store.subscribe(() => {
|
||||
nodeConfigStream.emit(state.app.nodeConfig)
|
||||
}
|
||||
|
||||
if (oldState.app.copyMenuSwitch !== state.app.copyMenuSwitch) {
|
||||
copyMenuSwitchStream.emit(state.app.copyMenuSwitch)
|
||||
}
|
||||
|
||||
if (oldState.app.framePasteMenuSwitch !== state.app.framePasteMenuSwitch) {
|
||||
framePasteMenuSwitchStream.emit(state.app.framePasteMenuSwitch)
|
||||
}
|
||||
if (oldState.app.chatLastSeen !== state.app.chatLastSeen) {
|
||||
chatLastSeenStream.emit(state.app.chatLastSeen)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Core App Actions here...
|
||||
import { UPDATE_BLOCK_INFO, UPDATE_NODE_STATUS, UPDATE_NODE_INFO, CHAT_HEADS, ACCOUNT_INFO, COPY_MENU_SWITCH, PASTE_MENU_SWITCH, FRAME_PASTE_MENU_SWITCH, ADD_AUTO_LOAD_IMAGES_CHAT, REMOVE_AUTO_LOAD_IMAGES_CHAT, ALLOW_QAPP_AUTO_AUTH, REMOVE_QAPP_AUTO_AUTH, SET_CHAT_LAST_SEEN, ADD_CHAT_LAST_SEEN, ALLOW_QAPP_AUTO_LISTS, REMOVE_QAPP_AUTO_LISTS } from '../app-action-types.js'
|
||||
import { UPDATE_BLOCK_INFO, UPDATE_NODE_STATUS, UPDATE_NODE_INFO, CHAT_HEADS, ACCOUNT_INFO, ADD_AUTO_LOAD_IMAGES_CHAT, REMOVE_AUTO_LOAD_IMAGES_CHAT, ALLOW_QAPP_AUTO_AUTH, REMOVE_QAPP_AUTO_AUTH, SET_CHAT_LAST_SEEN, ADD_CHAT_LAST_SEEN, ALLOW_QAPP_AUTO_LISTS, REMOVE_QAPP_AUTO_LISTS } from '../app-action-types.js'
|
||||
|
||||
export const doUpdateBlockInfo = (blockObj) => {
|
||||
return (dispatch, getState) => {
|
||||
@@ -66,46 +66,6 @@ const updateAccountInfo = (payload) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const doCopyMenuSwitch = (value) => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(copyMenuSwitch(value))
|
||||
}
|
||||
}
|
||||
|
||||
const copyMenuSwitch = (payload) => {
|
||||
return {
|
||||
type: COPY_MENU_SWITCH,
|
||||
payload
|
||||
}
|
||||
}
|
||||
|
||||
export const doPasteMenuSwitch = (value) => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(pasteMenuSwitch(value))
|
||||
}
|
||||
}
|
||||
|
||||
const pasteMenuSwitch = (payload) => {
|
||||
return {
|
||||
type: PASTE_MENU_SWITCH,
|
||||
payload
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const doFramePasteMenuSwitch = (value) => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(framePasteMenuSwitch(value))
|
||||
}
|
||||
}
|
||||
|
||||
const framePasteMenuSwitch = (payload) => {
|
||||
return {
|
||||
type: FRAME_PASTE_MENU_SWITCH,
|
||||
payload
|
||||
}
|
||||
}
|
||||
|
||||
export const addAutoLoadImageChat = (payload) => {
|
||||
return {
|
||||
type: ADD_AUTO_LOAD_IMAGES_CHAT,
|
||||
|
||||
@@ -17,9 +17,6 @@ export const PAGE_URL = 'PAGE_URL'
|
||||
export const CHAT_HEADS = 'CHAT_HEADS'
|
||||
export const ACCOUNT_INFO = 'ACCOUNT_INFO'
|
||||
export const ADD_NEW_PLUGIN_URL = 'ADD_NEW_PLUGIN_URL'
|
||||
export const COPY_MENU_SWITCH = 'COPY_MENU_SWITCH'
|
||||
export const PASTE_MENU_SWITCH = 'PASTE_MENU_SWITCH'
|
||||
export const FRAME_PASTE_MENU_SWITCH = 'FRAME_PASTE_MENU_SWITCH'
|
||||
export const ADD_AUTO_LOAD_IMAGES_CHAT = 'ADD_AUTO_LOAD_IMAGES_CHAT'
|
||||
export const REMOVE_AUTO_LOAD_IMAGES_CHAT = 'REMOVE_AUTO_LOAD_IMAGES_CHAT'
|
||||
export const ALLOW_QAPP_AUTO_AUTH = 'ALLOW_QAPP_AUTO_AUTH'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Loading state, login state, isNavDrawOpen state etc. None of this needs to be saved to localstorage.
|
||||
import { loadStateFromLocalStorage, saveStateToLocalStorage } from '../../localStorageHelpers.js'
|
||||
import { LOG_IN, LOG_OUT, NETWORK_CONNECTION_STATUS, INIT_WORKERS, ADD_PLUGIN_URL, ADD_PLUGIN, ADD_NEW_PLUGIN_URL, NAVIGATE, SELECT_ADDRESS, ACCOUNT_INFO, CHAT_HEADS, UPDATE_BLOCK_INFO, UPDATE_NODE_STATUS, UPDATE_NODE_INFO, LOAD_NODE_CONFIG, SET_NODE, ADD_NODE, PAGE_URL, COPY_MENU_SWITCH, PASTE_MENU_SWITCH, FRAME_PASTE_MENU_SWITCH, ADD_AUTO_LOAD_IMAGES_CHAT, REMOVE_AUTO_LOAD_IMAGES_CHAT, ALLOW_QAPP_AUTO_AUTH, REMOVE_QAPP_AUTO_AUTH, SET_CHAT_LAST_SEEN, ADD_CHAT_LAST_SEEN, ALLOW_QAPP_AUTO_LISTS, REMOVE_QAPP_AUTO_LISTS } from './app-action-types.js'
|
||||
import { LOG_IN, LOG_OUT, NETWORK_CONNECTION_STATUS, INIT_WORKERS, ADD_PLUGIN_URL, ADD_PLUGIN, ADD_NEW_PLUGIN_URL, NAVIGATE, SELECT_ADDRESS, ACCOUNT_INFO, CHAT_HEADS, UPDATE_BLOCK_INFO, UPDATE_NODE_STATUS, UPDATE_NODE_INFO, LOAD_NODE_CONFIG, SET_NODE, ADD_NODE, PAGE_URL, ADD_AUTO_LOAD_IMAGES_CHAT, REMOVE_AUTO_LOAD_IMAGES_CHAT, ALLOW_QAPP_AUTO_AUTH, REMOVE_QAPP_AUTO_AUTH, SET_CHAT_LAST_SEEN, ADD_CHAT_LAST_SEEN, ALLOW_QAPP_AUTO_LISTS, REMOVE_QAPP_AUTO_LISTS } from './app-action-types.js'
|
||||
import { initWorkersReducer } from './reducers/init-workers.js'
|
||||
import { loginReducer } from './reducers/login-reducer.js'
|
||||
import { setNode, addNode } from './reducers/manage-node.js'
|
||||
@@ -43,12 +43,6 @@ const INITIAL_STATE = {
|
||||
nodeInfo: {},
|
||||
nodeStatus: {},
|
||||
pageUrl: '',
|
||||
copyMenuSwitch: false,
|
||||
pasteMenuSwitch: false,
|
||||
framePasteMenuSwitch: {
|
||||
isOpen: false,
|
||||
elementId: ''
|
||||
},
|
||||
autoLoadImageChats: loadStateFromLocalStorage('autoLoadImageChats') || [],
|
||||
qAPPAutoAuth: loadStateFromLocalStorage('qAPPAutoAuth') || false,
|
||||
qAPPAutoLists: loadStateFromLocalStorage('qAPPAutoLists') || false,
|
||||
@@ -141,21 +135,6 @@ export default (state = INITIAL_STATE, action) => {
|
||||
...state,
|
||||
networkIsConnected: action.payload
|
||||
}
|
||||
case COPY_MENU_SWITCH:
|
||||
return {
|
||||
...state,
|
||||
copyMenuSwitch: action.payload
|
||||
}
|
||||
case PASTE_MENU_SWITCH:
|
||||
return {
|
||||
...state,
|
||||
pasteMenuSwitch: action.payload
|
||||
}
|
||||
case FRAME_PASTE_MENU_SWITCH:
|
||||
return {
|
||||
...state,
|
||||
framePasteMenuSwitch: action.payload
|
||||
}
|
||||
case ADD_AUTO_LOAD_IMAGES_CHAT: {
|
||||
const findChat = state.autoLoadImageChats.findIndex((chat)=> chat === action.payload)
|
||||
console.log({findChat})
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { store } from '../store.js'
|
||||
import * as api from 'qortal-ui-crypto'
|
||||
import snackbar from '../functional-components/snackbar.js'
|
||||
import copyTextMenu from '../functional-components/copy-text-menu.js';
|
||||
import framePasteMenu from '../functional-components/frame-paste-menu.js';
|
||||
|
||||
const createTransaction = api.createTransaction
|
||||
const processTransaction = api.processTransaction
|
||||
@@ -25,27 +23,6 @@ export const routes = {
|
||||
return api.request(url, req.data)
|
||||
},
|
||||
|
||||
openCopyTextMenu: async (req) => {
|
||||
const textMenuObject = {
|
||||
selectedText: req.data.selectedText,
|
||||
eventObject: req.data.eventObject,
|
||||
isFrame: req.data.isFrame,
|
||||
};
|
||||
copyTextMenu.open(textMenuObject);
|
||||
},
|
||||
|
||||
closeCopyTextMenu: async (req) => {
|
||||
copyTextMenu.close();
|
||||
},
|
||||
|
||||
openFramePasteMenu: async (req) => {
|
||||
framePasteMenu.open(req.data);
|
||||
},
|
||||
|
||||
closeFramePasteMenu: async (req) => {
|
||||
framePasteMenu.close();
|
||||
},
|
||||
|
||||
transaction: async (req) => {
|
||||
let response
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user