diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 75d8fea87..28af88433 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -16,6 +16,7 @@ import {Tab} from "../../layout/Tab"; import {getAllModels} from "../../layout/getAll"; import {updatePanelByEditor} from "../../editor/util"; /// #endif +import * as path from "path"; import {Editor} from "../../editor"; import {blockRender} from "../markdown/blockRender"; import {processRender} from "./processCode"; @@ -23,7 +24,6 @@ import {highlightRender} from "../markdown/highlightRender"; import {uploadLocalFiles} from "../upload"; import {MenuItem} from "../../menus/Menu"; import {insertHTML} from "./insertHTML"; -import {pathPosix} from "../../util/pathName"; const dragSb = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isBottom: boolean, direct: "col" | "row") => { const isSameDoc = protyle.element.contains(sourceElements[0]); @@ -718,7 +718,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { click() { let fileText = ""; files.forEach((item) => { - fileText += `[${pathPosix().basename(item)}](file://${item})\n`; + fileText += `[${path.basename(item)}](file://${item})\n`; }); insertHTML(protyle.lute.SpinBlockDOM(fileText), protyle); } diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index ba2c3fb6b..79f32ac97 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -69,7 +69,6 @@ export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Ele export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvent) & { target: HTMLElement }) => { event.stopPropagation(); event.preventDefault(); - let textHTML; let textPlain; let files; @@ -87,6 +86,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven /// #if !MOBILE if (!textHTML && !textPlain && ("clipboardData" in event)) { if ("darwin" === window.siyuan.config.system.os) { + /// #if !BROWSER const xmlString = clipboard.read("NSFilenamesPboardType"); const domParser = new DOMParser(); const xmlDom = domParser.parseFromString(xmlString, "application/xml"); @@ -96,6 +96,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven }); uploadLocalFiles(localFiles, protyle); writeText(""); + /// #endif return; } else { const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {}); diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index b55089f4b..fe7caf286 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -5,7 +5,8 @@ import { focusByRange, focusByWbr, getEditorRange, - getSelectionOffset, selectAll, + getSelectionOffset, + selectAll, setFirstNodeRange, setLastNodeRange } from "../util/selection"; @@ -22,7 +23,9 @@ import { getLastBlock, getNextBlock, getPreviousBlock, - getTopAloneElement, hasNextSibling, hasPreviousSibling, + getTopAloneElement, + hasNextSibling, + hasPreviousSibling, isNotEditBlock, } from "./getBlock"; import {matchHotKey} from "../util/hotKey"; @@ -39,10 +42,11 @@ import {fontEvent} from "../toolbar/Font"; import {listIndent, listOutdent, updateListOrder} from "./list"; import {newFileBySelect, newFileContentBySelect, rename, replaceFileName} from "../../editor/rename"; import {insertEmptyBlock, jumpToParentNext} from "../../block/util"; -import {isLocalPath, pathPosix} from "../../util/pathName"; +import {isLocalPath} from "../../util/pathName"; /// #if !BROWSER import {clipboard} from "electron"; import {getCurrentWindow} from "@electron/remote"; +import * as path from "path"; /// #endif /// #if !MOBILE import {openBy, openFileById} from "../../editor/util"; @@ -1570,6 +1574,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { /// #if !BROWSER && !MOBILE if (matchHotKey(window.siyuan.config.keymap.editor.general.pasteAsPlainText.custom, event)) { + event.returnValue = false; + event.preventDefault(); + event.stopPropagation(); let localFiles: string[] = []; if ("darwin" === window.siyuan.config.system.os) { const xmlString = clipboard.read("NSFilenamesPboardType"); @@ -1587,7 +1594,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (localFiles.length > 0) { let fileText = "" localFiles.forEach((item) => { - fileText += `[${pathPosix().basename(item)}](file://${item})\n`; + fileText += `[${path.basename(item)}](file://${item})\n`; }); insertHTML(protyle.lute.SpinBlockDOM(fileText), protyle); } else { @@ -1596,8 +1603,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { getCurrentWindow().webContents.pasteAndMatchStyle(); }, 100); } - event.preventDefault(); - event.stopPropagation(); return; }