mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
This commit is contained in:
parent
879361ecdf
commit
696953a79e
6 changed files with 13 additions and 41 deletions
|
|
@ -278,7 +278,7 @@ export const keymap = {
|
|||
}
|
||||
|
||||
if (["⌘", "⇧", "⌥", "⌃"].includes(keymapStr.substr(keymapStr.length - 1, 1)) ||
|
||||
["⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦"].includes(keymapStr)) {
|
||||
["⌘A", "⌘X", "⌘C", "⌘V", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦"].includes(keymapStr)) {
|
||||
showMessage(tip + "] " + window.siyuan.languages.invalid);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export abstract class Constants {
|
|||
"222": ["'", '"'],
|
||||
};
|
||||
// "⌘", "⇧", "⌥", "⌃"
|
||||
// "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "⌃I", "⌃E", "⌃N", "⌃U" 不可自定义
|
||||
// "⌘A", "⌘X", "⌘C", "⌘V", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦" 不可自定义
|
||||
public static readonly SIYUAN_KEYMAP: IKeymap = {
|
||||
general: {
|
||||
syncNow: {default: "F9", custom: "F9"},
|
||||
|
|
@ -157,7 +157,6 @@ export abstract class Constants {
|
|||
copyProtocol: {default: "⇧⌘H", custom: "⇧⌘H"},
|
||||
copyBlockEmbed: {default: "⇧⌘E", custom: "⇧⌘E"},
|
||||
copyHPath: {default: "⇧⌘P", custom: "⇧⌘P"},
|
||||
pasteAsPlainText: {default: "⇧⌘V", custom: "⇧⌘V"},
|
||||
undo: {default: "⌘Z", custom: "⌘Z"},
|
||||
redo: {default: "⌘Y", custom: "⌘Y"},
|
||||
rename: {default: "F2", custom: "F2"},
|
||||
|
|
|
|||
|
|
@ -23,10 +23,13 @@ import {readText, writeText} from "../protyle/util/compatibility";
|
|||
import {preventScroll} from "../protyle/scroll/preventScroll";
|
||||
import {onGet} from "../protyle/util/onGet";
|
||||
import {getAllModels} from "../layout/getAll";
|
||||
import {pasteAsPlainText, pasteText} from "../protyle/util/paste";
|
||||
import {pasteText} from "../protyle/util/paste";
|
||||
/// #if !MOBILE
|
||||
import {openFileById, updateBacklinkGraph} from "../editor/util";
|
||||
/// #endif
|
||||
/// #if !BROWSER
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
/// #endif
|
||||
import {isMobile} from "../util/functions";
|
||||
import {removeFoldHeading} from "../protyle/util/heading";
|
||||
import {lineNumberRender} from "../protyle/markdown/highlightRender";
|
||||
|
|
@ -358,10 +361,10 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
/// #if !BROWSER && !MOBILE
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.pasteAsPlainText,
|
||||
accelerator: window.siyuan.config.keymap.editor.general.pasteAsPlainText.custom,
|
||||
accelerator: "⇧⌘V",
|
||||
click() {
|
||||
focusByRange(getEditorRange(nodeElement));
|
||||
pasteAsPlainText(protyle);
|
||||
getCurrentWindow().webContents.pasteAndMatchStyle();
|
||||
}
|
||||
}).element);
|
||||
/// #endif
|
||||
|
|
|
|||
|
|
@ -29,34 +29,6 @@ const filterClipboardHint = (protyle: IProtyle, textPlain: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const pasteAsPlainText = async (protyle: IProtyle) => {
|
||||
/// #if !BROWSER && !MOBILE
|
||||
let localFiles: string[] = [];
|
||||
if ("darwin" === window.siyuan.config.system.os) {
|
||||
const xmlString = clipboard.read("NSFilenamesPboardType");
|
||||
const domParser = new DOMParser();
|
||||
const xmlDom = domParser.parseFromString(xmlString, "application/xml");
|
||||
Array.from(xmlDom.getElementsByTagName("string")).forEach(item => {
|
||||
localFiles.push(item.childNodes[0].nodeValue);
|
||||
});
|
||||
} else {
|
||||
const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});
|
||||
if (xmlString.data.length > 0) {
|
||||
localFiles = xmlString.data;
|
||||
}
|
||||
}
|
||||
if (localFiles.length > 0) {
|
||||
uploadLocalFiles(localFiles, protyle, false);
|
||||
writeText("");
|
||||
} else {
|
||||
protyle.lute.SetHTMLTag2TextMark(true); // 临时设置 Lute 解析参数,行级元素键盘和下划线无法粘贴为纯文本 https://github.com/siyuan-note/siyuan/issues/6220
|
||||
const dom = protyle.lute.InlineMd2BlockDOM(clipboard.readText());
|
||||
protyle.lute.SetHTMLTag2TextMark(false);
|
||||
insertHTML(protyle.lute.BlockDOM2Content(dom), protyle);
|
||||
}
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element) => {
|
||||
const range = getEditorRange(protyle.wysiwyg.element);
|
||||
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ import {isLocalPath} from "../../util/pathName";
|
|||
/// #if !MOBILE
|
||||
import {openBy, openFileById} from "../../editor/util";
|
||||
/// #endif
|
||||
/// #if !BROWSER
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
/// #endif
|
||||
import {commonHotkey, downSelect, getStartEndElement, upSelect} from "./commonHotkey";
|
||||
import {linkMenu, refMenu, setFold, zoomOut} from "../../menus/protyle";
|
||||
import {removeEmbed} from "./removeEmbed";
|
||||
|
|
@ -56,7 +59,6 @@ import * as dayjs from "dayjs";
|
|||
import {highlightRender} from "../markdown/highlightRender";
|
||||
import {countBlockWord} from "../../layout/status";
|
||||
import {openMobileFileById} from "../../mobile/editor";
|
||||
import {pasteAsPlainText} from "../util/paste";
|
||||
import {moveToDown, moveToUp} from "./move";
|
||||
|
||||
export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
|
|
@ -1577,11 +1579,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
/// #endif
|
||||
|
||||
/// #if !BROWSER && !MOBILE
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.pasteAsPlainText.custom, event)) {
|
||||
if (matchHotKey("⇧⌘V", event)) {
|
||||
event.returnValue = false;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
pasteAsPlainText(protyle);
|
||||
getCurrentWindow().webContents.pasteAndMatchStyle();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
4
app/src/types/protyle.d.ts
vendored
4
app/src/types/protyle.d.ts
vendored
|
|
@ -147,8 +147,6 @@ declare class Lute {
|
|||
|
||||
public BlockDOM2Content(text: string): string;
|
||||
|
||||
public InlineMd2BlockDOM(text: string): string;
|
||||
|
||||
public SetTextMark(enable: boolean): void;
|
||||
|
||||
public SetHeadingID(enable: boolean): void;
|
||||
|
|
@ -215,8 +213,6 @@ declare class Lute {
|
|||
|
||||
public SetProtyleWYSIWYG(wysiwyg: boolean): void;
|
||||
|
||||
public SetHTMLTag2TextMark(enable: boolean): void;
|
||||
|
||||
public MarkdownStr(name: string, md: string): string;
|
||||
|
||||
public IsValidLinkDest(text: string): boolean;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue