diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts index 8c66f487e..87122f86c 100644 --- a/app/src/menus/commonMenuItem.ts +++ b/app/src/menus/commonMenuItem.ts @@ -1,10 +1,9 @@ /// #if !BROWSER import {shell} from "electron"; /// #endif -import {getDockByType} from "../layout/util"; import {confirmDialog} from "../dialog/confirmDialog"; import {getSearch, isMobile, isValidAttrName} from "../util/functions"; -import {isLocalPath, movePathTo, moveToPath, pathPosix} from "../util/pathName"; +import {isLocalPath, movePathTo, moveToPath, pathPosix, setNotebookName} from "../util/pathName"; import {MenuItem} from "./Menu"; import {saveExport} from "../protyle/export"; import {openByMobile, writeText} from "../protyle/util/compatibility"; @@ -12,30 +11,22 @@ import {fetchPost, fetchSyncPost} from "../util/fetch"; import {hideMessage, showMessage} from "../dialog/message"; import {Dialog} from "../dialog"; import {focusBlock, focusByRange, getEditorRange} from "../protyle/util/selection"; -import {updateTransaction} from "../protyle/wysiwyg/transaction"; /// #if !MOBILE -import {getAllModels} from "../layout/getAll"; -import {Bookmark} from "../layout/dock/Bookmark"; import {openAsset, openBy} from "../editor/util"; /// #endif import {rename, replaceFileName} from "../editor/rename"; -import {matchHotKey} from "../protyle/util/hotKey"; import * as dayjs from "dayjs"; import {Constants} from "../constants"; import {exportImage} from "../protyle/export/util"; import {App} from "../index"; import {renderAVAttribute} from "../protyle/render/av/render"; -const bindAttrInput = (inputElement: HTMLInputElement, confirmElement: Element) => { - inputElement.addEventListener("keydown", (event) => { - if (event.isComposing) { - return; - } - if (matchHotKey("⌘↩", event)) { - confirmElement.dispatchEvent(new CustomEvent("click", {detail: "confirm"})); - event.stopPropagation(); - event.preventDefault(); - } +const bindAttrInput = (inputElement: HTMLInputElement, id: string) => { + inputElement.addEventListener("change", () => { + fetchPost("/api/attr/setBlockAttrs", { + id, + attrs: {[inputElement.dataset.name]: inputElement.value} + }); }); }; @@ -158,7 +149,7 @@ export const openFileWechatNotify = (protyle: IProtyle) => { }); }; -const genAttr = (attrs: IObject, focusName = "bookmark", cb: (dialog: Dialog, rms: string[]) => void) => { +const genAttr = (attrs: IObject, focusName = "bookmark") => { let customHTML = ""; let notifyHTML = ""; let hasAV = false; @@ -175,14 +166,6 @@ const genAttr = (attrs: IObject, focusName = "bookmark", cb: (dialog: Dialog, rm `; } else if (item.indexOf("custom-av") > -1) { hasAV = true; -// avHTML += ``; } else if (item.indexOf("custom") > -1) { customHTML += `