${keymap._genItem(window.siyuan.config.keymap.editor.insert, "editor" + Constants.ZWSP + "insert")}
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 5ef4f92855..c47c0f7897 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -436,6 +436,8 @@ export abstract class Constants extends SConst { // Sillot extend
"inline-code": {default: "⌘G", custom: "⌘G"},
link: {default: "⌘K", custom: "⌘K"},
check: {default: "⌘L", custom: "⌘L"},
+ "ordered-list": {default: "", custom: ""},
+ list: {default: "", custom: ""},
table: {default: "⌘O", custom: "⌘O"},
code: {default: "⇧⌘K", custom: "⇧⌘K"},
clearInline: {default: "⌘\\", custom: "⌘\\"},
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index 9bb7b2d3b3..2c9aa09e29 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -163,10 +163,6 @@ export const kernelError = () => {
if (document.querySelector("#errorLog")) {
return;
}
- if (window.JSAndroid) {
- window.JSAndroid.androidReboot();
- return;
- }
let iosReStart = "";
if (isInIOS()) {
iosReStart = `
`;
diff --git a/app/src/index.ts b/app/src/index.ts
index e5e40c66df..5346b6ff67 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -1,221 +1,211 @@
-import { Constants } from "./constants";
-import { Menus } from "./menus";
-import { Model } from "./layout/Model";
-import { onGetConfig } from "./boot/onGetConfig";
-import { initBlockPopover } from "./block/popover";
-import { account } from "./config/account";
-import { addScript, addScriptSync } from "./protyle/util/addScript";
-import { genUUID } from "./util/genID";
-import { fetchGet, fetchPost } from "./util/fetch";
-import { addBaseURL, getIdFromSYProtocol, isSYProtocol, setNoteBook } from "./util/pathName";
-import {registerServiceWorker} from "./util/serviceWorker";
-import { openFileById } from "./editor/util";
-import {
- bootSync,
- downloadProgress,
- processSync,
- progressBackgroundTask,
- progressLoading,
- progressStatus,
- reloadSync,
- setTitle,
- transactionError
-} from "./dialog/processSystem";
-import { initMessage } from "./dialog/message";
-import { getAllTabs } from "./layout/getAll";
-import { getLocalStorage } from "./protyle/util/compatibility";
-import { exportIDB, importIDB } from "./sillot/util/sillot-idb-backup-and-restore";
-import { SillotEnv } from "./sillot";
-import {getSearch} from "./util/functions";
-import {hideAllElements} from "./protyle/ui/hideElements";
-import {loadPlugins, reloadPlugin} from "./plugin/loader";
-import "./assets/scss/base.scss";
-
-export class App {
- public plugins: import("./plugin").Plugin[] = [];
- public appId: string;
-
- constructor() {
- /// #if BROWSER
- registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
- /// #endif
- addBaseURL();
-
- this.appId = Constants.SIYUAN_APPID;
- window.siyuan = {
- zIndex: 10,
- transactions: [],
- reqIds: {},
- backStack: [],
- layout: {},
- dialogs: [],
- blockPanels: [],
- ctrlIsPressed: false,
- altIsPressed: false,
- ws: new Model({
- app: this,
- id: genUUID(),
- type: "main",
- msgCallback: (data) => {
- this.plugins.forEach((plugin) => {
- plugin.eventBus.emit("ws-main", data);
- });
- if (data) {
- switch (data.cmd) {
- case "reloadPlugin":
- reloadPlugin(this, data.data);
- break;
- case "syncMergeResult":
- reloadSync(this, data.data);
- break;
- case "reloaddoc":
- reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false);
- break;
- case "readonly":
- window.siyuan.config.editor.readOnly = data.data;
- hideAllElements(["util"]);
- break;
- case "setConf":
- window.siyuan.config = data.data;
- break;
- case "progress":
- progressLoading(data);
- break;
- case "setLocalStorageVal":
- window.siyuan.storage[data.data.key] = data.data.val;
- break;
- case "rename":
- getAllTabs().forEach((tab) => {
- if (tab.headElement) {
- const initTab = tab.headElement.getAttribute("data-initdata");
- if (initTab) {
- const initTabData = JSON.parse(initTab);
- if (initTabData.instance === "Editor" && initTabData.rootId === data.data.id) {
- tab.updateTitle(data.data.title);
- }
- }
- }
- });
- break;
- case "unmount":
- getAllTabs().forEach((tab) => {
- if (tab.headElement) {
- const initTab = tab.headElement.getAttribute("data-initdata");
- if (initTab) {
- const initTabData = JSON.parse(initTab);
- if (initTabData.instance === "Editor" && data.data.box === initTabData.notebookId) {
- tab.parent.removeTab(tab.id);
- }
- }
- }
- });
- break;
- case "removeDoc":
- getAllTabs().forEach((tab) => {
- if (tab.headElement) {
- const initTab = tab.headElement.getAttribute("data-initdata");
- if (initTab) {
- const initTabData = JSON.parse(initTab);
- if (initTabData.instance === "Editor" && data.data.ids.includes(initTabData.rootId)) {
- tab.parent.removeTab(tab.id);
- }
- }
- }
- });
- break;
- case "statusbar":
- progressStatus(data);
- break;
- case "downloadProgress":
- downloadProgress(data.data);
- break;
- case "txerr":
- transactionError();
- break;
- case "syncing":
- processSync(data, this.plugins);
- break;
- case "backgroundtask":
- progressBackgroundTask(data.data.tasks);
- break;
- case "refreshtheme":
- if ((window.siyuan.config.appearance.mode === 1 && window.siyuan.config.appearance.themeDark !== Constants.Themes.DefaultThemeDark) || (window.siyuan.config.appearance.mode === 0 && window.siyuan.config.appearance.themeLight !== Constants.Themes.DefaultThemeLight)) {
- (document.getElementById("themeStyle") as HTMLLinkElement).href = data.data.theme;
- } else {
- (document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
- }
- break;
- case "openFileById":
- openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
- break;
- }
- }
- }
- }),
- };
- new SillotEnv();
- window.Sillot.androidRestartSiYuan = ()=>{
- const overlay = document.querySelector('#SillotOverlay') as HTMLElement;
- overlay.style.display = "block";
- exportIDB().then(() => {
- hideAllElements(["util"]);
- fetchPost("/api/sillot/androidReboot", {force: true}, (response) => {
- window.location.href = "siyuan://androidRestartSiYuan";
- });
- })
- };
-
- fetchPost("/api/system/getConf", {}, async (response) => {
- addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
- addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
- window.siyuan.config = response.data.conf;
- const workspaceName: string = window.siyuan.config.system.workspaceDir.replaceAll("\\","/").split("/").at(-1);
- // console.log(workspaceName)
- fetchPost("/api/sillot/getConfigesStore", { f: `IDB__${workspaceName}__.json` }, async (r) => {
- // console.log(r);
- importIDB(r.data).then(() => {
- window.Sillot.status.IDBloaded = true;
- });});
- getLocalStorage(() => {
- fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
- window.siyuan.languages = lauguages;
- window.siyuan.menus = new Menus(this);
- bootSync();
- fetchPost("/api/setting/getCloudUser", {}, userResponse => {
- window.siyuan.user = userResponse.data;
- onGetConfig(response.data.start, this);
- account.onSetaccount();
- setTitle(window.siyuan.languages.siyuanNote);
- initMessage();
- });
- });
- });
- });
- setNoteBook();
- initBlockPopover(this);
- loadPlugins(this);
- }
-}
-
-const siyuanApp = new App();
-
-window.openFileByURL = (openURL) => {
- if (openURL && isSYProtocol(openURL)) {
- const isZoomIn = getSearch("focus", openURL) === "1";
- openFileById({
- app: siyuanApp,
- id: getIdFromSYProtocol(openURL),
- action: isZoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],
- zoomIn: isZoomIn
- });
- return true;
- }
- return false;
-};
-
-
-/// #if BROWSER
-window.showKeyboardToolbar = () => {
- // 防止 Pad 端报错
-};
-/// #endif
+import { Constants } from "./constants";
+import { Menus } from "./menus";
+import { Model } from "./layout/Model";
+import { onGetConfig } from "./boot/onGetConfig";
+import { initBlockPopover } from "./block/popover";
+import { account } from "./config/account";
+import { addScript, addScriptSync } from "./protyle/util/addScript";
+import { genUUID } from "./util/genID";
+import { fetchGet, fetchPost } from "./util/fetch";
+import { addBaseURL, getIdFromSYProtocol, isSYProtocol, setNoteBook } from "./util/pathName";
+import {registerServiceWorker} from "./util/serviceWorker";
+import { openFileById } from "./editor/util";
+import {
+ bootSync,
+ downloadProgress,
+ processSync,
+ progressBackgroundTask,
+ progressLoading,
+ progressStatus,
+ reloadSync,
+ setTitle,
+ transactionError
+} from "./dialog/processSystem";
+import { initMessage } from "./dialog/message";
+import { getAllTabs } from "./layout/getAll";
+import { getLocalStorage } from "./protyle/util/compatibility";
+import { exportIDB, importIDB } from "./sillot/util/sillot-idb-backup-and-restore";
+import { SillotEnv } from "./sillot";
+import {getSearch} from "./util/functions";
+import {hideAllElements} from "./protyle/ui/hideElements";
+import {loadPlugins, reloadPlugin} from "./plugin/loader";
+import "./assets/scss/base.scss";
+
+export class App {
+ public plugins: import("./plugin").Plugin[] = [];
+ public appId: string;
+
+ constructor() {
+ /// #if BROWSER
+ registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
+ /// #endif
+ addBaseURL();
+
+ this.appId = Constants.SIYUAN_APPID;
+ window.siyuan = {
+ zIndex: 10,
+ transactions: [],
+ reqIds: {},
+ backStack: [],
+ layout: {},
+ dialogs: [],
+ blockPanels: [],
+ ctrlIsPressed: false,
+ altIsPressed: false,
+ ws: new Model({
+ app: this,
+ id: genUUID(),
+ type: "main",
+ msgCallback: (data) => {
+ this.plugins.forEach((plugin) => {
+ plugin.eventBus.emit("ws-main", data);
+ });
+ if (data) {
+ switch (data.cmd) {
+ case "reloadPlugin":
+ reloadPlugin(this, data.data);
+ break;
+ case "syncMergeResult":
+ reloadSync(this, data.data);
+ break;
+ case "reloaddoc":
+ reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false);
+ break;
+ case "readonly":
+ window.siyuan.config.editor.readOnly = data.data;
+ hideAllElements(["util"]);
+ break;
+ case "setConf":
+ window.siyuan.config = data.data;
+ break;
+ case "progress":
+ progressLoading(data);
+ break;
+ case "setLocalStorageVal":
+ window.siyuan.storage[data.data.key] = data.data.val;
+ break;
+ case "rename":
+ getAllTabs().forEach((tab) => {
+ if (tab.headElement) {
+ const initTab = tab.headElement.getAttribute("data-initdata");
+ if (initTab) {
+ const initTabData = JSON.parse(initTab);
+ if (initTabData.instance === "Editor" && initTabData.rootId === data.data.id) {
+ tab.updateTitle(data.data.title);
+ }
+ }
+ }
+ });
+ break;
+ case "unmount":
+ getAllTabs().forEach((tab) => {
+ if (tab.headElement) {
+ const initTab = tab.headElement.getAttribute("data-initdata");
+ if (initTab) {
+ const initTabData = JSON.parse(initTab);
+ if (initTabData.instance === "Editor" && data.data.box === initTabData.notebookId) {
+ tab.parent.removeTab(tab.id);
+ }
+ }
+ }
+ });
+ break;
+ case "removeDoc":
+ getAllTabs().forEach((tab) => {
+ if (tab.headElement) {
+ const initTab = tab.headElement.getAttribute("data-initdata");
+ if (initTab) {
+ const initTabData = JSON.parse(initTab);
+ if (initTabData.instance === "Editor" && data.data.ids.includes(initTabData.rootId)) {
+ tab.parent.removeTab(tab.id);
+ }
+ }
+ }
+ });
+ break;
+ case "statusbar":
+ progressStatus(data);
+ break;
+ case "downloadProgress":
+ downloadProgress(data.data);
+ break;
+ case "txerr":
+ transactionError();
+ break;
+ case "syncing":
+ processSync(data, this.plugins);
+ break;
+ case "backgroundtask":
+ progressBackgroundTask(data.data.tasks);
+ break;
+ case "refreshtheme":
+ if ((window.siyuan.config.appearance.mode === 1 && window.siyuan.config.appearance.themeDark !== Constants.Themes.DefaultThemeDark) || (window.siyuan.config.appearance.mode === 0 && window.siyuan.config.appearance.themeLight !== Constants.Themes.DefaultThemeLight)) {
+ (document.getElementById("themeStyle") as HTMLLinkElement).href = data.data.theme;
+ } else {
+ (document.getElementById("themeDefaultStyle") as HTMLLinkElement).href = data.data.theme;
+ }
+ break;
+ case "openFileById":
+ openFileById({app: this, id: data.data.id, action: [Constants.CB_GET_FOCUS]});
+ break;
+ }
+ }
+ }
+ }),
+ };
+ new SillotEnv();
+
+ fetchPost("/api/system/getConf", {}, async (response) => {
+ addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
+ addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
+ window.siyuan.config = response.data.conf;
+ const workspaceName: string = window.siyuan.config.system.workspaceDir.replaceAll("\\","/").split("/").at(-1);
+ // console.log(workspaceName)
+ fetchPost("/api/sillot/getConfigesStore", { f: `IDB__${workspaceName}__.json` }, async (r) => {
+ // console.log(r);
+ importIDB(r.data).then(() => {
+ window.Sillot.status.IDBloaded = true;
+ });});
+ getLocalStorage(() => {
+ fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
+ window.siyuan.languages = lauguages;
+ window.siyuan.menus = new Menus(this);
+ bootSync();
+ fetchPost("/api/setting/getCloudUser", {}, userResponse => {
+ window.siyuan.user = userResponse.data;
+ onGetConfig(response.data.start, this);
+ account.onSetaccount();
+ setTitle(window.siyuan.languages.siyuanNote);
+ initMessage();
+ });
+ });
+ });
+ });
+ setNoteBook();
+ initBlockPopover(this);
+ loadPlugins(this);
+ }
+}
+
+const siyuanApp = new App();
+
+window.openFileByURL = (openURL) => {
+ if (openURL && isSYProtocol(openURL)) {
+ const isZoomIn = getSearch("focus", openURL) === "1";
+ openFileById({
+ app: siyuanApp,
+ id: getIdFromSYProtocol(openURL),
+ action: isZoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],
+ zoomIn: isZoomIn
+ });
+ return true;
+ }
+ return false;
+};
+
+
+/// #if BROWSER
+window.showKeyboardToolbar = () => {
+ // 防止 Pad 端报错
+};
+/// #endif
diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts
index e625a44f5e..c369aaf167 100644
--- a/app/src/layout/dock/index.ts
+++ b/app/src/layout/dock/index.ts
@@ -63,7 +63,7 @@ export class Dock {
this.app = options.app;
this.element = document.getElementById("dock" + options.position);
const dockClass = options.position === "Bottom" ? ' class="fn__flex dock__items"' : ' class="dock__items"';
- this.element.innerHTML = `
`;
+ this.element.innerHTML = `
`;
this.position = options.position;
this.pin = options.data.pin;
this.data = {};
@@ -87,7 +87,7 @@ export class Dock {
}
}
if (!showDock) {
- this.element.firstElementChild.innerHTML = `
+ this.element.firstElementChild.innerHTML = `
`;
this.element.classList.add("fn__none");
@@ -143,17 +143,20 @@ export class Dock {
documentSelf.ondragstart = () => false;
let ghostElement: HTMLElement;
let selectItem: HTMLElement;
+ const moveItem = document.createElement("span");
+ moveItem.classList.add("dock__item", "fn__none");
+ moveItem.style.background = "var(--b3-theme-primary-light)";
+ moveItem.innerHTML = "";
+ moveItem.id = "dockMoveItem";
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
if (window.siyuan.config.readonly ||
Math.abs(moveEvent.clientY - event.clientY) < 3 && Math.abs(moveEvent.clientX - event.clientX) < 3) {
return;
}
- console.log(moveEvent.clientY - event.clientY)
moveEvent.preventDefault();
moveEvent.stopPropagation();
if (!ghostElement) {
item.style.opacity = "0.38";
- item.classList.remove("b3-tooltips");
ghostElement = item.cloneNode(true) as HTMLElement;
ghostElement.setAttribute("data-ghost-type", "dock");
this.element.append(ghostElement);
@@ -179,31 +182,92 @@ export class Dock {
}
const targetItem = hasClosestByClassName(moveEvent.target as HTMLElement, "dock__item") ||
- hasClosestByClassName(moveEvent.target as HTMLElement, "dock__items") as HTMLElement;
+ hasClosestByClassName(moveEvent.target as HTMLElement, "dock__items") as HTMLElement ||
+ hasClosestByClassName(moveEvent.target as HTMLElement, "dock__item--space") as HTMLElement;
if (targetItem && selectItem && targetItem.isSameNode(selectItem)) {
- if (selectItem.classList.contains("dock__item")) {
+ if (selectItem.classList.contains("dock__item--space")) {
+ const selectRect = selectItem.getBoundingClientRect();
+ if (selectItem.parentElement.id === "dockBottom") {
+ if (moveEvent.clientX < selectRect.right && moveEvent.clientX > selectRect.right - 40) {
+ const lastFirstElement = selectItem.nextElementSibling.firstElementChild;
+ if (lastFirstElement && lastFirstElement.isSameNode(item)) {
+ moveItem.classList.add("fn__none");
+ } else {
+ moveItem.classList.remove("fn__none");
+ lastFirstElement.before(moveItem);
+ }
+ }
+ } else {
+ if (moveEvent.clientY < selectRect.bottom && moveEvent.clientY > selectRect.bottom - 40) {
+ const lastFirstElement = selectItem.nextElementSibling.firstElementChild;
+ if (lastFirstElement && lastFirstElement.isSameNode(item)) {
+ moveItem.classList.add("fn__none");
+ } else {
+ moveItem.classList.remove("fn__none");
+ lastFirstElement.before(moveItem);
+ }
+ }
+ }
+ } else if (selectItem.classList.contains("dock__item--pin")) {
+ if (item.nextElementSibling?.isSameNode(selectItem)) {
+ moveItem.classList.add("fn__none");
+ } else {
+ moveItem.classList.remove("fn__none");
+ selectItem.before(moveItem);
+ }
+ } else if (selectItem.classList.contains("dock__item")) {
const selectRect = selectItem.getBoundingClientRect();
if (selectItem.parentElement.parentElement.id === "dockBottom") {
if (selectRect.left + selectRect.width / 2 > moveEvent.clientX) {
- selectItem.before(item);
+ if (item.nextElementSibling?.isSameNode(selectItem)) {
+ moveItem.classList.add("fn__none");
+ } else {
+ moveItem.classList.remove("fn__none");
+ selectItem.before(moveItem);
+ }
} else {
- selectItem.after(item);
+ if (item.previousElementSibling?.isSameNode(selectItem)) {
+ moveItem.classList.add("fn__none");
+ } else {
+ moveItem.classList.remove("fn__none");
+ selectItem.after(moveItem);
+ }
}
} else {
if (selectRect.top + selectRect.height / 2 > moveEvent.clientY) {
- selectItem.before(item);
+ if (item.nextElementSibling?.isSameNode(selectItem)) {
+ moveItem.classList.add("fn__none");
+ } else {
+ moveItem.classList.remove("fn__none");
+ selectItem.before(moveItem);
+ }
} else {
- selectItem.after(item);
+ if (item.previousElementSibling?.isSameNode(selectItem)) {
+ moveItem.classList.add("fn__none");
+ } else {
+ moveItem.classList.remove("fn__none");
+ selectItem.after(moveItem);
+ }
}
}
} else if (selectItem.childElementCount === 0) {
- selectItem.append(item)
+ moveItem.classList.remove("fn__none");
+ selectItem.append(moveItem);
+ } else if (selectItem.childElementCount === 1 && selectItem.firstElementChild.id === "dockMoveItem") {
+ moveItem.classList.remove("fn__none");
} else if (selectItem.childElementCount === 1 && selectItem.firstElementChild.classList.contains("dock__item--pin")) {
- selectItem.insertAdjacentElement("afterbegin", item);
+ moveItem.classList.remove("fn__none");
+ selectItem.insertAdjacentElement("afterbegin", moveItem);
+ } else if (selectItem.childElementCount === 2 &&
+ selectItem.firstElementChild.id === "dockMoveItem" && selectItem.lastElementChild.classList.contains("dock__item--pin")) {
+ moveItem.classList.remove("fn__none");
}
return;
}
- if (!targetItem || targetItem.classList.contains("dock__item--pin") || targetItem.style.position === "fixed" || targetItem.isSameNode(item)) {
+ if (!targetItem || targetItem.style.position === "fixed" || targetItem.isSameNode(item) || targetItem.id === "dockMoveItem") {
+ if (targetItem && targetItem.isSameNode(item)) {
+ moveItem.classList.add("fn__none");
+ }
return;
}
selectItem = targetItem;
@@ -216,20 +280,22 @@ export class Dock {
documentSelf.onselectstart = null;
documentSelf.onselect = null;
ghostElement?.remove();
- if (item.classList.contains("b3-tooltips")) {
+ if (item.style.opacity !== "0.38") {
return;
}
item.style.opacity = "";
- item.classList.add("b3-tooltips");
- let dock
- if (item.parentElement.parentElement.id === "dockBottom") {
- dock = window.siyuan.layout.bottomDock;
- } else if (item.parentElement.parentElement.id === "dockLeft") {
- dock = window.siyuan.layout.leftDock;
- } else if (item.parentElement.parentElement.id === "dockRight") {
- dock = window.siyuan.layout.rightDock;
+ if (!moveItem.classList.contains("fn__none")) {
+ let dock;
+ if (moveItem.parentElement.parentElement.id === "dockBottom") {
+ dock = window.siyuan.layout.bottomDock;
+ } else if (moveItem.parentElement.parentElement.id === "dockLeft") {
+ dock = window.siyuan.layout.leftDock;
+ } else if (moveItem.parentElement.parentElement.id === "dockRight") {
+ dock = window.siyuan.layout.rightDock;
+ }
+ dock.add(moveItem.parentElement.isSameNode(dock.element.firstElementChild) ? 0 : 1, item, moveItem.previousElementSibling?.getAttribute("data-type"));
}
- dock.add(item.parentElement.isSameNode(dock.element.firstElementChild) ? 0 : 1, item, item.previousElementSibling?.getAttribute("data-type"));
+ moveItem.remove();
};
});
@@ -684,7 +750,7 @@ export class Dock {
this.showDock();
}
- public add(index: number, sourceElement: Element, previousType?:string) {
+ public add(index: number, sourceElement: Element, previousType?: string) {
sourceElement.setAttribute("data-height", "");
sourceElement.setAttribute("data-width", "");
const type = sourceElement.getAttribute("data-type");
@@ -705,8 +771,6 @@ export class Dock {
delete sourceDock.data[type];
// 目标处理
- sourceElement.classList.remove("b3-tooltips__n", "b3-tooltips__ne", "b3-tooltips__nw", "b3-tooltips__s", "b3-tooltips__se", "b3-tooltips__sw", "b3-tooltips__e", "b3-tooltips__w");
- sourceElement.classList.add(`b3-tooltips__${this.getClassDirect(index)}`);
sourceElement.setAttribute("data-index", index.toString());
if (previousType) {
this.element.querySelector(`[data-type="${previousType}"]`).after(sourceElement);
@@ -736,23 +800,6 @@ export class Dock {
delete this.data[key];
}
- private getClassDirect(index: number) {
- let direct = "e";
- switch (this.position) {
- case "Right":
- direct = "w";
- break;
- case "Bottom":
- if (index === 0) {
- direct = "ne";
- } else {
- direct = "nw";
- }
- break;
- }
- return direct;
- }
-
public setSize() {
const activesElement = this.element.querySelectorAll(".dock__item--active");
activesElement.forEach((item) => {
@@ -792,7 +839,7 @@ export class Dock {
if (typeof tabIndex === "undefined" && !TYPES.includes(item.type)) {
return;
}
- html += `
+ html += `">
`;
this.data[item.type] = true;
@@ -805,7 +852,7 @@ export class Dock {
this.element.firstElementChild.lastElementChild.insertAdjacentHTML("beforebegin", html);
}
} else {
- this.element.firstElementChild.innerHTML = `${html}
+ this.element.firstElementChild.innerHTML = `${html}
`;
}
diff --git a/app/src/menus/dock.ts b/app/src/menus/dock.ts
index b99a2e74a6..a9f13db9c7 100644
--- a/app/src/menus/dock.ts
+++ b/app/src/menus/dock.ts
@@ -1,5 +1,4 @@
import {MenuItem} from "./Menu";
-import {saveLayout} from "../layout/util";
const moveMenuItem = (label: string, target: Element) => {
window.sout.tracker("invoked");
diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts
index f4f239f2bb..09837e2915 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -1,185 +1,175 @@
-import {addScript, addScriptSync} from "../protyle/util/addScript";
-import {Constants} from "../constants";
-import {onMessage} from "./util/onMessage";
-import {genUUID} from "../util/genID";
-import {hasClosestBlock, hasClosestByAttribute, hasTopClosestByClassName} from "../protyle/util/hasClosest";
-import {Model} from "../layout/Model";
-import "../assets/scss/mobile.scss";
-import {Menus} from "../menus";
-import {addBaseURL, getIdFromSYProtocol, isSYProtocol, setNoteBook} from "../util/pathName";
-import {handleTouchEnd, handleTouchMove, handleTouchStart} from "./util/touch";
-import {fetchGet, fetchPost} from "../util/fetch";
-import {initFramework} from "./util/initFramework";
-import {addGA, initAssets, loadAssets} from "../util/assets";
-import {bootSync} from "../dialog/processSystem";
-import {initMessage, showMessage} from "../dialog/message";
-import {goBack} from "./util/MobileBackFoward";
-import {hideKeyboardToolbar, showKeyboardToolbar} from "./util/keyboardToolbar";
-import {getLocalStorage, writeText} from "../protyle/util/compatibility";
-import {getCurrentEditor, openMobileFileById} from "./editor";
-import {getSearch} from "../util/functions";
-import {initRightMenu} from "./menu";
-import {openChangelog} from "../boot/openChangelog";
-import {registerServiceWorker} from "../util/serviceWorker";
-import {loadPlugins} from "../plugin/loader";
-import { SillotEnv } from "../sillot";
-import {saveScroll} from "../protyle/scroll/saveScroll";
-import {removeBlock} from "../protyle/wysiwyg/remove";
-import {isNotEditBlock} from "../protyle/wysiwyg/getBlock";
-import {updateCardHV} from "../card/util";
-import {mobileKeydown} from "./util/keydown";
-import {correctHotkey} from "../boot/globalEvent/commonHotkey";
-import { exportIDB } from "../sillot/util/sillot-idb-backup-and-restore";
-import {hideAllElements, hideElements} from "../protyle/ui/hideElements";
-
-class App {
- public plugins: import("../plugin").Plugin[] = [];
- public appId: string;
-
- constructor() {
- if (!window.webkit?.messageHandlers && !window.JSAndroid) {
- registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
- }
- addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
- addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
- addBaseURL();
- this.appId = Constants.SIYUAN_APPID;
- window.siyuan = {
- zIndex: 10,
- notebooks: [],
- transactions: [],
- reqIds: {},
- backStack: [],
- dialogs: [],
- blockPanels: [],
- mobile: {},
- ws: new Model({
- app: this,
- id: genUUID(),
- type: "main",
- msgCallback: (data) => {
- this.plugins.forEach((plugin) => {
- plugin.eventBus.emit("ws-main", data);
- });
- onMessage(this, data);
- }
- })
- };
- new SillotEnv();
- window.Sillot.androidRestartSiYuan = ()=>{
- const overlay = document.querySelector('#SillotOverlay') as HTMLElement;
- overlay.style.display = "block";
- exportIDB().then(() => {
- hideAllElements(["util"]);
- fetchPost("/api/sillot/androidReboot", {force: true}, (response) => {
- window.location.href = "siyuan://androidRestartSiYuan";
- });
- })
- };
- // 不能使用 touchstart,否则会被 event.stopImmediatePropagation() 阻塞
- window.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
- if (!window.siyuan.menus.menu.element.contains(event.target) && !hasClosestByAttribute(event.target, "data-menu", "true")) {
- window.siyuan.menus.menu.remove();
- }
- const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
- if (copyElement) {
- let text = copyElement.parentElement.nextElementSibling.textContent.trimEnd();
- text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
- writeText(text);
- showMessage(window.siyuan.languages.copied, 2000);
- event.preventDefault();
- }
- });
- window.addEventListener("beforeunload", () => {
- window.siyuan.mobile.editor?.protyle ? saveScroll(window.siyuan.mobile.editor.protyle) : null;
- }, false);
- window.addEventListener("pagehide", () => {
- window.siyuan.mobile.editor?.protyle ? saveScroll(window.siyuan.mobile.editor.protyle) : null;
- }, false);
- // 判断手机横竖屏状态
- window.matchMedia("(orientation:portrait)").addEventListener("change", () => {
- updateCardHV();
- });
- fetchPost("/api/system/getConf", {}, async (confResponse) => {
- window.siyuan.config = confResponse.data.conf;
- correctHotkey(siyuanApp);
- await loadPlugins(this);
- getLocalStorage(() => {
- fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
- window.siyuan.languages = lauguages;
- window.siyuan.menus = new Menus(this);
- document.title = window.siyuan.languages.siyuanNote;
- bootSync();
- loadAssets(confResponse.data.conf.appearance);
- initMessage();
- initAssets();
- fetchPost("/api/setting/getCloudUser", {}, userResponse => {
- window.siyuan.user = userResponse.data;
- fetchPost("/api/system/getEmojiConf", {}, emojiResponse => {
- window.siyuan.emojis = emojiResponse.data as IEmoji[];
- setNoteBook(() => {
- initRightMenu(this); // 前置避免 initFramework crash 影响
- window.sout.tracker("initRightMenu() resolved");
- initFramework(this, confResponse.data.start);
- window.sout.tracker("initFramework() resolved");
- openChangelog();
- });
- });
- });
- addGA();
- });
- });
- document.addEventListener("touchstart", handleTouchStart, false);
- document.addEventListener("touchmove", handleTouchMove, false);
- document.addEventListener("touchend", (event) => {
- handleTouchEnd(event, siyuanApp);
- }, false);
- window.addEventListener("keydown", (event) => {
- mobileKeydown(siyuanApp, event);
- });
- // 移动端删除键 https://github.com/siyuan-note/siyuan/issues/9259
- window.addEventListener("keydown", (event) => {
- if (getSelection().rangeCount > 0) {
- const range = getSelection().getRangeAt(0);
- const editor = getCurrentEditor();
- if (range.toString() === "" &&
- editor && editor.protyle.wysiwyg.element.contains(range.startContainer) &&
- !event.altKey && (event.key === "Backspace" || event.key === "Delete")) {
- const nodeElement = hasClosestBlock(range.startContainer);
- if (nodeElement && isNotEditBlock(nodeElement)) {
- nodeElement.classList.add("protyle-wysiwyg--select");
- removeBlock(editor.protyle, nodeElement, range, event.key);
- event.stopPropagation();
- event.preventDefault();
- return;
- }
- }
- }
- });
- });
- }
-}
-
-const siyuanApp = new App();
-
-// https://github.com/siyuan-note/siyuan/issues/8441
-window.reconnectWebSocket = () => {
- window.siyuan.ws.send("ping", {});
- window.siyuan.mobile.files.send("ping", {});
- window.siyuan.mobile.editor?.protyle.ws.send("ping", {});
- window.siyuan.mobile.popEditor?.protyle.ws.send("ping", {});
-};
-window.goBack = goBack;
-window.showKeyboardToolbar = (height) => {
- document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.outerHeight / 2 - 42).toString());
- showKeyboardToolbar();
-};
-window.hideKeyboardToolbar = hideKeyboardToolbar;
-window.openFileByURL = (openURL) => {
- if (openURL && isSYProtocol(openURL)) {
- openMobileFileById(siyuanApp, getIdFromSYProtocol(openURL),
- getSearch("focus", openURL) === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
- return true;
- }
- return false;
-};
+import {addScript, addScriptSync} from "../protyle/util/addScript";
+import {Constants} from "../constants";
+import {onMessage} from "./util/onMessage";
+import {genUUID} from "../util/genID";
+import {hasClosestBlock, hasClosestByAttribute, hasTopClosestByClassName} from "../protyle/util/hasClosest";
+import {Model} from "../layout/Model";
+import "../assets/scss/mobile.scss";
+import {Menus} from "../menus";
+import {addBaseURL, getIdFromSYProtocol, isSYProtocol, setNoteBook} from "../util/pathName";
+import {handleTouchEnd, handleTouchMove, handleTouchStart} from "./util/touch";
+import {fetchGet, fetchPost} from "../util/fetch";
+import {initFramework} from "./util/initFramework";
+import {addGA, initAssets, loadAssets} from "../util/assets";
+import {bootSync} from "../dialog/processSystem";
+import {initMessage, showMessage} from "../dialog/message";
+import {goBack} from "./util/MobileBackFoward";
+import {hideKeyboardToolbar, showKeyboardToolbar} from "./util/keyboardToolbar";
+import {getLocalStorage, writeText} from "../protyle/util/compatibility";
+import {getCurrentEditor, openMobileFileById} from "./editor";
+import {getSearch} from "../util/functions";
+import {initRightMenu} from "./menu";
+import {openChangelog} from "../boot/openChangelog";
+import {registerServiceWorker} from "../util/serviceWorker";
+import {loadPlugins} from "../plugin/loader";
+import { SillotEnv } from "../sillot";
+import {saveScroll} from "../protyle/scroll/saveScroll";
+import {removeBlock} from "../protyle/wysiwyg/remove";
+import {isNotEditBlock} from "../protyle/wysiwyg/getBlock";
+import {updateCardHV} from "../card/util";
+import {mobileKeydown} from "./util/keydown";
+import {correctHotkey} from "../boot/globalEvent/commonHotkey";
+import { exportIDB } from "../sillot/util/sillot-idb-backup-and-restore";
+import {hideAllElements, hideElements} from "../protyle/ui/hideElements";
+
+class App {
+ public plugins: import("../plugin").Plugin[] = [];
+ public appId: string;
+
+ constructor() {
+ if (!window.webkit?.messageHandlers && !window.JSAndroid) {
+ registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
+ }
+ addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
+ addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
+ addBaseURL();
+ this.appId = Constants.SIYUAN_APPID;
+ window.siyuan = {
+ zIndex: 10,
+ notebooks: [],
+ transactions: [],
+ reqIds: {},
+ backStack: [],
+ dialogs: [],
+ blockPanels: [],
+ mobile: {},
+ ws: new Model({
+ app: this,
+ id: genUUID(),
+ type: "main",
+ msgCallback: (data) => {
+ this.plugins.forEach((plugin) => {
+ plugin.eventBus.emit("ws-main", data);
+ });
+ onMessage(this, data);
+ }
+ })
+ };
+ new SillotEnv();
+ // 不能使用 touchstart,否则会被 event.stopImmediatePropagation() 阻塞
+ window.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
+ if (!window.siyuan.menus.menu.element.contains(event.target) && !hasClosestByAttribute(event.target, "data-menu", "true")) {
+ window.siyuan.menus.menu.remove();
+ }
+ const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
+ if (copyElement) {
+ let text = copyElement.parentElement.nextElementSibling.textContent.trimEnd();
+ text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
+ writeText(text);
+ showMessage(window.siyuan.languages.copied, 2000);
+ event.preventDefault();
+ }
+ });
+ window.addEventListener("beforeunload", () => {
+ window.siyuan.mobile.editor?.protyle ? saveScroll(window.siyuan.mobile.editor.protyle) : null;
+ }, false);
+ window.addEventListener("pagehide", () => {
+ window.siyuan.mobile.editor?.protyle ? saveScroll(window.siyuan.mobile.editor.protyle) : null;
+ }, false);
+ // 判断手机横竖屏状态
+ window.matchMedia("(orientation:portrait)").addEventListener("change", () => {
+ updateCardHV();
+ });
+ fetchPost("/api/system/getConf", {}, async (confResponse) => {
+ window.siyuan.config = confResponse.data.conf;
+ correctHotkey(siyuanApp);
+ await loadPlugins(this);
+ getLocalStorage(() => {
+ fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => {
+ window.siyuan.languages = lauguages;
+ window.siyuan.menus = new Menus(this);
+ document.title = window.siyuan.languages.siyuanNote;
+ bootSync();
+ loadAssets(confResponse.data.conf.appearance);
+ initMessage();
+ initAssets();
+ fetchPost("/api/setting/getCloudUser", {}, userResponse => {
+ window.siyuan.user = userResponse.data;
+ fetchPost("/api/system/getEmojiConf", {}, emojiResponse => {
+ window.siyuan.emojis = emojiResponse.data as IEmoji[];
+ setNoteBook(() => {
+ initRightMenu(this); // 前置避免 initFramework crash 影响
+ window.sout.tracker("initRightMenu() resolved");
+ initFramework(this, confResponse.data.start);
+ window.sout.tracker("initFramework() resolved");
+ openChangelog();
+ });
+ });
+ });
+ addGA();
+ });
+ });
+ document.addEventListener("touchstart", handleTouchStart, false);
+ document.addEventListener("touchmove", handleTouchMove, false);
+ document.addEventListener("touchend", (event) => {
+ handleTouchEnd(event, siyuanApp);
+ }, false);
+ window.addEventListener("keydown", (event) => {
+ mobileKeydown(siyuanApp, event);
+ });
+ // 移动端删除键 https://github.com/siyuan-note/siyuan/issues/9259
+ window.addEventListener("keydown", (event) => {
+ if (getSelection().rangeCount > 0) {
+ const range = getSelection().getRangeAt(0);
+ const editor = getCurrentEditor();
+ if (range.toString() === "" &&
+ editor && editor.protyle.wysiwyg.element.contains(range.startContainer) &&
+ !event.altKey && (event.key === "Backspace" || event.key === "Delete")) {
+ const nodeElement = hasClosestBlock(range.startContainer);
+ if (nodeElement && isNotEditBlock(nodeElement)) {
+ nodeElement.classList.add("protyle-wysiwyg--select");
+ removeBlock(editor.protyle, nodeElement, range, event.key);
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
+ }
+ }
+ });
+ });
+ }
+}
+
+const siyuanApp = new App();
+
+// https://github.com/siyuan-note/siyuan/issues/8441
+window.reconnectWebSocket = () => {
+ window.siyuan.ws.send("ping", {});
+ window.siyuan.mobile.files.send("ping", {});
+ window.siyuan.mobile.editor?.protyle.ws.send("ping", {});
+ window.siyuan.mobile.popEditor?.protyle.ws.send("ping", {});
+};
+window.goBack = goBack;
+window.showKeyboardToolbar = (height) => {
+ document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.outerHeight / 2 - 42).toString());
+ showKeyboardToolbar();
+};
+window.hideKeyboardToolbar = hideKeyboardToolbar;
+window.openFileByURL = (openURL) => {
+ if (openURL && isSYProtocol(openURL)) {
+ openMobileFileById(siyuanApp, getIdFromSYProtocol(openURL),
+ getSearch("focus", openURL) === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
+ return true;
+ }
+ return false;
+};
diff --git a/app/src/mobile/menu/index.ts b/app/src/mobile/menu/index.ts
index 68aa90ac19..ac51610c80 100644
--- a/app/src/mobile/menu/index.ts
+++ b/app/src/mobile/menu/index.ts
@@ -1,5 +1,6 @@
import {popSearch} from "./search";
import {initAppearance} from "../settings/appearance";
+import { initAppearanceReact } from "../settings/appearance_react";
import {closePanel} from "../util/closePanel";
import {mountHelp, newDailyNote, newNotebook} from "../../util/mount";
import {repos} from "../../config/repos";
@@ -21,6 +22,7 @@ import {newFile} from "../../util/newFile";
import {afterLoadPlugin} from "../../plugin/loader";
import {Menu} from "../../plugin/Menu";
import {commandPanel} from "../../boot/globalEvent/command/panel";
+import { initDevOptions } from "../settings/devOptions";
export const popMenu = () => {
window.sout.tracker("invoked");
@@ -90,9 +92,12 @@ export const initRightMenu = (app: App) => {
+
+
`;
};
+
+export const processClonePHElement = (item:Element) => {
+ if (item.getAttribute("data-type") === "NodeHTMLBlock") {
+ const phElement = item.querySelector("protyle-html");
+ phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(phElement.getAttribute("data-content")));
+ }
+ return item;
+}
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index f7f9b0210c..68f7e737f0 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -1,351 +1,348 @@
-import {focusByRange} from "./selection";
-import {fetchPost} from "../../util/fetch";
-import {Constants} from "../../constants";
-
-export const openByMobile = (uri: string, from?: string) => {
- window.sout.tracker("invoked");
- if (!uri) {
- return;
- }
- if (window.siyuan.config.system.container === "ios") {
- window.location.href = uri;
- } else if (isInAndroid()) {
- console.warn(uri);
- if (from?.startsWith("export")) {
- // 特殊情况直接调用
- window.JSAndroid.openExternal(uri);
- return;
- }
- const toolbarOpenBy = document.querySelector("#toolbarOpenBy");
- const toolbarConsole = document.querySelector("#toolbarConsole");
- if (toolbarOpenBy && toolbarConsole) {
- const existingUri = toolbarOpenBy.getAttribute("data-uri");
-
- // 只有在首次调用时才更新uri和绑定事件
- if (!existingUri) {
- toolbarConsole.classList.add("fn__none");
- toolbarOpenBy.classList.remove("fn__none");
- toolbarOpenBy.removeAttribute("data-refBlockId"); // 避免冲突
- toolbarOpenBy.addEventListener("click", () => {
- toolbarOpenBy.classList.add("fn__none");
- toolbarConsole.classList.remove("fn__none");
- const updatedUri = toolbarOpenBy.getAttribute("data-uri");
- if (updatedUri) {
- window.JSAndroid.openExternal(updatedUri);
- toolbarOpenBy.removeAttribute("data-uri");
- }
- });
-
- // 更新"data-uri"值
- toolbarOpenBy.setAttribute("data-uri", uri);
- if (!toolbarOpenBy.classList.contains("flash-blue")) {
- toolbarOpenBy.classList.add("flash-blue");
- setTimeout(() => {
- toolbarOpenBy.classList.remove("flash-blue");
- }, 200);
- }
- } else {
- // 更新"data-uri"值
- toolbarOpenBy.setAttribute("data-uri", uri);
- if (!toolbarOpenBy.classList.contains("flash-blue")) {
- toolbarOpenBy.classList.add("flash-blue");
- setTimeout(() => {
- toolbarOpenBy.classList.remove("flash-blue");
- }, 200);
- }
- }
- } else {
- // 如果找不到元素,则直接调用
- window.JSAndroid.openExternal(uri);
- }
- } else {
- window.open(uri);
- }
-};
-
-export const readText = () => {
- window.sout.tracker("invoked");
- if (isInAndroid()) {
- return window.JSAndroid.readClipboard();
- }
- return navigator.clipboard.readText();
-};
-
-export const writeText = (text: string) => {
- window.sout.tracker("invoked");
- 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 (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 {
- 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 = async (text: string) => {
- window.sout.tracker("invoked");
- text = text.replace(new RegExp(Constants.ZWSP, "g"), ""); // `复制纯文本` 时移除所有零宽空格 https://github.com/siyuan-note/siyuan/issues/6674
- await writeText(text);
-};
-
-// 用户 iPhone 点击延迟/需要双击的处理
-export const getEventName = () => {
- if (isIPhone()) {
- return "touchstart";
- } else {
- return "click";
- }
-};
-
-export const isOnlyMeta = (event: KeyboardEvent | MouseEvent) => {
- // window.sout.tracker("invoked"); // 这里调用频繁
- 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) => {
- // window.sout.tracker("invoked"); // 这里调用频繁
- if (!event.metaKey && !event.ctrlKey) {
- return true;
- }
- return false;
-};
-
-export const isHuawei = () => {
- return window.siyuan.config.system.osPlatform.toLowerCase().indexOf("huawei") > -1;
-};
-
-export const isIPhone = () => {
- return navigator.userAgent.indexOf("iPhone") > -1;
-};
-
-export const isIPad = () => {
- return navigator.userAgent.indexOf("iPad") > -1;
-};
-
-export const isMac = () => {
- return navigator.platform.toUpperCase().indexOf("MAC") > -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;
-};
-
-// Mac,Windows 快捷键展示
-export const updateHotkeyTip = (hotkey: string) => {
- // window.sout.tracker("invoked"); // 这里调用频繁
- if (isMac()) {
- return hotkey;
- }
-
- const KEY_MAP = new Map(Object.entries({
- "⌘": "Ctrl",
- "⌃": "Ctrl",
- "⇧": "Shift",
- "⌥": "Alt",
- "⇥": "Tab",
- "⌫": "Backspace",
- "⌦": "Delete",
- "↩": "Enter",
- }));
-
- const keys = [];
-
- if ((hotkey.indexOf("⌘") > -1 || hotkey.indexOf("⌃") > -1)) keys.push(KEY_MAP.get("⌘"));
- if (hotkey.indexOf("⇧") > -1) keys.push(KEY_MAP.get("⇧"));
- if (hotkey.indexOf("⌥") > -1) keys.push(KEY_MAP.get("⌥"));
-
- // 不能去最后一个,需匹配 F2
- const lastKey = hotkey.replace(/⌘|⇧|⌥|⌃/g, "");
- if (lastKey) {
- keys.push(KEY_MAP.get(lastKey) || lastKey);
- }
-
- return keys.join("+");
-};
-
-export const getLocalStorage = (cb: () => void) => {
- window.sout.tracker("invoked");
- 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}
- defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
- defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
- defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
- defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr}
- defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition}
- defaultStorage[Constants.LOCAL_HISTORY] = {
- notebookId: "%", type: 0, operation: "all"
- };
- 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
- };
- defaultStorage[Constants.LOCAL_EXPORTIMG] = {
- keepFold: false,
- watermark: false
- };
- defaultStorage[Constants.LOCAL_DOCINFO] = {
- id: "",
- };
- defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
- defaultStorage[Constants.LOCAL_SEARCHDATA] = {
- page: 1,
- sort: 0,
- group: 0,
- hasReplace: false,
- method: 0,
- hPath: "",
- idPath: [],
- k: "",
- r: "",
- types: {
- document: window.siyuan.config.search.document,
- heading: window.siyuan.config.search.heading,
- list: window.siyuan.config.search.list,
- listItem: window.siyuan.config.search.listItem,
- codeBlock: window.siyuan.config.search.codeBlock,
- htmlBlock: window.siyuan.config.search.htmlBlock,
- mathBlock: window.siyuan.config.search.mathBlock,
- table: window.siyuan.config.search.table,
- blockquote: window.siyuan.config.search.blockquote,
- superBlock: window.siyuan.config.search.superBlock,
- paragraph: window.siyuan.config.search.paragraph,
- embedBlock: window.siyuan.config.search.embedBlock,
- databaseBlock: window.siyuan.config.search.databaseBlock,
- },
- replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES),
- };
- defaultStorage[Constants.LOCAL_ZOOM] = 1;
-
- [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].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);
- }
- cb();
- });
-};
-
-export const setStorageVal = (key: string, val: any) => {
- window.sout.tracker("invoked");
- fetchPost("/api/storage/setLocalStorageVal", {
- app: Constants.SIYUAN_APPID,
- key,
- val,
- });
-};
+import {focusByRange} from "./selection";
+import {fetchPost} from "../../util/fetch";
+import {Constants} from "../../constants";
+
+export const openByMobile = (uri: string, from?: string) => {
+ window.sout.tracker("invoked");
+ if (!uri) {
+ return;
+ }
+ if (window.siyuan.config.system.container === "ios") {
+ window.location.href = uri;
+ } else if (isInAndroid()) {
+ console.warn(uri);
+ if (from?.startsWith("export")) {
+ // 特殊情况直接调用
+ window.JSAndroid.openExternal(uri);
+ return;
+ }
+ const toolbarOpenBy = document.querySelector("#toolbarOpenBy");
+ if (toolbarOpenBy) {
+ const existingUri = toolbarOpenBy.getAttribute("data-uri");
+
+ // 只有在首次调用时才更新uri和绑定事件
+ if (!existingUri) {
+ toolbarOpenBy.classList.remove("fn__none");
+ toolbarOpenBy.removeAttribute("data-refBlockId"); // 避免冲突
+ toolbarOpenBy.addEventListener("click", () => {
+ toolbarOpenBy.classList.add("fn__none");
+ const updatedUri = toolbarOpenBy.getAttribute("data-uri");
+ if (updatedUri) {
+ window.JSAndroid.openExternal(updatedUri);
+ toolbarOpenBy.removeAttribute("data-uri");
+ }
+ });
+
+ // 更新"data-uri"值
+ toolbarOpenBy.setAttribute("data-uri", uri);
+ if (!toolbarOpenBy.classList.contains("flash-blue")) {
+ toolbarOpenBy.classList.add("flash-blue");
+ setTimeout(() => {
+ toolbarOpenBy.classList.remove("flash-blue");
+ }, 200);
+ }
+ } else {
+ // 更新"data-uri"值
+ toolbarOpenBy.setAttribute("data-uri", uri);
+ if (!toolbarOpenBy.classList.contains("flash-blue")) {
+ toolbarOpenBy.classList.add("flash-blue");
+ setTimeout(() => {
+ toolbarOpenBy.classList.remove("flash-blue");
+ }, 200);
+ }
+ }
+ } else {
+ // 如果找不到元素,则直接调用
+ window.JSAndroid.openExternal(uri);
+ }
+ } else {
+ window.open(uri);
+ }
+};
+
+export const readText = () => {
+ window.sout.tracker("invoked");
+ if (isInAndroid()) {
+ return window.JSAndroid.readClipboard();
+ }
+ return navigator.clipboard.readText();
+};
+
+export const writeText = (text: string) => {
+ window.sout.tracker("invoked");
+ 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 (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 {
+ 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 = async (text: string) => {
+ window.sout.tracker("invoked");
+ text = text.replace(new RegExp(Constants.ZWSP, "g"), ""); // `复制纯文本` 时移除所有零宽空格 https://github.com/siyuan-note/siyuan/issues/6674
+ await writeText(text);
+};
+
+// 用户 iPhone 点击延迟/需要双击的处理
+export const getEventName = () => {
+ if (isIPhone()) {
+ return "touchstart";
+ } else {
+ return "click";
+ }
+};
+
+export const isOnlyMeta = (event: KeyboardEvent | MouseEvent) => {
+ // window.sout.tracker("invoked"); // 这里调用频繁
+ 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) => {
+ // window.sout.tracker("invoked"); // 这里调用频繁
+ if (!event.metaKey && !event.ctrlKey) {
+ return true;
+ }
+ return false;
+};
+
+export const isHuawei = () => {
+ return window.siyuan.config.system.osPlatform.toLowerCase().indexOf("huawei") > -1;
+};
+
+export const isIPhone = () => {
+ return navigator.userAgent.indexOf("iPhone") > -1;
+};
+
+export const isIPad = () => {
+ return navigator.userAgent.indexOf("iPad") > -1;
+};
+
+export const isMac = () => {
+ return navigator.platform.toUpperCase().indexOf("MAC") > -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;
+};
+
+// Mac,Windows 快捷键展示
+export const updateHotkeyTip = (hotkey: string) => {
+ // window.sout.tracker("invoked"); // 这里调用频繁
+ if (isMac()) {
+ return hotkey;
+ }
+
+ const KEY_MAP = new Map(Object.entries({
+ "⌘": "Ctrl",
+ "⌃": "Ctrl",
+ "⇧": "Shift",
+ "⌥": "Alt",
+ "⇥": "Tab",
+ "⌫": "Backspace",
+ "⌦": "Delete",
+ "↩": "Enter",
+ }));
+
+ const keys = [];
+
+ if ((hotkey.indexOf("⌘") > -1 || hotkey.indexOf("⌃") > -1)) keys.push(KEY_MAP.get("⌘"));
+ if (hotkey.indexOf("⇧") > -1) keys.push(KEY_MAP.get("⇧"));
+ if (hotkey.indexOf("⌥") > -1) keys.push(KEY_MAP.get("⌥"));
+
+ // 不能去最后一个,需匹配 F2
+ const lastKey = hotkey.replace(/⌘|⇧|⌥|⌃/g, "");
+ if (lastKey) {
+ keys.push(KEY_MAP.get(lastKey) || lastKey);
+ }
+
+ return keys.join("+");
+};
+
+export const getLocalStorage = (cb: () => void) => {
+ window.sout.tracker("invoked");
+ 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}
+ defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
+ defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
+ defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
+ defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr}
+ defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition}
+ defaultStorage[Constants.LOCAL_HISTORY] = {
+ notebookId: "%", type: 0, operation: "all"
+ };
+ 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
+ };
+ defaultStorage[Constants.LOCAL_EXPORTIMG] = {
+ keepFold: false,
+ watermark: false
+ };
+ defaultStorage[Constants.LOCAL_DOCINFO] = {
+ id: "",
+ };
+ defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
+ defaultStorage[Constants.LOCAL_SEARCHDATA] = {
+ page: 1,
+ sort: 0,
+ group: 0,
+ hasReplace: false,
+ method: 0,
+ hPath: "",
+ idPath: [],
+ k: "",
+ r: "",
+ types: {
+ document: window.siyuan.config.search.document,
+ heading: window.siyuan.config.search.heading,
+ list: window.siyuan.config.search.list,
+ listItem: window.siyuan.config.search.listItem,
+ codeBlock: window.siyuan.config.search.codeBlock,
+ htmlBlock: window.siyuan.config.search.htmlBlock,
+ mathBlock: window.siyuan.config.search.mathBlock,
+ table: window.siyuan.config.search.table,
+ blockquote: window.siyuan.config.search.blockquote,
+ superBlock: window.siyuan.config.search.superBlock,
+ paragraph: window.siyuan.config.search.paragraph,
+ embedBlock: window.siyuan.config.search.embedBlock,
+ databaseBlock: window.siyuan.config.search.databaseBlock,
+ },
+ replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES),
+ };
+ defaultStorage[Constants.LOCAL_ZOOM] = 1;
+
+ [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].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);
+ }
+ cb();
+ });
+};
+
+export const setStorageVal = (key: string, val: any) => {
+ window.sout.tracker("invoked");
+ fetchPost("/api/storage/setLocalStorageVal", {
+ app: Constants.SIYUAN_APPID,
+ key,
+ val,
+ });
+};
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index b3428f5960..c450ab95c3 100644
--- a/app/src/protyle/util/selection.ts
+++ b/app/src/protyle/util/selection.ts
@@ -499,11 +499,12 @@ export const focusByRange = (range: Range) => {
selection.addRange(range);
};
-export const focusBlock = (element: Element, parentElement?: HTMLElement, toStart = true) => {
+export const focusBlock = (element: Element, parentElement?: HTMLElement, toStart = true): false | Range => {
window.sout.tracker("invoked");
if (!element) {
return false;
}
+
// hr、嵌入块、数学公式、iframe、音频、视频、图表渲染块等,删除段落块后,光标位置矫正 https://github.com/siyuan-note/siyuan/issues/4143
if (element.classList.contains("render-node") || element.classList.contains("iframe") || element.classList.contains("hr") || element.classList.contains("av")) {
const range = document.createRange();
@@ -623,6 +624,11 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
return range;
} else if (parentElement) {
parentElement.focus();
+ } else {
+ // li 下面为 hr、嵌入块、数学公式、iframe、音频、视频、图表渲染块等时递归处理
+ if (element.classList.contains("li")) {
+ return focusBlock(element.querySelector("[data-node-id]"), parentElement, toStart);
+ }
}
return false;
};
diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts
index 69a1079490..33ab234ca3 100644
--- a/app/src/protyle/wysiwyg/commonHotkey.ts
+++ b/app/src/protyle/wysiwyg/commonHotkey.ts
@@ -16,6 +16,7 @@ import {onGet} from "../util/onGet";
import {Constants} from "../../constants";
// import * as dayjs from "dayjs";
import {net2LocalAssets} from "../breadcrumb/action";
+import {processClonePHElement} from "../render/util";
import {formatDate} from "sofill/mid";
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {
@@ -219,15 +220,7 @@ export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {
tempElement.setAttribute("data-marker", (orderIndex) + ".");
tempElement.querySelector(".protyle-action--order").textContent = (orderIndex) + ".";
}
- if (tempElement.dataset.type === "NodeHTMLBlock") {
- const phElement = tempElement.querySelector("protyle-html");
- const content = phElement.getAttribute("data-content");
- phElement.setAttribute("data-content", "");
- nodeElements[0].after(tempElement);
- phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(content));
- } else {
- nodeElements[0].after(tempElement);
- }
+ nodeElements[0].after(processClonePHElement(tempElement));
doOperations.push({
action: "insert",
data: tempElement.outerHTML,
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index c12f8e8354..1131436df5 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1861,9 +1861,6 @@ export class WYSIWYG {
isComposition = false;
const range = getEditorRange(this.element);
const blockElement = hasClosestBlock(range.startContainer);
- if (blockElement && blockElement.getAttribute("data-type") === "NodeHTMLBlock") {
- return;
- }
if (!blockElement) {
return;
}
@@ -1899,10 +1896,6 @@ export class WYSIWYG {
if (!blockElement) {
return;
}
- if (blockElement && blockElement.getAttribute("data-type") === "NodeHTMLBlock") {
- event.stopPropagation();
- return;
- }
if ([":", "(", "【", "(", "[", "{", "「", "『", "#", "/", "、"].includes(event.data)) {
protyle.hint.enableExtend = true;
}
@@ -2103,21 +2096,18 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table
/// #if MOBILE
console.warn(`refBlockId : ${refBlockId}`); // 文档中直接点击双链
const toolbarOpenBy = document.querySelector("#toolbarOpenBy");
- const toolbarConsole = document.querySelector("#toolbarConsole");
- if (toolbarOpenBy && toolbarConsole) {
+ if (toolbarOpenBy) {
const existingUri = toolbarOpenBy.getAttribute("data-refBlockId");
// 只有在首次调用时才更新uri和绑定事件
if (!existingUri) {
- toolbarConsole.classList.add("fn__none");
toolbarOpenBy.classList.remove("fn__none");
toolbarOpenBy.removeAttribute("data-uri"); // 避免冲突
toolbarOpenBy.addEventListener("click", () => {
toolbarOpenBy.classList.add("fn__none");
- toolbarConsole.classList.remove("fn__none");
const updatedUri = toolbarOpenBy.getAttribute("data-refBlockId");
if (updatedUri) {
- console.warn(`refBlockId : ${updatedUri} -> openMobileFileById() ? (toolbarOpenBy && toolbarConsole)`);
+ console.warn(`refBlockId : ${updatedUri} -> openMobileFileById() ? (toolbarOpenBy)`);
toolbarOpenBy.removeAttribute("data-refBlockId");
openMobileFileById(protyle.app, updatedUri, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
activeBlur();
@@ -2150,7 +2140,7 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table
} else {
// 如果找不到元素,则直接调用
toolbarOpenBy.removeAttribute("data-refBlockId");
- console.warn(`refBlockId : ${refBlockId} -> openMobileFileById() ? not(toolbarOpenBy && toolbarConsole)`);
+ console.warn(`refBlockId : ${refBlockId} -> openMobileFileById() ? not(toolbarOpenBy)`);
openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
activeBlur();
hideKeyboardToolbar();
@@ -2471,7 +2461,7 @@ if (tableElement && tableElement.isSameNode(item) && item.querySelector(".table
const imgElement = hasTopClosestByClassName(event.target, "img");
if (!event.shiftKey && !ctrlIsPressed && imgElement) {
imgElement.classList.add("img--select");
- const nextSibling = hasNextSibling(imgElement)
+ const nextSibling = hasNextSibling(imgElement);
if (nextSibling) {
if (nextSibling.textContent.startsWith(Constants.ZWSP)) {
range.setStart(nextSibling, 1);
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 84d8e0f392..2a3160fda0 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -31,7 +31,13 @@ import {
import {matchHotKey} from "../util/hotKey";
import {enter, softEnter} from "./enter";
import {fixTable} from "../util/table";
-import {turnsIntoOneTransaction, turnsIntoTransaction, updateBatchTransaction, updateTransaction} from "./transaction";
+import {
+ turnsIntoOneTransaction,
+ turnsIntoTransaction,
+ turnsOneInto,
+ updateBatchTransaction,
+ updateTransaction
+} from "./transaction";
import {fontEvent} from "../toolbar/Font";
import {addSubList, listIndent, listOutdent} from "./list";
import {newFileContentBySelect, rename, replaceFileName} from "../../editor/rename";
@@ -694,7 +700,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
if (event.key === "ArrowDown") {
- if (nodeElement.isSameNode(protyle.wysiwyg.element.lastElementChild)) {
+ if (nodeEditableElement?.textContent.trimRight().substr(position.start).indexOf("\n") === -1 &&
+ nodeElement.isSameNode(protyle.wysiwyg.element.lastElementChild)) {
setLastNodeRange(getContenteditableElement(nodeEditableElement), range, false);
range.collapse(false);
event.stopPropagation();
@@ -1332,10 +1339,73 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return true;
}
}
- if (matchHotKey(window.siyuan.config.keymap.editor.insert.check.custom, event)) {
- protyle.hint.splitChar = "/";
- protyle.hint.lastIndex = -1;
- protyle.hint.fill("* [ ] " + Lute.Caret, protyle);
+ const isMatchList = matchHotKey(window.siyuan.config.keymap.editor.insert.list.custom, event);
+ const isMatchCheck = matchHotKey(window.siyuan.config.keymap.editor.insert.check.custom, event);
+ const isMatchOList = matchHotKey(window.siyuan.config.keymap.editor.insert["ordered-list"].custom, event);
+ if (isMatchList || isMatchOList || isMatchCheck) {
+ const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
+ if (selectsElement.length === 0) {
+ protyle.hint.splitChar = "/";
+ protyle.hint.lastIndex = -1;
+ protyle.hint.fill((isMatchCheck ? "* [ ] " : (isMatchList ? "* " : "1. ")) + Lute.Caret, protyle);
+ } else if (selectsElement.length === 1) {
+ const subType = selectsElement[0].dataset.subtype;
+ const type = selectsElement[0].dataset.type;
+ if (type === "NodeParagraph") {
+ turnsIntoOneTransaction({
+ protyle,
+ selectsElement,
+ type: isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs")
+ });
+ } else if (type === "NodeList") {
+ const id = selectsElement[0].dataset.nodeId;
+ if (subType === "o" && (isMatchList || isMatchCheck)) {
+ turnsOneInto({
+ protyle,
+ nodeElement: selectsElement[0],
+ id,
+ type: isMatchCheck ? "UL2TL" : "OL2UL",
+ });
+ } else if (subType === "t" && (isMatchList || isMatchOList)) {
+ turnsOneInto({
+ protyle,
+ nodeElement: selectsElement[0],
+ id,
+ type: isMatchList ? "TL2UL" : "TL2OL",
+ });
+ } else if (isMatchCheck || isMatchOList) {
+ turnsOneInto({
+ protyle,
+ nodeElement: selectsElement[0],
+ id,
+ type: isMatchCheck ? "OL2TL" : "UL2OL",
+ });
+ }
+ }
+ } else {
+ let isList = false;
+ let isContinue = false;
+ selectsElement.find((item, index) => {
+ if (item.classList.contains("li")) {
+ isList = true;
+ return true;
+ }
+ if (item.nextElementSibling && selectsElement[index + 1] &&
+ item.nextElementSibling.isSameNode(selectsElement[index + 1])) {
+ isContinue = true;
+ } else if (index !== selectsElement.length - 1) {
+ isContinue = false;
+ return true;
+ }
+ });
+ if (!isList && isContinue) {
+ turnsIntoOneTransaction({
+ protyle,
+ selectsElement,
+ type: isMatchCheck ? "Blocks2TLs" : (isMatchList ? "Blocks2ULs" : "Blocks2OLs")
+ });
+ }
+ }
event.preventDefault();
event.stopPropagation();
return;
diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts
index 67a69948e4..70ef3a10a6 100644
--- a/app/src/protyle/wysiwyg/remove.ts
+++ b/app/src/protyle/wysiwyg/remove.ts
@@ -198,13 +198,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
removeBlock(protyle, blockElement, range, type);
return;
}
- // 设置 bq 和代码块光标
- if (["NodeCodeBlock", "NodeTable", "NodeAttributeView"].includes(blockType)) {
- if (blockElement.previousElementSibling) {
- focusBlock(blockElement.previousElementSibling, undefined, false);
- }
- return;
- }
+
if (!blockElement.previousElementSibling && blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote") {
range.insertNode(document.createElement("wbr"));
const blockParentElement = blockElement.parentElement;
@@ -250,6 +244,14 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
removeLi(protyle, blockElement, range, type === "Delete");
return;
}
+ // 设置 bq 和代码块光标
+ // 需放在列表处理后 https://github.com/siyuan-note/siyuan/issues/11606
+ if (["NodeCodeBlock", "NodeTable", "NodeAttributeView"].includes(blockType)) {
+ if (blockElement.previousElementSibling) {
+ focusBlock(blockElement.previousElementSibling, undefined, false);
+ }
+ return;
+ }
if (blockType === "NodeHeading") {
turnsIntoTransaction({
protyle: protyle,
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 511aca6297..d05c557e33 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -1,6 +1,6 @@
-import {fetchPost} from "../../util/fetch";
+import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {focusBlock, focusByWbr, focusSideBlock, getEditorRange} from "../util/selection";
-import {getTopAloneElement} from "./getBlock";
+import {getContenteditableElement, getTopAloneElement} from "./getBlock";
import {Constants} from "../../constants";
import {blockRender} from "../render/blockRender";
import {processRender} from "../util/processCode";
@@ -19,6 +19,7 @@ import {reloadProtyle} from "../util/reload";
import {countBlockWord} from "../../layout/status";
import {isPaidUser, needSubscribe} from "../../util/needSubscribe";
import {resize} from "../util/resize";
+import {processClonePHElement} from "../render/util";
const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
window.sout.tracker("invoked");
@@ -209,7 +210,7 @@ const promiseTransaction = () => {
if (operation.previousID && updateElements.length > 0) {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`)).forEach(item => {
if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" || !hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
- item.after(updateElements[0].cloneNode(true));
+ item.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
hasFind = true;
}
});
@@ -218,9 +219,9 @@ const promiseTransaction = () => {
if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" || !hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
// 列表特殊处理
if (item.firstElementChild?.classList.contains("protyle-action")) {
- item.firstElementChild.after(updateElements[0].cloneNode(true));
+ item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
} else {
- item.prepend(updateElements[0].cloneNode(true));
+ item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));
}
hasFind = true;
}
@@ -644,22 +645,22 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
if (operation.previousID && updateElements.length > 0) {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`)).forEach(item => {
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
- item.after(updateElements[0].cloneNode(true));
+ item.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
hasFind = true;
}
});
} else if (updateElements.length > 0) {
if (!protyle.options.backlinkData && operation.parentID === protyle.block.parentID) {
- protyle.wysiwyg.element.prepend(updateElements[0].cloneNode(true));
+ protyle.wysiwyg.element.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));
hasFind = true;
} else {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.parentID}"]`)).forEach(item => {
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
// 列表特殊处理
if (item.firstElementChild?.classList.contains("protyle-action")) {
- item.firstElementChild.after(updateElements[0].cloneNode(true));
+ item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));
} else {
- item.prepend(updateElements[0].cloneNode(true));
+ item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));
}
hasFind = true;
}
@@ -1034,6 +1035,99 @@ export const turnsIntoTransaction = (options: {
hideElements(["gutter"], options.protyle);
};
+export const turnsOneInto = async (options: {
+ protyle: IProtyle,
+ nodeElement: Element,
+ id: string,
+ type: string,
+ level?: number
+}) => {
+ if (!options.nodeElement.querySelector("wbr")) {
+ getContenteditableElement(options.nodeElement)?.insertAdjacentHTML("afterbegin", "
");
+ }
+ if (options.type === "CancelList" || options.type === "CancelBlockquote") {
+ for await(const item of options.nodeElement.querySelectorAll('[data-type="NodeHeading"][fold="1"]')) {
+ const itemId = item.getAttribute("data-node-id");
+ item.removeAttribute("fold");
+ const response = await fetchSyncPost("/api/transactions", {
+ session: options.protyle.id,
+ app: Constants.SIYUAN_APPID,
+ transactions: [{
+ doOperations: [{
+ action: "unfoldHeading",
+ id: itemId,
+ }],
+ undoOperations: [{
+ action: "foldHeading",
+ id: itemId
+ }],
+ }]
+ });
+ options.protyle.undo.add([{
+ action: "unfoldHeading",
+ id: itemId,
+ }], [{
+ action: "foldHeading",
+ id: itemId
+ }], options.protyle);
+ item.insertAdjacentHTML("afterend", response.data[0].doOperations[0].retData);
+ }
+ }
+ const oldHTML = options.nodeElement.outerHTML;
+ const previousId = options.nodeElement.previousElementSibling?.getAttribute("data-node-id");
+ const parentId = options.nodeElement.parentElement.getAttribute("data-node-id") || options.protyle.block.parentID;
+ // @ts-ignore
+ const newHTML = options.protyle.lute[options.type](options.nodeElement.outerHTML, options.level);
+ options.nodeElement.outerHTML = newHTML;
+ if (options.type === "CancelList" || options.type === "CancelBlockquote") {
+ const tempElement = document.createElement("template");
+ tempElement.innerHTML = newHTML;
+ const doOperations: IOperation[] = [{
+ action: "delete",
+ id: options.id
+ }];
+ const undoOperations: IOperation[] = [];
+ let tempPreviousId = previousId;
+ Array.from(tempElement.content.children).forEach((item) => {
+ const tempId = item.getAttribute("data-node-id");
+ doOperations.push({
+ action: "insert",
+ data: item.outerHTML,
+ id: tempId,
+ previousID: tempPreviousId,
+ parentID: parentId
+ });
+ undoOperations.push({
+ action: "delete",
+ id: tempId
+ });
+ tempPreviousId = tempId;
+ });
+ undoOperations.push({
+ action: "insert",
+ data: oldHTML,
+ id: options.id,
+ previousID: previousId,
+ parentID: parentId
+ });
+ transaction(options.protyle, doOperations, undoOperations);
+ } else {
+ updateTransaction(options.protyle, options.id, newHTML, oldHTML);
+ }
+ focusByWbr(options.protyle.wysiwyg.element, getEditorRange(options.protyle.wysiwyg.element));
+ options.protyle.wysiwyg.element.querySelectorAll('[data-type~="block-ref"]').forEach(item => {
+ if (item.textContent === "") {
+ fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
+ item.innerHTML = response.data;
+ });
+ }
+ });
+ blockRender(options.protyle, options.protyle.wysiwyg.element);
+ processRender(options.protyle.wysiwyg.element);
+ highlightRender(options.protyle.wysiwyg.element);
+ avRender(options.protyle.wysiwyg.element, options.protyle);
+};
+
const updateRef = (protyle: IProtyle, id: string, index = 0) => {
window.sout.tracker("invoked");
if (index > 6) {
diff --git a/app/src/sillot/index.ts b/app/src/sillot/index.ts
index d148a6a1d1..f1c5bb516c 100644
--- a/app/src/sillot/index.ts
+++ b/app/src/sillot/index.ts
@@ -1,67 +1,66 @@
-import { highlightRender } from "../protyle/render/highlightRender";
-const lodash = require("lodash");
-import { exAce } from "./ace";
-import { Toastify } from "./react-toastify";
-import { HotToast } from "./react-hot-toast";
-import * as React from "react"; // 兼容性好
-import * as ReactDOM from "react-dom"; // 兼容性好
-import Swal from "sweetalert2";
-import {sout} from 'sofill/core'
-import { MusicPlayer } from "./react-music-player";
-import VConsole from 'vconsole';
-import {
- focusBlock,
- focusByOffset,
- focusSideBlock,
- focusByRange,
-} from "../protyle/util/selection";
-import { bS } from "./bridge";
-
-export class SillotEnv {
- constructor() {
- window.sout = sout();
- window.Sillot = {
- status: { IDBloaded: false, disableDocSetPadding: false },
- funs: { hljsRender: highlightRender },
- lute: null,
- androidRestartSiYuan: null,
- };
- window.__ = {
- ace: null,
- Swal: Swal,
- toastify: new Toastify({ id: "app1", limit: 5, theme: "colored" }),
- hottt: new HotToast({ id: "app3" }),
- };
- window._ = lodash;
- window.React = React;
- window.ReactDOM = ReactDOM;
- exAce();
- // new MusicPlayer({id: 'app4'})
- window.nodebugger = {
- focusBlock: focusBlock,
- focusByOffset: focusByOffset,
- focusSideBlock: focusSideBlock,
- focusByRange: focusByRange,
- /// #if !BROWSER
- bS: new bS(),
- ///#endif
- };
- window.vConsole = new VConsole({ theme: 'dark' });
- window.vConsole.hideSwitch();
-
- // 接下来即可照常使用 `console` 等方法
- console.log(window.vConsole.version);
- document.querySelector("#toolbarConsole")?.addEventListener("click", () => {
- if (document.querySelector("#toolbarConsole")?.getAttribute("data-mode") === "0") {
- window.vConsole?.showSwitch();
- document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "1");
- } else {
- window.vConsole?.hideSwitch();
- document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "0");
- }
- });
- // 结束调试后,可移除掉
- // window.vConsole.destroy();
-
- }
-}
+import { highlightRender } from "../protyle/render/highlightRender";
+const lodash = require("lodash");
+import { exAce } from "./ace";
+import { Toastify } from "./react-toastify";
+import { HotToast } from "./react-hot-toast";
+import * as React from "react"; // 兼容性好
+import * as ReactDOM from "react-dom"; // 兼容性好
+import Swal from "sweetalert2";
+import {sout} from 'sofill/core'
+import { MusicPlayer } from "./react-music-player";
+import VConsole from 'vconsole';
+import {
+ focusBlock,
+ focusByOffset,
+ focusSideBlock,
+ focusByRange,
+} from "../protyle/util/selection";
+import { bS } from "./bridge";
+
+export class SillotEnv {
+ constructor() {
+ window.sout = sout();
+ window.Sillot = {
+ status: { IDBloaded: false, disableDocSetPadding: false },
+ funs: { hljsRender: highlightRender },
+ lute: null,
+ };
+ window.__ = {
+ ace: null,
+ Swal: Swal,
+ toastify: new Toastify({ id: "app1", limit: 5, theme: "colored" }),
+ hottt: new HotToast({ id: "app3" }),
+ };
+ window._ = lodash;
+ window.React = React;
+ window.ReactDOM = ReactDOM;
+ exAce();
+ // new MusicPlayer({id: 'app4'})
+ window.nodebugger = {
+ focusBlock: focusBlock,
+ focusByOffset: focusByOffset,
+ focusSideBlock: focusSideBlock,
+ focusByRange: focusByRange,
+ /// #if !BROWSER
+ bS: new bS(),
+ ///#endif
+ };
+ window.vConsole = new VConsole({ theme: 'dark' });
+ window.vConsole.hideSwitch();
+
+ // 接下来即可照常使用 `console` 等方法
+ console.log(window.vConsole.version);
+ document.querySelector("#toolbarConsole")?.addEventListener("click", () => {
+ if (document.querySelector("#toolbarConsole")?.getAttribute("data-mode") === "0") {
+ window.vConsole?.showSwitch();
+ document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "1");
+ } else {
+ window.vConsole?.hideSwitch();
+ document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "0");
+ }
+ });
+ // 结束调试后,可移除掉
+ // window.vConsole.destroy();
+
+ }
+}
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index d4e60bf363..f80dffe98f 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -172,7 +172,6 @@ interface Window {
requestPermissionActivity(id: string, Msg: string, cb: string): boolean
requestPermission(id: string, Msg: string): boolean
exitSillotAndroid(): void
- restartSillotAndroid(): void
androidReboot(): void
savePictureByURL(uri: string): void
// sillot extend end
diff --git a/app/src/types/sillot.d.ts b/app/src/types/sillot.d.ts
index 4dbd49217c..415f06d046 100644
--- a/app/src/types/sillot.d.ts
+++ b/app/src/types/sillot.d.ts
@@ -1,55 +1,54 @@
-// declare module 'react-dom'
-declare module "monaco-editor-nls/locale/zh-hans";
-declare module "*.jsx";
-declare module "*.js";
-
-// REF https://www.tslang.cn/docs/handbook/declaration-merging.html
-interface Window {
- // Sillot extend
- Sillot: ISillot;
- nodebugger: any;
- _: any;
- __: ISillotDoubleUnderline;
- sout: ISout;
- React: any;
- ReactDOM: any;
- vConsole: any;
-}
-
-interface ISillot {
- status: {
- IDBloaded: boolean;
- disableDocSetPadding: boolean;
- };
- funs: {
- hljsRender: any;
- };
- lute: Lute;
- androidRestartSiYuan: ()=>void;
-}
-
-interface ISout {
- debug: boolean;
- showAll(): void;
- log(m: any): void;
- slog(m: any): void;
- print(m: any, head?: string): void;
- info(m: any, head?: string): void;
- success(m: any, head?: string): void;
- warn(m: any, head?: string): void;
- unsure(m: any, head?: string): void;
- ops(m: any, head?: string): void;
- error(m: any, head?: string): void;
- good(m: any, head?: string): void;
- wink(m: any, head?: string): void;
- bad(m: any, head?: string): void;
- tracker(m: any, ...additionalMessages: any[]): void;
- table(m: Array