mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-18 10:00:48 +08:00
This commit is contained in:
parent
427ec33b78
commit
31a573d90d
@ -1472,12 +1472,13 @@ export class WYSIWYG {
|
|||||||
let shiftStartElement: HTMLElement;
|
let shiftStartElement: HTMLElement;
|
||||||
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||||
hideElements(["hint", "util"], protyle);
|
hideElements(["hint", "util"], protyle);
|
||||||
|
const ctrlIsPressed = event.metaKey || event.ctrlKey
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item");
|
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item");
|
||||||
if (backlinkBreadcrumbItemElement) {
|
if (backlinkBreadcrumbItemElement) {
|
||||||
const breadcrumbId = backlinkBreadcrumbItemElement.getAttribute("data-id");
|
const breadcrumbId = backlinkBreadcrumbItemElement.getAttribute("data-id");
|
||||||
if (breadcrumbId) {
|
if (breadcrumbId) {
|
||||||
if (window.siyuan.ctrlIsPressed) {
|
if (ctrlIsPressed) {
|
||||||
openFileById({
|
openFileById({
|
||||||
id: breadcrumbId,
|
id: breadcrumbId,
|
||||||
action: breadcrumbId === protyle.block.rootID ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL]
|
action: breadcrumbId === protyle.block.rootID ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL]
|
||||||
@ -1493,7 +1494,7 @@ export class WYSIWYG {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
if (!window.siyuan.shiftIsPressed) {
|
if (!event.shiftKey) {
|
||||||
shiftStartElement = undefined;
|
shiftStartElement = undefined;
|
||||||
}
|
}
|
||||||
this.setEmptyOutline(protyle, event.target);
|
this.setEmptyOutline(protyle, event.target);
|
||||||
@ -1518,7 +1519,7 @@ export class WYSIWYG {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
hideElements(["dialog", "toolbar"], protyle);
|
hideElements(["dialog", "toolbar"], protyle);
|
||||||
if (range.toString() !== "" && !window.siyuan.shiftIsPressed) {
|
if (range.toString() !== "" && !event.shiftKey) {
|
||||||
// 选择不打开引用
|
// 选择不打开引用
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1537,21 +1538,21 @@ export class WYSIWYG {
|
|||||||
window.open(aElement.getAttribute("data-href"));
|
window.open(aElement.getAttribute("data-href"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.siyuan.shiftIsPressed) {
|
if (event.shiftKey) {
|
||||||
openFileById({
|
openFileById({
|
||||||
id: refBlockId,
|
id: refBlockId,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
||||||
zoomIn: foldResponse.data
|
zoomIn: foldResponse.data
|
||||||
});
|
});
|
||||||
} else if (window.siyuan.altIsPressed) {
|
} else if (event.altKey) {
|
||||||
openFileById({
|
openFileById({
|
||||||
id: refBlockId,
|
id: refBlockId,
|
||||||
position: "right",
|
position: "right",
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
||||||
zoomIn: foldResponse.data
|
zoomIn: foldResponse.data
|
||||||
});
|
});
|
||||||
} else if (window.siyuan.ctrlIsPressed) {
|
} else if (ctrlIsPressed) {
|
||||||
openFileById({
|
openFileById({
|
||||||
id: refBlockId,
|
id: refBlockId,
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],
|
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],
|
||||||
@ -1593,9 +1594,9 @@ export class WYSIWYG {
|
|||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
openByMobile(linkAddress);
|
openByMobile(linkAddress);
|
||||||
/// #else
|
/// #else
|
||||||
if (window.siyuan.ctrlIsPressed) {
|
if (ctrlIsPressed) {
|
||||||
openBy(linkAddress, "folder");
|
openBy(linkAddress, "folder");
|
||||||
} else if (window.siyuan.shiftIsPressed) {
|
} else if (event.shiftKey) {
|
||||||
openBy(linkAddress, "app");
|
openBy(linkAddress, "app");
|
||||||
} else {
|
} else {
|
||||||
openAsset(linkAddress, fileIds[2], "right");
|
openAsset(linkAddress, fileIds[2], "right");
|
||||||
@ -1604,7 +1605,7 @@ export class WYSIWYG {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aElement && !window.siyuan.altIsPressed) {
|
if (aElement && !event.altKey) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const linkAddress = aElement.getAttribute("data-href");
|
const linkAddress = aElement.getAttribute("data-href");
|
||||||
@ -1617,16 +1618,16 @@ export class WYSIWYG {
|
|||||||
(!linkPathname.endsWith(".pdf") ||
|
(!linkPathname.endsWith(".pdf") ||
|
||||||
(linkPathname.endsWith(".pdf") && !linkAddress.startsWith("file://")))
|
(linkPathname.endsWith(".pdf") && !linkAddress.startsWith("file://")))
|
||||||
) {
|
) {
|
||||||
if (window.siyuan.ctrlIsPressed) {
|
if (ctrlIsPressed) {
|
||||||
openBy(linkAddress, "folder");
|
openBy(linkAddress, "folder");
|
||||||
} else if (window.siyuan.shiftIsPressed) {
|
} else if (event.shiftKey) {
|
||||||
openBy(linkAddress, "app");
|
openBy(linkAddress, "app");
|
||||||
} else {
|
} else {
|
||||||
openAsset(linkPathname, parseInt(getSearch("page", linkAddress)), "right");
|
openAsset(linkPathname, parseInt(getSearch("page", linkAddress)), "right");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
if (window.siyuan.ctrlIsPressed) {
|
if (ctrlIsPressed) {
|
||||||
openBy(linkAddress, "folder");
|
openBy(linkAddress, "folder");
|
||||||
} else {
|
} else {
|
||||||
openBy(linkAddress, "app");
|
openBy(linkAddress, "app");
|
||||||
@ -1650,8 +1651,8 @@ export class WYSIWYG {
|
|||||||
|
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
const tagElement = hasClosestByAttribute(event.target, "data-type", "tag");
|
const tagElement = hasClosestByAttribute(event.target, "data-type", "tag");
|
||||||
if (tagElement && !window.siyuan.altIsPressed && protyle.model) {
|
if (tagElement && !event.altKey && protyle.model) {
|
||||||
openGlobalSearch(`#${tagElement.textContent}#`, !window.siyuan.ctrlIsPressed);
|
openGlobalSearch(`#${tagElement.textContent}#`, !ctrlIsPressed);
|
||||||
hideElements(["dialog"]);
|
hideElements(["dialog"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1663,21 +1664,21 @@ export class WYSIWYG {
|
|||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
openMobileFileById(embedId, [Constants.CB_GET_ALL]);
|
openMobileFileById(embedId, [Constants.CB_GET_ALL]);
|
||||||
/// #else
|
/// #else
|
||||||
if (window.siyuan.shiftIsPressed) {
|
if (event.shiftKey) {
|
||||||
openFileById({
|
openFileById({
|
||||||
id: embedId,
|
id: embedId,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],
|
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],
|
||||||
zoomIn: true
|
zoomIn: true
|
||||||
});
|
});
|
||||||
} else if (window.siyuan.altIsPressed) {
|
} else if (event.altKey) {
|
||||||
openFileById({
|
openFileById({
|
||||||
id: embedId,
|
id: embedId,
|
||||||
position: "right",
|
position: "right",
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],
|
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],
|
||||||
zoomIn: true
|
zoomIn: true
|
||||||
});
|
});
|
||||||
} else if (window.siyuan.ctrlIsPressed) {
|
} else if (ctrlIsPressed) {
|
||||||
openFileById({
|
openFileById({
|
||||||
id: embedId,
|
id: embedId,
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],
|
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL],
|
||||||
@ -1767,7 +1768,7 @@ export class WYSIWYG {
|
|||||||
|
|
||||||
// 需放在属性后,否则数学公式无法点击属性;需放在 action 后,否则嵌入块的的 action 无法打开;需放在嵌入块后,否则嵌入块中的数学公式会被打开
|
// 需放在属性后,否则数学公式无法点击属性;需放在 action 后,否则嵌入块的的 action 无法打开;需放在嵌入块后,否则嵌入块中的数学公式会被打开
|
||||||
const mathElement = hasClosestByAttribute(event.target, "data-subtype", "math");
|
const mathElement = hasClosestByAttribute(event.target, "data-subtype", "math");
|
||||||
if (!window.siyuan.shiftIsPressed && !window.siyuan.ctrlIsPressed && mathElement && !protyle.disabled) {
|
if (!event.shiftKey && !ctrlIsPressed && mathElement && !protyle.disabled) {
|
||||||
protyle.toolbar.showRender(protyle, mathElement);
|
protyle.toolbar.showRender(protyle, mathElement);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return;
|
return;
|
||||||
@ -1782,7 +1783,7 @@ export class WYSIWYG {
|
|||||||
clientY: event.clientY
|
clientY: event.clientY
|
||||||
});
|
});
|
||||||
} else if (!protyle.disabled && actionElement.parentElement.classList.contains("li")) {
|
} else if (!protyle.disabled && actionElement.parentElement.classList.contains("li")) {
|
||||||
if (window.siyuan.altIsPressed) {
|
if (event.altKey) {
|
||||||
// 展开/折叠当前层级的所有列表项
|
// 展开/折叠当前层级的所有列表项
|
||||||
if (actionElement.parentElement.parentElement.classList.contains("protyle-wysiwyg")) {
|
if (actionElement.parentElement.parentElement.classList.contains("protyle-wysiwyg")) {
|
||||||
// 缩放列表项 https://ld246.com/article/1653123034794
|
// 缩放列表项 https://ld246.com/article/1653123034794
|
||||||
@ -1810,9 +1811,9 @@ export class WYSIWYG {
|
|||||||
updateTransaction(protyle, actionElement.parentElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.parentElement.outerHTML, oldHTML);
|
updateTransaction(protyle, actionElement.parentElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.parentElement.outerHTML, oldHTML);
|
||||||
}
|
}
|
||||||
hideElements(["gutter"], protyle);
|
hideElements(["gutter"], protyle);
|
||||||
} else if (window.siyuan.shiftIsPressed) {
|
} else if (event.shiftKey) {
|
||||||
openAttr(actionElement.parentElement, protyle);
|
openAttr(actionElement.parentElement, protyle);
|
||||||
} else if (window.siyuan.ctrlIsPressed) {
|
} else if (ctrlIsPressed) {
|
||||||
zoomOut(protyle, actionElement.parentElement.getAttribute("data-node-id"));
|
zoomOut(protyle, actionElement.parentElement.getAttribute("data-node-id"));
|
||||||
} else {
|
} else {
|
||||||
if (actionElement.classList.contains("protyle-action--task")) {
|
if (actionElement.classList.contains("protyle-action--task")) {
|
||||||
@ -1841,14 +1842,14 @@ export class WYSIWYG {
|
|||||||
|
|
||||||
const selectElement = hasClosestByClassName(event.target, "hr") ||
|
const selectElement = hasClosestByClassName(event.target, "hr") ||
|
||||||
hasClosestByClassName(event.target, "iframe");
|
hasClosestByClassName(event.target, "iframe");
|
||||||
if (!window.siyuan.shiftIsPressed && !window.siyuan.ctrlIsPressed && selectElement) {
|
if (!event.shiftKey && !ctrlIsPressed && selectElement) {
|
||||||
selectElement.classList.add("protyle-wysiwyg--select");
|
selectElement.classList.add("protyle-wysiwyg--select");
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const imgElement = hasTopClosestByClassName(event.target, "img");
|
const imgElement = hasTopClosestByClassName(event.target, "img");
|
||||||
if (!window.siyuan.shiftIsPressed && !window.siyuan.ctrlIsPressed && imgElement) {
|
if (!event.shiftKey && !ctrlIsPressed && imgElement) {
|
||||||
imgElement.classList.add("img--select");
|
imgElement.classList.add("img--select");
|
||||||
range.setStartAfter(imgElement);
|
range.setStartAfter(imgElement);
|
||||||
range.collapse(true);
|
range.collapse(true);
|
||||||
@ -1907,7 +1908,7 @@ export class WYSIWYG {
|
|||||||
/// #endif
|
/// #endif
|
||||||
}, (isMobile() || window.webkit?.messageHandlers) ? 520 : 0); // Android/iPad 双击慢了出不来
|
}, (isMobile() || window.webkit?.messageHandlers) ? 520 : 0); // Android/iPad 双击慢了出不来
|
||||||
protyle.hint.enableExtend = false;
|
protyle.hint.enableExtend = false;
|
||||||
if (window.siyuan.shiftIsPressed) {
|
if (event.shiftKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// shift 多选
|
// shift 多选
|
||||||
@ -2016,7 +2017,7 @@ export class WYSIWYG {
|
|||||||
focusByRange(range);
|
focusByRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.siyuan.ctrlIsPressed) {
|
if (ctrlIsPressed) {
|
||||||
let ctrlElement = hasClosestBlock(event.target);
|
let ctrlElement = hasClosestBlock(event.target);
|
||||||
if (ctrlElement) {
|
if (ctrlElement) {
|
||||||
ctrlElement = getTopAloneElement(ctrlElement) as HTMLElement;
|
ctrlElement = getTopAloneElement(ctrlElement) as HTMLElement;
|
||||||
|
Loading…
Reference in New Issue
Block a user