feat:open hyperlink shortcut
This commit is contained in:
@@ -27,6 +27,7 @@ export class HyperlinkParticle {
|
||||
hyperlinkPopupContainer.classList.add(`${EDITOR_PREFIX}-hyperlink-popup`)
|
||||
const hyperlinkDom = document.createElement('a')
|
||||
hyperlinkDom.target = '_blank'
|
||||
hyperlinkDom.rel = 'noopener'
|
||||
hyperlinkPopupContainer.append(hyperlinkDom)
|
||||
this.container.append(hyperlinkPopupContainer)
|
||||
return { hyperlinkPopupContainer, hyperlinkDom }
|
||||
@@ -51,6 +52,13 @@ export class HyperlinkParticle {
|
||||
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) {
|
||||
ctx.save()
|
||||
ctx.font = element.style
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ElementType } from '../../../dataset/enum/Element'
|
||||
import { MouseEventButton } from '../../../dataset/enum/Event'
|
||||
import { deepClone } from '../../../utils'
|
||||
import { isMod } from '../../../utils/hotkey'
|
||||
import { CheckboxControl } from '../../draw/control/checkbox/CheckboxControl'
|
||||
import { CanvasEvent } from '../CanvasEvent'
|
||||
|
||||
@@ -106,7 +107,11 @@ export function mousedown(evt: MouseEvent, host: CanvasEvent) {
|
||||
const hyperlinkParticle = draw.getHyperlinkParticle()
|
||||
hyperlinkParticle.clearHyperlinkPopup()
|
||||
if (curElement.type === ElementType.HYPERLINK) {
|
||||
hyperlinkParticle.drawHyperlinkPopup(curElement, positionList[curIndex])
|
||||
if (isMod(evt)) {
|
||||
hyperlinkParticle.openHyperlink(curElement)
|
||||
} else {
|
||||
hyperlinkParticle.drawHyperlinkPopup(curElement, positionList[curIndex])
|
||||
}
|
||||
}
|
||||
// 日期控件
|
||||
const dateParticle = draw.getDateParticle()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isApple } from './ua'
|
||||
|
||||
export function isMod(evt: KeyboardEvent) {
|
||||
export function isMod(evt: KeyboardEvent | MouseEvent) {
|
||||
return isApple ? evt.metaKey : evt.ctrlKey
|
||||
}
|
||||
Reference in New Issue
Block a user