diff --git a/src/components/LinkItems/SubItem.vue b/src/components/LinkItems/SubItem.vue index 22aba4e0b7..8a80dbdf6b 100644 --- a/src/components/LinkItems/SubItem.vue +++ b/src/components/LinkItems/SubItem.vue @@ -33,7 +33,6 @@ import Icon from '@/components/LinkItems/ItemIcon.vue'; import ContextMenu from '@/components/LinkItems/ItemContextMenu'; import ItemMixin from '@/mixins/ItemMixin'; -// import { targetValidator } from '@/utils/ConfigHelpers'; export default { name: 'Item', diff --git a/src/components/PageStrcture/Nav.vue b/src/components/PageStrcture/Nav.vue index 781d776fb3..8fcc53c0ee 100644 --- a/src/components/PageStrcture/Nav.vue +++ b/src/components/PageStrcture/Nav.vue @@ -70,9 +70,10 @@ export default { switch (link.target) { case 'sametab': return '_self'; case 'newtab': return '_blank'; + case 'newwindow': return '_blank'; case 'parent': return '_parent'; case 'top': return '_top'; - default: return undefined; + default: return '_blank'; } }, }, diff --git a/src/mixins/ItemMixin.js b/src/mixins/ItemMixin.js index 0867987057..809f878023 100644 --- a/src/mixins/ItemMixin.js +++ b/src/mixins/ItemMixin.js @@ -152,6 +152,10 @@ export default { } else if (this.accumulatedTarget === 'clipboard') { e.preventDefault(); this.copyToClipboard(url); + } else if (this.accumulatedTarget === 'newwindow') { + e.preventDefault(); + const { width, height } = window.screen; + window.open(url, '_blank', `width=${width},height=${height},noopener,noreferrer`); } // Emit event to clear search field, etc this.$emit('itemClicked'); @@ -172,6 +176,12 @@ export default { case 'sametab': window.open(url, '_self'); break; + case 'parent': + window.open(url, '_parent'); + break; + case 'top': + window.open(url, '_top'); + break; case 'modal': this.$emit('triggerModal', url); break; @@ -181,9 +191,11 @@ export default { case 'clipboard': this.copyToClipboard(url); break; - case 'newwindow': - window.open(url, '_blank', 'noopener,noreferrer'); + case 'newwindow': { + const { width, height } = window.screen; + window.open(url, '_blank', `width=${width},height=${height},noopener,noreferrer`); break; + } default: window.open(url, '_blank'); } }, diff --git a/src/utils/ConfigHelpers.js b/src/utils/ConfigHelpers.js index f970c8a953..a4ceb2c0ac 100644 --- a/src/utils/ConfigHelpers.js +++ b/src/utils/ConfigHelpers.js @@ -7,8 +7,6 @@ import { localStorageKeys, language as defaultLanguage, } from '@/utils/defaults'; -import ErrorHandler from '@/utils/ErrorHandler'; -import ConfigSchema from '@/utils/ConfigSchema.json'; /* Given a page name, converts to lowercase, removes special characters and extension */ export const makePageName = (pageName) => { @@ -101,18 +99,3 @@ export const getUsersLanguage = () => { const langObj = languages.find(lang => lang.code === resolvedCode); return langObj; }; - -/** - * validator for item target attribute - * Uses enum values from config schema, and shows warning if invalid - * @param {String} target - * @returns {Boolean} isValid - */ -export const targetValidator = (target) => { - if (!target) return true; - const acceptedTargets = ConfigSchema.properties.sections.items - .properties.items.items.properties.target.enum; - const isTargetValid = acceptedTargets.indexOf(target) !== -1; - if (!isTargetValid) ErrorHandler(`Unknown target value: ${target}`); - return isTargetValid; -}; diff --git a/src/utils/ConfigSchema.json b/src/utils/ConfigSchema.json index f795576b61..5597b0d29a 100644 --- a/src/utils/ConfigSchema.json +++ b/src/utils/ConfigSchema.json @@ -146,15 +146,13 @@ }, "target": { "title": "Opening Method", - "type": ["string", "null"], + "type": "string", "enum": [ "newtab", "sametab", "parent", "top", - "newwindow", - "", - null + "newwindow" ], "default": "newtab", "description": "Where / how the item is opened when it's clicked" @@ -207,7 +205,8 @@ "top", "modal", "workspace", - "clipboard" + "clipboard", + "newwindow" ], "default": "newtab", "description": "The default opening method for items. Only used if no item.target is specified" @@ -394,7 +393,6 @@ "enum": [ "newtab", "sametab", - "modal", "workspace" ], "default": "newtab", @@ -1067,7 +1065,7 @@ }, "target": { "title": "Opening Method", - "type": ["string", "null"], + "type": "string", "enum": [ "newtab", "sametab", @@ -1076,9 +1074,7 @@ "modal", "workspace", "clipboard", - "newwindow", - "", - null + "newwindow" ], "default": "newtab", "description": "Where / how the item is opened when it's clicked" diff --git a/src/views/Workspace.vue b/src/views/Workspace.vue index 6e5f0faeb8..2599c500bc 100644 --- a/src/views/Workspace.vue +++ b/src/views/Workspace.vue @@ -19,6 +19,7 @@ import WebContent from '@/components/Workspace/WebContent'; import WidgetView from '@/components/Workspace/WidgetView'; import MultiTaskingWebComtent from '@/components/Workspace/MultiTaskingWebComtent'; import Defaults from '@/utils/defaults'; +import ErrorHandler from '@/utils/ErrorHandler'; export default { name: 'Workspace', @@ -49,12 +50,14 @@ export default { if (options.target === 'newtab') { window.open(options.url, '_blank'); } else if (options.target === 'newwindow') { - window.open(options.url, '_blank', 'noopener,noreferrer'); + const { width, height } = window.screen; + window.open(options.url, '_blank', `width=${width},height=${height},noopener,noreferrer`); } else if (options.target === 'clipboard') { if (navigator.clipboard) { navigator.clipboard.writeText(options.url); this.$toasted.show(this.$t('context-menus.item.copied-toast'), { className: 'toast-success' }); } else { + ErrorHandler('Clipboard access requires HTTPS. See: https://bit.ly/3N5WuAA'); this.$toasted.show('Unable to copy, see log', { className: 'toast-error' }); } return;