forked from siyuan-note/siyuan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompatibility.ts
More file actions
662 lines (623 loc) · 22.5 KB
/
Copy pathcompatibility.ts
File metadata and controls
662 lines (623 loc) · 22.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
import {focusByRange} from "./selection";
import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {Constants} from "../../constants";
/// #if !BROWSER
import {ipcRenderer} from "electron";
/// #endif
import {getDefaultSubType, getDefaultType} from "../../search/getDefault";
import {hideMessage, showMessage} from "../../dialog/message";
export const isPhablet = () => {
return /Android|webOS|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|Tablet/i.test(navigator.userAgent) || isIPhone() || isIPad();
};
export const encodeBase64 = (text: string): string => {
if (typeof Buffer !== "undefined") {
return Buffer.from(text, "utf8").toString("base64");
} else {
const encoder = new TextEncoder();
const bytes = encoder.encode(text);
let binary = "";
const chunkSize = 0x8000; // 避免栈溢出
for (let i = 0; i < bytes.length; i += chunkSize) {
const chunk = bytes.subarray(i, Math.min(i + chunkSize, bytes.length));
binary += String.fromCharCode(...chunk);
}
return btoa(binary);
}
};
export const getTextSiyuanFromTextHTML = (html: string) => {
if (html.trimStart().startsWith("<html") &&
html.substring(0, html.indexOf(">")).includes('xmlns:x="urn:schemas-microsoft-com:office:excel"')) {
// 移除 Microsoft Excel 中的 data-siyuan https://github.com/siyuan-note/siyuan/pull/16338
return {
textSiyuan: "",
textHtml: html.replace(/<!--data-siyuan='[^']+'-->/g, "")
};
}
const siyuanMatch = html.match(/<!--data-siyuan='([^']+)'-->/);
let textSiyuan = "";
let textHtml = html;
if (siyuanMatch) {
try {
if (typeof Buffer !== "undefined") {
const decodedBytes = Buffer.from(siyuanMatch[1], "base64");
textSiyuan = decodedBytes.toString("utf8");
} else {
const decoder = new TextDecoder();
const bytes = Uint8Array.from(atob(siyuanMatch[1]), char => char.charCodeAt(0));
textSiyuan = decoder.decode(bytes);
}
// 移除注释节点,保持原有的 text/html 内容
textHtml = html.replace(/<!--data-siyuan='[^']+'-->/g, "");
} catch (e) {
console.log("Failed to decode siyuan data from HTML comment:", e);
}
}
return {
textSiyuan,
textHtml
};
};
export const saveExportFile = async (uri: string, msgId?: string) => {
if (!uri) {
return;
}
/// #if !BROWSER
try {
const resolved = new URL(uri, `${location.origin}/`);
const pathSeg = resolved.pathname.substring(resolved.pathname.lastIndexOf("/") + 1);
let fileName: string;
try {
fileName = decodeURIComponent(pathSeg);
} catch {
fileName = pathSeg;
}
if (!fileName) {
fileName = "download";
}
const result = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
cmd: "showSaveDialog",
defaultPath: fileName,
properties: ["showOverwriteConfirmation"],
});
if (result.canceled || !result.filePath) {
if (msgId) {
hideMessage(msgId);
}
return;
}
const copyResponse = await (await fetch("/api/export/copyExportFile", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({
srcPath: resolved.pathname,
dest: result.filePath,
}),
})).json();
if (copyResponse.code !== 0) {
throw new Error(copyResponse.msg);
}
if (msgId) {
hideMessage(msgId);
}
showMessage(window.siyuan.languages.exported);
return;
} catch (e) {
if (msgId) {
hideMessage(msgId);
}
showMessage("saveExportFile failed: " + e);
}
/// #else
try {
if (isInAndroid()) {
window.JSAndroid.saveExportFile(uri);
if (msgId) {
hideMessage(msgId);
}
return;
}
if (isInIOS()) {
window.webkit.messageHandlers.saveExportFile.postMessage(uri);
if (msgId) {
hideMessage(msgId);
}
return;
}
if (isInHarmony()) {
window.JSHarmony.saveExportFile(uri);
if (msgId) {
hideMessage(msgId);
}
return;
}
const openUrl = new URL(uri, `${location.origin}/`);
openUrl.searchParams.set("download", "true");
window.open(openUrl.href);
if (msgId) {
hideMessage(msgId);
}
} catch (e) {
if (msgId) {
hideMessage(msgId);
}
showMessage("saveExportFile failed: " + e);
}
/// #endif
};
export const readText = () => {
if (isInAndroid()) {
return window.JSAndroid.readClipboard();
} else if (isInHarmony()) {
return window.JSHarmony.readClipboard();
}
if (typeof navigator.clipboard === "undefined") {
alert(window.siyuan.languages.clipboardPermissionDenied);
return "";
}
return navigator.clipboard.readText().catch(() => {
alert(window.siyuan.languages.clipboardPermissionDenied);
}) || "";
};
/// #if !BROWSER
export const getLocalFiles = async () => {
// 不再支持 PC 浏览器 https://github.com/siyuan-note/siyuan/issues/7206
let localFiles: ILocalFiles[] = [];
if ("darwin" === window.siyuan.config.system.os) {
const xmlString = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
cmd: "clipboardRead",
format: "NSFilenamesPboardType",
});
if (xmlString) {
const domParser = new DOMParser();
const xmlDom = domParser.parseFromString(xmlString, "application/xml");
Array.from(xmlDom.getElementsByTagName("string")).forEach(item => {
localFiles.push({path: item.childNodes[0].nodeValue, size: null});
});
}
} else {
const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});
if (xmlString.data.length > 0) {
localFiles = xmlString.data;
}
}
return localFiles;
};
/// #endif
export const readClipboard = async () => {
const text: IClipboardData = {textPlain: "", textHTML: "", siyuanHTML: ""};
if (isInAndroid()) {
text.textPlain = window.JSAndroid.readClipboard();
text.textHTML = window.JSAndroid.readHTMLClipboard();
const textObj = getTextSiyuanFromTextHTML(text.textHTML);
text.textHTML = textObj.textHtml;
text.siyuanHTML = textObj.textSiyuan;
if (!text.siyuanHTML) {
text.siyuanHTML = window.JSAndroid.readSiYuanHTMLClipboard();
}
return text;
}
if (isInHarmony()) {
text.textPlain = window.JSHarmony.readClipboard();
text.textHTML = window.JSHarmony.readHTMLClipboard();
const textObj = getTextSiyuanFromTextHTML(text.textHTML);
text.textHTML = textObj.textHtml;
text.siyuanHTML = textObj.textSiyuan;
if (!text.siyuanHTML) {
text.siyuanHTML = window.JSHarmony.readSiYuanHTMLClipboard();
}
return text;
}
if (typeof navigator.clipboard === "undefined") {
alert(window.siyuan.languages.clipboardPermissionDenied);
return text;
}
try {
const clipboardContents = await navigator.clipboard.read().catch(() => {
alert(window.siyuan.languages.clipboardPermissionDenied);
});
if (!clipboardContents) {
return text;
}
for (const item of clipboardContents) {
if (item.types.includes("text/html")) {
const blob = await item.getType("text/html");
text.textHTML = await blob.text();
const textObj = getTextSiyuanFromTextHTML(text.textHTML);
text.textHTML = textObj.textHtml;
text.siyuanHTML = textObj.textSiyuan;
}
if (item.types.includes("text/plain")) {
const blob = await item.getType("text/plain");
text.textPlain = await blob.text();
}
if (item.types.includes("image/png")) {
const blob = await item.getType("image/png");
text.files = [new File([blob], "image.png", {type: "image/png", lastModified: Date.now()})];
}
}
/// #if !BROWSER
if (!text.textHTML && !text.files) {
text.localFiles = await getLocalFiles();
}
/// #endif
return text;
} catch (e) {
return text;
}
};
export const writeText = (text: string) => {
let range: Range;
if (getSelection().rangeCount > 0) {
range = getSelection().getRangeAt(0).cloneRange();
}
try {
// navigator.clipboard.writeText 抛出异常不进入 catch,这里需要先处理移动端复制
if (isInAndroid()) {
window.JSAndroid.writeClipboard(text);
return;
}
if (isInHarmony()) {
window.JSHarmony.writeClipboard(text);
return;
}
if (isInIOS()) {
window.webkit.messageHandlers.setClipboard.postMessage(text);
return;
}
navigator.clipboard.writeText(text);
} catch (e) {
if (isInIOS()) {
window.webkit.messageHandlers.setClipboard.postMessage(text);
} else if (isInAndroid()) {
window.JSAndroid.writeClipboard(text);
} else if (isInHarmony()) {
window.JSHarmony.writeClipboard(text);
} else {
const textElement = document.createElement("textarea");
textElement.value = text;
textElement.style.position = "fixed"; //avoid scrolling to bottom
document.body.appendChild(textElement);
textElement.focus();
textElement.select();
document.execCommand("copy");
document.body.removeChild(textElement);
if (range) {
focusByRange(range);
}
}
}
};
export const copyPlainText = (text: string) => {
text = text.replace(new RegExp(Constants.ZWSP, "g"), ""); // `复制纯文本` 时移除所有零宽空格 https://github.com/siyuan-note/siyuan/issues/6674
writeText(text);
};
// 用户 iPhone 点击延迟/需要双击的处理
export const getEventName = () => {
if (isIPhone()) {
return "touchstart";
} else {
return "click";
}
};
export const isOnlyMeta = (event: KeyboardEvent | MouseEvent) => {
if (isMac()) {
// mac
if (event.metaKey && !event.ctrlKey) {
return true;
}
return false;
} else {
if (!event.metaKey && event.ctrlKey) {
return true;
}
return false;
}
};
export const isNotCtrl = (event: KeyboardEvent | MouseEvent) => {
if (!event.metaKey && !event.ctrlKey) {
return true;
}
return false;
};
export const isHuawei = () => {
return window.siyuan.config.system.osPlatform.toLowerCase().indexOf("huawei") > -1;
};
export const isDisabledFeature = (feature: string): boolean => {
return window.siyuan.config.system.disabledFeatures?.indexOf(feature) > -1;
};
export const isIPhone = () => {
return navigator.userAgent.indexOf("iPhone") > -1;
};
export const isSafari = () => {
const userAgent = navigator.userAgent;
return userAgent.includes("Safari") && !userAgent.includes("Chrome") && !userAgent.includes("Chromium");
};
export const isIPad = () => {
return navigator.userAgent.indexOf("iPad") > -1;
};
export const isMac = () => {
return navigator.platform.toUpperCase().indexOf("MAC") > -1;
};
export const isWin11 = async () => {
if (!(navigator as any).userAgentData || !(navigator as any).userAgentData.getHighEntropyValues) {
return false;
}
const ua = await (navigator as any).userAgentData.getHighEntropyValues(["platformVersion"]);
if ((navigator as any).userAgentData.platform === "Windows") {
if (parseInt(ua.platformVersion.split(".")[0]) >= 13) {
return true;
}
}
return false;
};
export const getScreenWidth = () => {
if (isInAndroid()) {
return window.JSAndroid.getScreenWidthPx();
} else if (isInHarmony()) {
return window.JSHarmony.getScreenWidthPx();
}
return window.outerWidth;
};
export const isWindows = () => {
return navigator.platform.toUpperCase().indexOf("WIN") > -1;
};
export const isInAndroid = () => {
return window.siyuan.config.system.container === "android" && window.JSAndroid;
};
export const isInIOS = () => {
return window.siyuan.config.system.container === "ios" && window.webkit?.messageHandlers;
};
export const isInMobileApp = () => {
if (isInAndroid() || isInHarmony() || isInIOS()) {
return true;
}
return false;
};
export const isInHarmony = () => {
return window.siyuan.config.system.container === "harmony" && window.JSHarmony;
};
export const isInEdge = () => {
const ua = navigator.userAgent;
return ua.indexOf("EdgA/") > -1 || ua.indexOf("Edge/") > -1;
};
export function isChromeBrowser(): boolean {
const nav = window.navigator as Navigator & {
userAgentData: {
brands: {
brand: string;
version: string;
}[]
}
};
if (nav.userAgentData && Array.isArray(nav.userAgentData.brands)) {
return nav.userAgentData.brands.some((b: any) => /Chrome|Chromium/i.test(b.brand));
}
// 回退到 userAgent
const ua = nav.userAgent || "";
const isChromium = /\bChrome\/\d+/i.test(ua) || /\bChromium\/\d+/i.test(ua);
const isEdge = /\bEdg(e|A|iOS)?\/\d+/i.test(ua); // Edge Chromium
const isOpera = /\b(OPR|Opera)\/\d+/i.test(ua);
return isChromium && !isEdge && !isOpera;
}
export const updateHotkeyAfterTip = (hotkey: string, split = " ") => {
if (hotkey) {
return split + updateHotkeyTip(hotkey);
}
return "";
};
// Mac,Windows 快捷键展示
export const updateHotkeyTip = (hotkey: string) => {
if (!hotkey || isMac()) {
return hotkey;
}
const keys = [];
if ((hotkey.indexOf("⌘") > -1 || hotkey.indexOf("⌃") > -1)) keys.push("Ctrl");
if (hotkey.indexOf("⇧") > -1) keys.push("Shift");
if (hotkey.indexOf("⌥") > -1) keys.push("Alt");
// 不能去最后一个,需匹配 F2
const lastKey = hotkey.replace(/[⌘⇧⌥⌃]/g, "");
if (lastKey) {
keys.push({
"⇥": "Tab",
"⌫": "Backspace",
"⌦": "Delete",
"↩": "Enter"
}[lastKey] || lastKey);
}
return keys.join("+");
};
export const getLocalStorage = (cb: () => void) => {
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
window.siyuan.storage = response.data;
// 历史数据迁移
const defaultStorage: any = {};
defaultStorage[Constants.LOCAL_SEARCHASSET] = {
keys: [],
col: "",
row: "",
layout: 0,
method: 0,
types: {},
sort: 0,
k: "",
};
defaultStorage[Constants.LOCAL_SEARCHUNREF] = {
col: "",
row: "",
layout: 0,
};
Constants.SIYUAN_ASSETS_SEARCH.forEach(type => {
defaultStorage[Constants.LOCAL_SEARCHASSET].types[type] = true;
});
defaultStorage[Constants.LOCAL_SEARCHKEYS] = {
keys: [],
replaceKeys: [],
col: "",
row: "",
layout: 0,
colTab: "",
rowTab: "",
layoutTab: 0
};
defaultStorage[Constants.LOCAL_PDFTHEME] = {
light: "light",
dark: "dark",
annoColor: "var(--b3-pdf-background1)"
};
defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}, time: number, filespaths: IFilesPath[]}
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
defaultStorage[Constants.LOCAL_PLUGIN_DOCKS] = {}; // { pluginName: {dockId: IPluginDockTab}}
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
defaultStorage[Constants.LOCAL_OUTLINE] = {keepCurrentExpand: false};
defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr}
defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition}
defaultStorage[Constants.LOCAL_HISTORY] = {
notebookId: "%",
type: 0,
operation: "all",
sideWidth: "256px",
sideDocWidth: "256px",
sideDiffWidth: "256px",
};
defaultStorage[Constants.LOCAL_FLASHCARD] = {
fullscreen: false
};
defaultStorage[Constants.LOCAL_BAZAAR] = {
theme: "0",
template: "0",
icon: "0",
widget: "0",
};
defaultStorage[Constants.LOCAL_EXPORTWORD] = {removeAssets: false, mergeSubdocs: false};
defaultStorage[Constants.LOCAL_EXPORTPDF] = {
landscape: false,
marginType: "0",
scale: 1,
pageSize: "A4",
removeAssets: true,
keepFold: false,
mergeSubdocs: false,
watermark: false,
paged: true
};
defaultStorage[Constants.LOCAL_EXPORTIMG] = {
keepFold: false,
watermark: false
};
defaultStorage[Constants.LOCAL_DOCINFO] = {
id: "",
};
defaultStorage[Constants.LOCAL_IMAGES] = {
file: "1f4c4",
note: "1f5c3",
folder: "1f4d1"
};
defaultStorage[Constants.LOCAL_EMOJIS] = {
currentTab: "emoji"
};
defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
defaultStorage[Constants.LOCAL_CLOSED_TABS] = [];
defaultStorage[Constants.LOCAL_FILESPATHS] = []; // IFilesPath[]
defaultStorage[Constants.LOCAL_SEARCHDATA] = {
removed: true,
page: 1,
sort: 0,
group: 0,
hasReplace: false,
method: 0,
hPath: "",
idPath: [],
k: "",
r: "",
types: getDefaultType(),
subTypes: getDefaultSubType(),
replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES),
};
defaultStorage[Constants.LOCAL_ZOOM] = 1;
defaultStorage[Constants.LOCAL_MOVE_PATH] = {keys: [], k: ""};
defaultStorage[Constants.LOCAL_RECENT_DOCS] = {type: "viewedAt"}; // TRecentDocsSort
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR,
Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES,
Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI,
Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD,
Constants.LOCAL_DIALOGPOSITION, Constants.LOCAL_SEARCHUNREF, Constants.LOCAL_HISTORY,
Constants.LOCAL_OUTLINE, Constants.LOCAL_FILEPOSITION, Constants.LOCAL_FILESPATHS, Constants.LOCAL_IMAGES,
Constants.LOCAL_PLUGIN_DOCKS, Constants.LOCAL_EMOJIS, Constants.LOCAL_MOVE_PATH, Constants.LOCAL_RECENT_DOCS,
Constants.LOCAL_CLOSED_TABS].forEach((key) => {
if (typeof response.data[key] === "string") {
try {
const parseData = JSON.parse(response.data[key]);
if (typeof parseData === "number") {
// https://github.com/siyuan-note/siyuan/issues/8852 Object.assign 会导致 number to Number
window.siyuan.storage[key] = parseData;
} else {
window.siyuan.storage[key] = Object.assign(defaultStorage[key], parseData);
}
} catch (e) {
window.siyuan.storage[key] = defaultStorage[key];
}
} else if (typeof response.data[key] === "undefined") {
window.siyuan.storage[key] = defaultStorage[key];
}
});
// 搜索数据添加 replaceTypes 兼容
if (!window.siyuan.storage[Constants.LOCAL_SEARCHDATA].replaceTypes ||
Object.keys(window.siyuan.storage[Constants.LOCAL_SEARCHDATA].replaceTypes).length === 0) {
window.siyuan.storage[Constants.LOCAL_SEARCHDATA].replaceTypes = Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES);
}
// Migrate stored search data to include subTypes when absent
if (!window.siyuan.storage[Constants.LOCAL_SEARCHDATA].subTypes ||
Object.keys(window.siyuan.storage[Constants.LOCAL_SEARCHDATA].subTypes).length === 0) {
window.siyuan.storage[Constants.LOCAL_SEARCHDATA].subTypes = getDefaultSubType();
}
cb();
});
};
export const setStorageVal = (key: string, val: any, cb?: () => void) => {
if (window.siyuan.config.readonly || window.siyuan.isPublish) {
return;
}
fetchPost("/api/storage/setLocalStorageVal", {
app: Constants.SIYUAN_APPID,
key,
val,
}, () => {
if (cb) {
cb();
}
});
};
/// #if !BROWSER
export const initNativeDialogOverride = () => {
const originalAlert = window.alert;
const originalConfirm = window.confirm;
window.alert = function (message: string) {
try {
ipcRenderer.sendSync(Constants.SIYUAN_ALERT_DIALOG, {
title: window.siyuan.languages.siyuanNote,
message,
buttons: [window.siyuan.languages.confirm],
noLink: true,
});
return undefined;
} catch (error) {
return originalAlert.call(this, message);
}
};
window.confirm = function (message: string): boolean {
try {
const buttonIndex = ipcRenderer.sendSync(Constants.SIYUAN_CONFIRM_DIALOG, {
title: window.siyuan?.languages?.siyuanNote || "SiYuan",
message,
buttons: [window.siyuan?.languages?.cancel || "Cancel", window.siyuan?.languages?.confirm || "OK"],
cancelId: 0,
defaultId: 1,
noLink: true,
});
return buttonIndex === 1;
} catch (error) {
return originalConfirm.call(this, message);
}
};
};
/// #endif