mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 09:30:48 +08:00
🎨 移动端复制后长按块粘贴无效 Fix https://github.com/siyuan-note/insider/issues/1091
This commit is contained in:
parent
34e4697878
commit
21b76c1a72
@ -19,7 +19,7 @@ import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction";
|
|||||||
import {openMenu} from "./commonMenuItem";
|
import {openMenu} from "./commonMenuItem";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {writeText} from "../protyle/util/compatibility";
|
import {readText, writeText} from "../protyle/util/compatibility";
|
||||||
import {preventScroll} from "../protyle/scroll/preventScroll";
|
import {preventScroll} from "../protyle/scroll/preventScroll";
|
||||||
import {onGet} from "../protyle/util/onGet";
|
import {onGet} from "../protyle/util/onGet";
|
||||||
import {getAllModels} from "../layout/getAll";
|
import {getAllModels} from "../layout/getAll";
|
||||||
@ -347,7 +347,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||||||
document.execCommand("paste");
|
document.execCommand("paste");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const clipText = await navigator.clipboard.readText();
|
const clipText = await readText();
|
||||||
pasteText(protyle, clipText, nodeElement);
|
pasteText(protyle, clipText, nodeElement);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
@ -370,7 +370,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||||||
async click() {
|
async click() {
|
||||||
try {
|
try {
|
||||||
// * _ [ ] ! \ ` < > & ~ { } ( ) = # $ ^ |
|
// * _ [ ] ! \ ` < > & ~ { } ( ) = # $ ^ |
|
||||||
let clipText = await navigator.clipboard.readText();
|
let clipText = await readText();
|
||||||
// https://github.com/siyuan-note/siyuan/issues/5446
|
// https://github.com/siyuan-note/siyuan/issues/5446
|
||||||
// A\B\C\D\
|
// A\B\C\D\
|
||||||
// E
|
// E
|
||||||
|
@ -2,6 +2,7 @@ import {ToolbarItem} from "./ToolbarItem";
|
|||||||
import {linkMenu} from "../../menus/protyle";
|
import {linkMenu} from "../../menus/protyle";
|
||||||
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
|
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
|
||||||
import {focusByRange, focusByWbr} from "../util/selection";
|
import {focusByRange, focusByWbr} from "../util/selection";
|
||||||
|
import {readText} from "../util/compatibility";
|
||||||
|
|
||||||
export class Link extends ToolbarItem {
|
export class Link extends ToolbarItem {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
@ -27,7 +28,7 @@ export class Link extends ToolbarItem {
|
|||||||
const rangeString = range.toString().trim();
|
const rangeString = range.toString().trim();
|
||||||
let dataHref = "";
|
let dataHref = "";
|
||||||
try {
|
try {
|
||||||
const clipText = await navigator.clipboard.readText();
|
const clipText = await readText();
|
||||||
// 选中链接时需忽略剪切板内容 https://ld246.com/article/1643035329737
|
// 选中链接时需忽略剪切板内容 https://ld246.com/article/1643035329737
|
||||||
if (protyle.lute.IsValidLinkDest(rangeString)) {
|
if (protyle.lute.IsValidLinkDest(rangeString)) {
|
||||||
dataHref = rangeString;
|
dataHref = rangeString;
|
||||||
|
@ -13,6 +13,13 @@ export const openByMobile = (uri: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const readText = async () => {
|
||||||
|
if ("android" === window.siyuan.config.system.container && window.JSAndroid) {
|
||||||
|
return window.JSAndroid.readClipboard();
|
||||||
|
}
|
||||||
|
return navigator.clipboard.readText();
|
||||||
|
}
|
||||||
|
|
||||||
export const writeText = async (text: string) => {
|
export const writeText = async (text: string) => {
|
||||||
let range: Range;
|
let range: Range;
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount > 0) {
|
||||||
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
@ -34,6 +34,7 @@ interface Window {
|
|||||||
changeStatusBarColor(color: string, mode: number): void
|
changeStatusBarColor(color: string, mode: number): void
|
||||||
writeClipboard(text: string): void
|
writeClipboard(text: string): void
|
||||||
writeImageClipboard(uri: string): void
|
writeImageClipboard(uri: string): void
|
||||||
|
readClipboard(): string
|
||||||
}
|
}
|
||||||
|
|
||||||
goBack(): void
|
goBack(): void
|
||||||
|
Loading…
Reference in New Issue
Block a user