feat:open hyperlink shortcut
This commit is contained in:
Vendored
+1
@@ -11,6 +11,7 @@
|
|||||||
"dppx",
|
"dppx",
|
||||||
"inputarea",
|
"inputarea",
|
||||||
"linebreak",
|
"linebreak",
|
||||||
|
"noopener",
|
||||||
"prismjs",
|
"prismjs",
|
||||||
"resizer",
|
"resizer",
|
||||||
"richtext",
|
"richtext",
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export class HyperlinkParticle {
|
|||||||
hyperlinkPopupContainer.classList.add(`${EDITOR_PREFIX}-hyperlink-popup`)
|
hyperlinkPopupContainer.classList.add(`${EDITOR_PREFIX}-hyperlink-popup`)
|
||||||
const hyperlinkDom = document.createElement('a')
|
const hyperlinkDom = document.createElement('a')
|
||||||
hyperlinkDom.target = '_blank'
|
hyperlinkDom.target = '_blank'
|
||||||
|
hyperlinkDom.rel = 'noopener'
|
||||||
hyperlinkPopupContainer.append(hyperlinkDom)
|
hyperlinkPopupContainer.append(hyperlinkDom)
|
||||||
this.container.append(hyperlinkPopupContainer)
|
this.container.append(hyperlinkPopupContainer)
|
||||||
return { hyperlinkPopupContainer, hyperlinkDom }
|
return { hyperlinkPopupContainer, hyperlinkDom }
|
||||||
@@ -51,6 +52,13 @@ export class HyperlinkParticle {
|
|||||||
this.hyperlinkPopupContainer.style.display = 'none'
|
this.hyperlinkPopupContainer.style.display = 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public openHyperlink(element: IElement) {
|
||||||
|
const newTab = window.open(element.url, '_blank')
|
||||||
|
if (newTab) {
|
||||||
|
newTab.opener = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public render(ctx: CanvasRenderingContext2D, element: IRowElement, x: number, y: number) {
|
public render(ctx: CanvasRenderingContext2D, element: IRowElement, x: number, y: number) {
|
||||||
ctx.save()
|
ctx.save()
|
||||||
ctx.font = element.style
|
ctx.font = element.style
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ElementType } from '../../../dataset/enum/Element'
|
import { ElementType } from '../../../dataset/enum/Element'
|
||||||
import { MouseEventButton } from '../../../dataset/enum/Event'
|
import { MouseEventButton } from '../../../dataset/enum/Event'
|
||||||
import { deepClone } from '../../../utils'
|
import { deepClone } from '../../../utils'
|
||||||
|
import { isMod } from '../../../utils/hotkey'
|
||||||
import { CheckboxControl } from '../../draw/control/checkbox/CheckboxControl'
|
import { CheckboxControl } from '../../draw/control/checkbox/CheckboxControl'
|
||||||
import { CanvasEvent } from '../CanvasEvent'
|
import { CanvasEvent } from '../CanvasEvent'
|
||||||
|
|
||||||
@@ -106,8 +107,12 @@ export function mousedown(evt: MouseEvent, host: CanvasEvent) {
|
|||||||
const hyperlinkParticle = draw.getHyperlinkParticle()
|
const hyperlinkParticle = draw.getHyperlinkParticle()
|
||||||
hyperlinkParticle.clearHyperlinkPopup()
|
hyperlinkParticle.clearHyperlinkPopup()
|
||||||
if (curElement.type === ElementType.HYPERLINK) {
|
if (curElement.type === ElementType.HYPERLINK) {
|
||||||
|
if (isMod(evt)) {
|
||||||
|
hyperlinkParticle.openHyperlink(curElement)
|
||||||
|
} else {
|
||||||
hyperlinkParticle.drawHyperlinkPopup(curElement, positionList[curIndex])
|
hyperlinkParticle.drawHyperlinkPopup(curElement, positionList[curIndex])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 日期控件
|
// 日期控件
|
||||||
const dateParticle = draw.getDateParticle()
|
const dateParticle = draw.getDateParticle()
|
||||||
dateParticle.clearDatePicker()
|
dateParticle.clearDatePicker()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { isApple } from './ua'
|
import { isApple } from './ua'
|
||||||
|
|
||||||
export function isMod(evt: KeyboardEvent) {
|
export function isMod(evt: KeyboardEvent | MouseEvent) {
|
||||||
return isApple ? evt.metaKey : evt.ctrlKey
|
return isApple ? evt.metaKey : evt.ctrlKey
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user