🎨 Improve #commonMenu menu (#16141)

* 改进菜单的 data-name 属性值和选项的 data-id 属性值

fix https://github.com/siyuan-note/siyuan/issues/12506 https://github.com/siyuan-note/siyuan/issues/16133

* 改进菜单的 data-name 属性值和选项的 data-id 属性值

fix https://github.com/siyuan-note/siyuan/issues/12506 https://github.com/siyuan-note/siyuan/issues/16133

* 更新数据库排序菜单文案

* 改进菜单的 data-name 属性值和选项的 data-id 属性值

fix https://github.com/siyuan-note/siyuan/issues/12506 https://github.com/siyuan-note/siyuan/issues/16133

使用正则 (?:get|set)Attribute\("data-name"|new Menu\((?:"|Constants) 来搜索

* 改进菜单的 data-name 属性值和选项的 data-subname 属性值

fix https://github.com/siyuan-note/siyuan/issues/12506 https://github.com/siyuan-note/siyuan/issues/15075

* 改进菜单的 data-name 属性值和选项的 data-subname 属性值

fix https://github.com/siyuan-note/siyuan/issues/12506 https://github.com/siyuan-note/siyuan/issues/15075
This commit is contained in:
Jeffrey Chen 2025-10-18 10:41:11 +08:00 committed by GitHub
parent 3e7177d22f
commit 8725e5daa8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 209 additions and 75 deletions

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "إلغاء القفل المؤقت", "cancelTempUnlock": "إلغاء القفل المؤقت",
"addFilter": "إضافة عامل تصفية", "addFilter": "إضافة عامل تصفية",
"removeFilters": "مسح عامل تصفية", "removeFilters": "مسح عامل تصفية",
"addSort": "إضافة ترتيب",
"removeSorts": "مسح الترتيب",
"checked": "مكتمل", "checked": "مكتمل",
"unchecked": "غير مكتمل", "unchecked": "غير مكتمل",
"percentChecked": "نسبة المكتمل", "percentChecked": "نسبة المكتمل",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Temporäres Entsperren abbrechen", "cancelTempUnlock": "Temporäres Entsperren abbrechen",
"addFilter": "Filter hinzufügen", "addFilter": "Filter hinzufügen",
"removeFilters": "Filter zurücksetzen", "removeFilters": "Filter zurücksetzen",
"addSort": "Sortierung hinzufügen",
"removeSorts": "Sortierung zurücksetzen",
"checked": "Überprüft", "checked": "Überprüft",
"unchecked": "Nicht überprüft", "unchecked": "Nicht überprüft",
"percentChecked": "Prozent geprüft", "percentChecked": "Prozent geprüft",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Cancel temporary unlock", "cancelTempUnlock": "Cancel temporary unlock",
"addFilter": "Add filter", "addFilter": "Add filter",
"removeFilters": "Clear filter", "removeFilters": "Clear filter",
"addSort": "Add sort",
"removeSorts": "Clear sort",
"checked": "Checked", "checked": "Checked",
"unchecked": "Unchecked", "unchecked": "Unchecked",
"percentChecked": "Percent checked", "percentChecked": "Percent checked",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Cancelar desbloqueo temporal", "cancelTempUnlock": "Cancelar desbloqueo temporal",
"addFilter": "Agregar filtro", "addFilter": "Agregar filtro",
"removeFilters": "Borrar filtro", "removeFilters": "Borrar filtro",
"addSort": "Agregar ordenación",
"removeSorts": "Borrar ordenación",
"checked": "marcado", "checked": "marcado",
"unchecked": "desmarcado", "unchecked": "desmarcado",
"percentChecked": "Porcentaje comprobado", "percentChecked": "Porcentaje comprobado",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Annuler le déverrouillage temporaire", "cancelTempUnlock": "Annuler le déverrouillage temporaire",
"addFilter": "Ajouter un filtre", "addFilter": "Ajouter un filtre",
"removeFilters": "Effacer le filtre", "removeFilters": "Effacer le filtre",
"addSort": "Ajouter un tri",
"removeSorts": "Effacer le tri",
"checked": "Coché", "checked": "Coché",
"unchecked": "Décoché", "unchecked": "Décoché",
"percentChecked": "Pourcentage vérifié", "percentChecked": "Pourcentage vérifié",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "בטל שחרור זמני", "cancelTempUnlock": "בטל שחרור זמני",
"addFilter": "הוסף מסנן", "addFilter": "הוסף מסנן",
"removeFilters": "נקה מסננים", "removeFilters": "נקה מסננים",
"addSort": "הוסף מיון",
"removeSorts": "נקה מיון",
"checked": "נבדק", "checked": "נבדק",
"unchecked": "לא נבדק", "unchecked": "לא נבדק",
"percentChecked": "אחוז נבדק", "percentChecked": "אחוז נבדק",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Annulla sblocco temporaneo", "cancelTempUnlock": "Annulla sblocco temporaneo",
"addFilter": "Aggiungi filtro", "addFilter": "Aggiungi filtro",
"removeFilters": "Pulisci filtro", "removeFilters": "Pulisci filtro",
"addSort": "Aggiungi ordinamento",
"removeSorts": "Pulisci ordinamento",
"checked": "Selezionato", "checked": "Selezionato",
"unchecked": "Deselezionato", "unchecked": "Deselezionato",
"percentChecked": "Percentuale selezionata", "percentChecked": "Percentuale selezionata",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "一時的なロック解除をキャンセル", "cancelTempUnlock": "一時的なロック解除をキャンセル",
"addFilter": "フィルタを追加", "addFilter": "フィルタを追加",
"removeFilters": "フィルタを削除", "removeFilters": "フィルタを削除",
"addSort": "ソートを追加",
"removeSorts": "ソートを削除",
"checked": "チェック済み", "checked": "チェック済み",
"unchecked": "未チェック", "unchecked": "未チェック",
"percentChecked": "チェック済みの割合", "percentChecked": "チェック済みの割合",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Anuluj tymczasowe odblokowanie", "cancelTempUnlock": "Anuluj tymczasowe odblokowanie",
"addFilter": "Dodaj filtr", "addFilter": "Dodaj filtr",
"removeFilters": "Wyczyść filtr", "removeFilters": "Wyczyść filtr",
"addSort": "Dodaj sortowanie",
"removeSorts": "Wyczyść sortowanie",
"checked": "Zaznaczone", "checked": "Zaznaczone",
"unchecked": "Nie zaznaczone", "unchecked": "Nie zaznaczone",
"percentChecked": "Procent zaznaczonych", "percentChecked": "Procent zaznaczonych",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Cancelar desbloqueio temporário", "cancelTempUnlock": "Cancelar desbloqueio temporário",
"addFilter": "Adicionar filtro", "addFilter": "Adicionar filtro",
"removeFilters": "Limpar filtro", "removeFilters": "Limpar filtro",
"addSort": "Adicionar ordenação",
"removeSorts": "Limpar ordenação",
"checked": "Marcado", "checked": "Marcado",
"unchecked": "Desmarcado", "unchecked": "Desmarcado",
"percentChecked": "Porcentagem marcada", "percentChecked": "Porcentagem marcada",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "Отменить временную разблокировку", "cancelTempUnlock": "Отменить временную разблокировку",
"addFilter": "Добавить фильтр", "addFilter": "Добавить фильтр",
"removeFilters": "Очистить фильтр", "removeFilters": "Очистить фильтр",
"addSort": "Добавить сортировку",
"removeSorts": "Очистить сортировку",
"checked": "Отмечено", "checked": "Отмечено",
"unchecked": "Не отмечено", "unchecked": "Не отмечено",
"percentChecked": "Процент отмеченных", "percentChecked": "Процент отмеченных",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "取消暫時解鎖", "cancelTempUnlock": "取消暫時解鎖",
"addFilter": "新增篩選條件", "addFilter": "新增篩選條件",
"removeFilters": "清空篩選規則", "removeFilters": "清空篩選規則",
"addSort": "新增排序條件",
"removeSorts": "清空排序規則",
"checked": "已完成", "checked": "已完成",
"unchecked": "未完成", "unchecked": "未完成",
"percentChecked": "已完成佔比", "percentChecked": "已完成佔比",

View file

@ -231,6 +231,8 @@
"cancelTempUnlock": "取消临时解锁", "cancelTempUnlock": "取消临时解锁",
"addFilter": "添加筛选条件", "addFilter": "添加筛选条件",
"removeFilters": "清空筛选规则", "removeFilters": "清空筛选规则",
"addSort": "添加排序条件",
"removeSorts": "清空排序规则",
"checked": "已完成", "checked": "已完成",
"unchecked": "未完成", "unchecked": "未完成",
"percentChecked": "已完成占比", "percentChecked": "已完成占比",

View file

@ -161,7 +161,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
elements.forEach(item => { elements.forEach(item => {
ids.push(item.getAttribute("data-node-id")); ids.push(item.getAttribute("data-node-id"));
}); });
const menu = new Menu("ai", () => { const menu = new Menu(Constants.MENU_AI, () => {
focusByRange(protyle.toolbar.range); focusByRange(protyle.toolbar.range);
}); });
let customHTML = ""; let customHTML = "";

View file

@ -220,7 +220,7 @@ const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
} else { } else {
// 浮窗上点击菜单,浮窗不能消失 https://ld246.com/article/1632668091023 // 浮窗上点击菜单,浮窗不能消失 https://ld246.com/article/1632668091023
const menuElement = hasClosestByClassName(target, "b3-menu"); const menuElement = hasClosestByClassName(target, "b3-menu");
if (menuElement && menuElement.getAttribute("data-name") !== "docTreeMore") { if (menuElement && menuElement.getAttribute("data-name") !== Constants.MENU_DOC_TREE_MORE) {
const blockPanel = window.siyuan.blockPanels.find((item) => { const blockPanel = window.siyuan.blockPanels.find((item) => {
if (item.element.style.zIndex < menuElement.style.zIndex) { if (item.element.style.zIndex < menuElement.style.zIndex) {
return true; return true;

View file

@ -442,7 +442,7 @@ export const execByCommand = async (options: {
case "move": case "move":
if (!isFileFocus) { if (!isFileFocus) {
const nodeElement = hasClosestBlock(range.startContainer); const nodeElement = hasClosestBlock(range.startContainer);
if (protyle.title?.editElement.contains(range.startContainer) || !nodeElement || window.siyuan.menus.menu.element.getAttribute("data-name") === "titleMenu") { if (protyle.title?.editElement.contains(range.startContainer) || !nodeElement || window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_TITLE) {
movePathTo((toPath, toNotebook) => { movePathTo((toPath, toNotebook) => {
moveToPath([protyle.path], toNotebook[0], toPath[0]); moveToPath([protyle.path], toNotebook[0], toPath[0]);
}, [protyle.path], range); }, [protyle.path], range);

View file

@ -224,6 +224,68 @@ export abstract class Constants {
public static readonly DIALOG_OPENWORKSPACE = "dialog-openworkspace"; // 打开工作空间 public static readonly DIALOG_OPENWORKSPACE = "dialog-openworkspace"; // 打开工作空间
public static readonly DIALOG_SAVEWORKSPACE = "dialog-saveworkspace"; // 保存工作空间 public static readonly DIALOG_SAVEWORKSPACE = "dialog-saveworkspace"; // 保存工作空间
// menu
public static readonly MENU_BAR_WORKSPACE = "barWorkspace"; // 顶栏主菜单
public static readonly MENU_BAR_PLUGIN = "topBarPlugin"; // 顶栏插件菜单
public static readonly MENU_BAR_ZOOM = "barZoom"; // 顶栏缩放菜单
public static readonly MENU_BAR_MORE = "barmore"; // 顶栏外观菜单
public static readonly MENU_STATUS_HELP = "statusHelp"; // 状态栏帮助菜单
public static readonly MENU_STATUS_BACKGROUND_TASK = "statusBackgroundTask"; // 状态栏后台任务菜单
public static readonly MENU_DOCK_MOBILE = "dockMobileMenu"; // 移动端侧栏插件选项菜单
public static readonly MENU_BLOCK_SINGLE = "block-single"; // 单选块菜单
public static readonly MENU_BLOCK_MULTI = "block-multi"; // 多选块菜单
public static readonly MENU_TITLE = "titleMenu"; // 文档块菜单
public static readonly MENU_TITLE_PROTYLE = "title-protyle"; // 在 Protyle 触发的文档块菜单
public static readonly MENU_TITLE_BREADCRUMB = "title-breadcrumb"; // 在面包屑触发的文档块菜单
public static readonly MENU_BREADCRUMB_MORE = "breadcrumbMore"; // 面包屑更多菜单
public static readonly MENU_BREADCRUMB_MOBILE_PATH = "breadcrumb-mobile-path"; // 移动端面包屑菜单
public static readonly MENU_DOC_TREE_MORE = "docTreeMore"; // 侧栏文档树右键菜单
public static readonly MENU_DOC_TREE_MORE_NOTEBOOK = "docTreeMore-notebook"; // 侧栏文档树右键菜单,单个笔记本
public static readonly MENU_DOC_TREE_MORE_DOC = "docTreeMore-doc"; // 侧栏文档树右键菜单,单个文档
public static readonly MENU_DOC_TREE_MORE_DOCS = "docTreeMore-docs"; // 侧栏文档树右键菜单,多个文档
public static readonly MENU_TAG = "tagMenu"; // 侧栏标签菜单
public static readonly MENU_BOOKMARK = "bookmarkMenu"; // 侧栏书签菜单
public static readonly MENU_OUTLINE_CONTEXT = "outline-context"; // 大纲标题右键菜单
public static readonly MENU_OUTLINE_EXPAND_LEVEL = "outline-expand-level"; // 大纲展开层级菜单
public static readonly MENU_AV_VIEW = "av-view"; // 数据库视图标题菜单
public static readonly MENU_AV_HEADER_CELL = "av-header-cell"; // 数据库字段标题菜单
public static readonly MENU_AV_HEADER_ADD = "av-header-add"; // 数据库添加字段菜单
public static readonly MENU_AV_ADD_FILTER = "av-add-filter"; // 数据库添加筛选条件菜单
public static readonly MENU_AV_ADD_SORT = "av-add-sort"; // 数据库添加排序条件菜单
public static readonly MENU_AV_COL_OPTION = "av-col-option"; // 数据库单选多选字段的选项编辑菜单
public static readonly MENU_AV_COL_FORMAT_NUMBER = "av-col-format-number"; // 数据库数字字段格式化菜单
public static readonly MENU_AV_GROUP_DATE = "avGroupDate"; // 数据库日期字段分组菜单的日期菜单
public static readonly MENU_AV_GROUP_SORT = "avGroupSort"; // 数据库日期字段分组菜单的排序菜单
public static readonly MENU_AV_ASSET_EDIT = "av-asset-edit"; // 数据库资源字段链接或资源文件菜单
public static readonly MENU_AV_CALC = "av-calc"; // 数据库计算菜单
public static readonly MENU_AV_PAGE_SIZE = "av-page-size"; // 数据库条目数菜单
public static readonly MENU_SEARCH_MORE = "searchMore"; // 搜索更多菜单
public static readonly MENU_SEARCH_METHOD = "searchMethod"; // 搜索方式菜单
public static readonly MENU_SEARCH_ASSET_MORE = "searchAssetMore"; // 资源文件搜索更多菜单
public static readonly MENU_SEARCH_ASSET_METHOD = "searchAssetMethod"; // 资源文件搜索方式菜单
public static readonly MENU_SEARCH_UNREF_MORE = "searchUnRefMore"; // 列出引用失效的块的更多菜单
public static readonly MENU_SEARCH_HISTORY = "search-history"; // 搜索历史菜单
public static readonly MENU_SEARCH_REPLACE_HISTORY = "search-replace-history"; // 替换历史菜单
public static readonly MENU_SEARCH_ASSET_HISTORY = "search-asset-history"; // 资源文件搜索历史菜单
public static readonly MENU_MOVE_PATH_HISTORY = "move-path-history"; // 移动文档窗口搜索历史菜单
public static readonly MENU_BACKGROUND_ASSET = "background-asset"; // 资源文件选择器菜单
public static readonly MENU_AI = "ai"; // 块 AI 菜单
public static readonly MENU_TAB = "tab"; // 页签右键菜单
public static readonly MENU_TAB_LIST = "tabList"; // 页签切换菜单
public static readonly MENU_INLINE_CONTEXT = "inline-context"; // 文本右键菜单
public static readonly MENU_INLINE_IMG = "inline-img"; // 图片元素菜单
public static readonly MENU_INLINE_FILE_ANNOTATION_REF = "inline-file-annotation-ref"; // PDF 标注元素菜单
public static readonly MENU_INLINE_REF = "inline-block-ref"; // 块引用元素菜单
public static readonly MENU_INLINE_A = "inline-a"; // 超链接元素菜单
public static readonly MENU_INLINE_TAG = "inline-tag"; // 行级标签元素菜单
public static readonly MENU_INLINE_MATH = "inline-math"; // 行级公式元素菜单
// timeout // timeout
public static readonly TIMEOUT_OPENDIALOG = 50; public static readonly TIMEOUT_OPENDIALOG = 50;
public static readonly TIMEOUT_DBLCLICK = 190; public static readonly TIMEOUT_DBLCLICK = 190;

View file

@ -461,7 +461,7 @@ export const progressBackgroundTask = (tasks: { action: string }[]) => {
if (tasks.length === 0) { if (tasks.length === 0) {
backgroundTaskElement.classList.add("fn__none"); backgroundTaskElement.classList.add("fn__none");
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "statusBackgroundTask") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_STATUS_BACKGROUND_TASK) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
} }
} else { } else {

View file

@ -654,7 +654,7 @@ export class Wnd {
private renderTabList(target: HTMLElement) { private renderTabList(target: HTMLElement) {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "tabList") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_TAB_LIST) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
@ -703,7 +703,7 @@ export class Wnd {
current: item.classList.contains("item--focus") current: item.classList.contains("item--focus")
}).element); }).element);
}); });
window.siyuan.menus.menu.element.setAttribute("data-name", "tabList"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_TAB_LIST);
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({ window.siyuan.menus.menu.popup({
x: rect.left + rect.width, x: rect.left + rect.width,

View file

@ -788,8 +788,10 @@ export class Outline extends Model {
*/ */
private showExpandLevelMenu(target: HTMLElement) { private showExpandLevelMenu(target: HTMLElement) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_OUTLINE_EXPAND_LEVEL);
for (let i = 1; i <= 6; i++) { for (let i = 1; i <= 6; i++) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: `heading${i}`,
icon: `iconH${i}`, icon: `iconH${i}`,
label: window.siyuan.languages[`heading${i}`], label: window.siyuan.languages[`heading${i}`],
click: () => this.expandToLevel(i) click: () => this.expandToLevel(i)
@ -867,9 +869,11 @@ export class Outline extends Model {
} }
const currentLevel = this.getHeadingLevel(element); const currentLevel = this.getHeadingLevel(element);
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_OUTLINE_CONTEXT);
// 升级 // 升级
if (currentLevel > 1) { if (currentLevel > 1) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "upgrade",
icon: "iconUp", icon: "iconUp",
label: window.siyuan.languages.upgrade, label: window.siyuan.languages.upgrade,
click: () => { click: () => {
@ -889,6 +893,7 @@ export class Outline extends Model {
// 降级 // 降级
if (currentLevel < 6) { if (currentLevel < 6) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "downgrade",
icon: "iconDown", icon: "iconDown",
label: window.siyuan.languages.downgrade, label: window.siyuan.languages.downgrade,
click: () => { click: () => {
@ -945,10 +950,11 @@ export class Outline extends Model {
}).element); }).element);
} }
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({id: "separator_1", type: "separator"}).element);
// 在前面插入同级标题 // 在前面插入同级标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "insertSameLevelHeadingBefore",
icon: "iconBefore", icon: "iconBefore",
label: window.siyuan.languages.insertSameLevelHeadingBefore, label: window.siyuan.languages.insertSameLevelHeadingBefore,
click: () => { click: () => {
@ -973,6 +979,7 @@ export class Outline extends Model {
// 在后面插入同级标题 // 在后面插入同级标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "insertSameLevelHeadingAfter",
icon: "iconAfter", icon: "iconAfter",
label: window.siyuan.languages.insertSameLevelHeadingAfter, label: window.siyuan.languages.insertSameLevelHeadingAfter,
click: () => { click: () => {
@ -1006,6 +1013,7 @@ export class Outline extends Model {
// 添加子标题 // 添加子标题
if (currentLevel < 6) { // 只有当前级别小于6时才能添加子标题 if (currentLevel < 6) { // 只有当前级别小于6时才能添加子标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "addChildHeading",
icon: "iconAdd", icon: "iconAdd",
label: window.siyuan.languages.addChildHeading, label: window.siyuan.languages.addChildHeading,
click: () => { click: () => {
@ -1045,10 +1053,11 @@ export class Outline extends Model {
}).element); }).element);
} }
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({id: "separator_2", type: "separator"}).element);
// 复制带子标题 // 复制带子标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "copyHeadings1",
icon: "iconCopy", icon: "iconCopy",
label: `${window.siyuan.languages.copy} ${window.siyuan.languages.headings1}`, label: `${window.siyuan.languages.copy} ${window.siyuan.languages.headings1}`,
click: () => { click: () => {
@ -1070,6 +1079,7 @@ export class Outline extends Model {
// 剪切带子标题 // 剪切带子标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "cutHeadings1",
icon: "iconCut", icon: "iconCut",
label: `${window.siyuan.languages.cut} ${window.siyuan.languages.headings1}`, label: `${window.siyuan.languages.cut} ${window.siyuan.languages.headings1}`,
click: () => { click: () => {
@ -1117,6 +1127,7 @@ export class Outline extends Model {
// 删除 // 删除
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "deleteHeadings1",
icon: "iconTrashcan", icon: "iconTrashcan",
label: `${window.siyuan.languages.delete} ${window.siyuan.languages.headings1}`, label: `${window.siyuan.languages.delete} ${window.siyuan.languages.headings1}`,
click: () => { click: () => {
@ -1150,10 +1161,11 @@ export class Outline extends Model {
} }
}).element); }).element);
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({id: "separator_3", type: "separator"}).element);
// 展开子标题 // 展开子标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "expandChildHeading",
icon: "iconExpand", icon: "iconExpand",
label: window.siyuan.languages.expandChildHeading, label: window.siyuan.languages.expandChildHeading,
accelerator: updateHotkeyTip("⌘") + window.siyuan.languages.clickArrow, accelerator: updateHotkeyTip("⌘") + window.siyuan.languages.clickArrow,
@ -1162,6 +1174,7 @@ export class Outline extends Model {
// 折叠子标题 // 折叠子标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "foldChildHeading",
icon: "iconContract", icon: "iconContract",
label: window.siyuan.languages.foldChildHeading, label: window.siyuan.languages.foldChildHeading,
accelerator: updateHotkeyTip("⌘") + window.siyuan.languages.clickArrow, accelerator: updateHotkeyTip("⌘") + window.siyuan.languages.clickArrow,
@ -1170,6 +1183,7 @@ export class Outline extends Model {
// 展开同级标题 // 展开同级标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "expandSameLevelHeading",
icon: "iconExpand", icon: "iconExpand",
label: window.siyuan.languages.expandSameLevelHeading, label: window.siyuan.languages.expandSameLevelHeading,
accelerator: updateHotkeyTip("⌥") + window.siyuan.languages.clickArrow, accelerator: updateHotkeyTip("⌥") + window.siyuan.languages.clickArrow,
@ -1178,6 +1192,7 @@ export class Outline extends Model {
// 折叠同级标题 // 折叠同级标题
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "foldSameLevelHeading",
icon: "iconContract", icon: "iconContract",
label: window.siyuan.languages.foldSameLevelHeading, label: window.siyuan.languages.foldSameLevelHeading,
accelerator: updateHotkeyTip("⌥") + window.siyuan.languages.clickArrow, accelerator: updateHotkeyTip("⌥") + window.siyuan.languages.clickArrow,
@ -1186,6 +1201,7 @@ export class Outline extends Model {
// 全部展开 // 全部展开
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "expandAll",
icon: "iconExpand", icon: "iconExpand",
label: window.siyuan.languages.expandAll, label: window.siyuan.languages.expandAll,
click: () => { click: () => {
@ -1196,6 +1212,7 @@ export class Outline extends Model {
// 全部折叠 // 全部折叠
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "foldAll",
icon: "iconContract", icon: "iconContract",
label: window.siyuan.languages.foldAll, label: window.siyuan.languages.foldAll,
click: () => { click: () => {

View file

@ -39,12 +39,12 @@ export const initStatus = (isWindow = false) => {
break; break;
} else if (target.classList.contains("status__backgroundtask")) { } else if (target.classList.contains("status__backgroundtask")) {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "statusBackgroundTask") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_STATUS_BACKGROUND_TASK) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "statusBackgroundTask"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_STATUS_BACKGROUND_TASK);
JSON.parse(target.getAttribute("data-tasks")).forEach((item: { action: string }) => { JSON.parse(target.getAttribute("data-tasks")).forEach((item: { action: string }) => {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
type: "readonly", type: "readonly",
@ -58,12 +58,12 @@ export const initStatus = (isWindow = false) => {
break; break;
} else if (target.id === "statusHelp") { } else if (target.id === "statusHelp") {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "statusHelp") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_STATUS_HELP) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "statusHelp"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_STATUS_HELP);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.userGuide, label: window.siyuan.languages.userGuide,
icon: "iconHelp", icon: "iconHelp",

View file

@ -75,12 +75,12 @@ export const initBar = (app: App) => {
break; break;
} else if (targetId === "barMore") { } else if (targetId === "barMore") {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "barmore") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_BAR_MORE) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "barmore"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BAR_MORE);
(target.getAttribute("data-hideids") || "").split(",").forEach((itemId) => { (target.getAttribute("data-hideids") || "").split(",").forEach((itemId) => {
const hideElement = toolbarElement.querySelector("#" + itemId); const hideElement = toolbarElement.querySelector("#" + itemId);
const useElement = hideElement.querySelector("use"); const useElement = hideElement.querySelector("use");
@ -127,12 +127,12 @@ export const initBar = (app: App) => {
break; break;
} else if (targetId === "barMode") { } else if (targetId === "barMode") {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "barmode") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_BAR_MORE) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "barmode"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BAR_MORE);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "themeLight", id: "themeLight",
label: window.siyuan.languages.themeLight, label: window.siyuan.languages.themeLight,
@ -191,12 +191,12 @@ export const initBar = (app: App) => {
break; break;
} else if (targetId === "barZoom") { } else if (targetId === "barZoom") {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "barZoom") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_BAR_ZOOM) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "barZoom"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BAR_ZOOM);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.zoomIn, label: window.siyuan.languages.zoomIn,
icon: "iconZoomIn", icon: "iconZoomIn",

View file

@ -120,6 +120,7 @@ export class Menu {
this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen"); this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen");
this.element.removeAttribute("style"); // zIndex this.element.removeAttribute("style"); // zIndex
this.element.removeAttribute("data-name"); // 标识再次点击不消失 this.element.removeAttribute("data-name"); // 标识再次点击不消失
this.element.removeAttribute("data-subname");
this.element.removeAttribute("data-from"); // 标识是否在浮窗内打开 this.element.removeAttribute("data-from"); // 标识是否在浮窗内打开
this.data = undefined; // 移除数据 this.data = undefined; // 移除数据
} }

View file

@ -11,7 +11,7 @@ import {Constants} from "../constants";
export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookmarkObj: Bookmark | MobileBookmarks) => { export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookmarkObj: Bookmark | MobileBookmarks) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "bookmarkMenu") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_BOOKMARK) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
@ -92,6 +92,6 @@ export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookma
} }
}).element); }).element);
} }
window.siyuan.menus.menu.element.setAttribute("data-name", "bookmarkMenu"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BOOKMARK);
window.siyuan.menus.menu.popup({x: event.clientX - 11, y: event.clientY + 11, h: 22, w: 12}); window.siyuan.menus.menu.popup({x: event.clientX - 11, y: event.clientY + 11, h: 22, w: 12});
}; };

View file

@ -32,6 +32,7 @@ import {openByMobile} from "../protyle/util/compatibility";
import {addFilesToDatabase} from "../protyle/render/av/addToDatabase"; import {addFilesToDatabase} from "../protyle/render/av/addToDatabase";
const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => { const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
window.siyuan.menus.menu.element.setAttribute("data-subname", Constants.MENU_DOC_TREE_MORE_DOCS);
const fileItemElement = Array.from(selectItemElements).find(item => { const fileItemElement = Array.from(selectItemElements).find(item => {
if (item.getAttribute("data-type") === "navigation-file") { if (item.getAttribute("data-type") === "navigation-file") {
return true; return true;
@ -187,6 +188,7 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
export const initNavigationMenu = (app: App, liElement: HTMLElement) => { export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_DOC_TREE_MORE);
const fileElement = hasClosestByTag(liElement, "DIV"); const fileElement = hasClosestByTag(liElement, "DIV");
if (!fileElement) { if (!fileElement) {
return window.siyuan.menus.menu; return window.siyuan.menus.menu;
@ -202,6 +204,8 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus"); const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus");
if (selectItemElements.length > 1) { if (selectItemElements.length > 1) {
return initMultiMenu(selectItemElements, app); return initMultiMenu(selectItemElements, app);
} else {
window.siyuan.menus.menu.element.setAttribute("data-subname", Constants.MENU_DOC_TREE_MORE_NOTEBOOK);
} }
const notebookId = liElement.parentElement.getAttribute("data-url"); const notebookId = liElement.parentElement.getAttribute("data-url");
const name = getNotebookName(notebookId); const name = getNotebookName(notebookId);
@ -417,6 +421,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
export const initFileMenu = (app: App, notebookId: string, pathString: string, liElement: Element) => { export const initFileMenu = (app: App, notebookId: string, pathString: string, liElement: Element) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_DOC_TREE_MORE);
const fileElement = hasClosestByTag(liElement, "DIV"); const fileElement = hasClosestByTag(liElement, "DIV");
if (!fileElement) { if (!fileElement) {
return window.siyuan.menus.menu; return window.siyuan.menus.menu;
@ -706,7 +711,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
separatorPosition: "top", separatorPosition: "top",
}); });
} }
window.siyuan.menus.menu.element.setAttribute("data-name", "docTreeMore"); window.siyuan.menus.menu.element.setAttribute("data-subname", Constants.MENU_DOC_TREE_MORE_DOC);
return window.siyuan.menus.menu; return window.siyuan.menus.menu;
}; };

View file

@ -95,7 +95,7 @@ const renderAssetList = (element: Element, k: string, position: IPosition, exts:
}; };
export const assetMenu = (protyle: IProtyle, position: IPosition, callback?: (url: string, name: string) => void, exts?: string[]) => { export const assetMenu = (protyle: IProtyle, position: IPosition, callback?: (url: string, name: string) => void, exts?: string[]) => {
const menu = new Menu("background-asset"); const menu = new Menu(Constants.MENU_BACKGROUND_ASSET);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }
@ -214,6 +214,7 @@ export const fileAnnotationRefMenu = (protyle: IProtyle, refElement: HTMLElement
const id = nodeElement.getAttribute("data-node-id"); const id = nodeElement.getAttribute("data-node-id");
let oldHTML = nodeElement.outerHTML; let oldHTML = nodeElement.outerHTML;
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_FILE_ANNOTATION_REF);
let anchorElement: HTMLInputElement; let anchorElement: HTMLInputElement;
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "idAndAnchor", id: "idAndAnchor",
@ -348,6 +349,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
const id = nodeElement.getAttribute("data-node-id"); const id = nodeElement.getAttribute("data-node-id");
let oldHTML = nodeElement.outerHTML; let oldHTML = nodeElement.outerHTML;
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_REF);
if (!protyle.disabled) { if (!protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "anchor", id: "anchor",
@ -706,6 +708,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
export const contentMenu = (protyle: IProtyle, nodeElement: Element) => { export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
const range = getEditorRange(nodeElement); const range = getEditorRange(nodeElement);
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_CONTEXT);
/// #if MOBILE /// #if MOBILE
protyle.toolbar.showContent(protyle, range, nodeElement); protyle.toolbar.showContent(protyle, range, nodeElement);
/// #else /// #else
@ -1074,6 +1077,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
clientY: number clientY: number
}) => { }) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_IMG);
const nodeElement = hasClosestBlock(assetElement); const nodeElement = hasClosestBlock(assetElement);
if (!nodeElement) { if (!nodeElement) {
return; return;
@ -1085,7 +1089,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
const html = nodeElement.outerHTML; const html = nodeElement.outerHTML;
let src = imgElement.getAttribute("src"); let src = imgElement.getAttribute("src");
if (!src) { if (!src) {
src = "" src = "";
} }
if (!protyle.disabled) { if (!protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
@ -1454,6 +1458,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText = false) => { export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText = false) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_A);
const nodeElement = hasClosestBlock(linkElement); const nodeElement = hasClosestBlock(linkElement);
if (!nodeElement) { if (!nodeElement) {
return; return;
@ -1742,6 +1747,7 @@ style="margin:4px 0;width: ${isMobile() ? "100%" : "360px"}" class="b3-text-fiel
export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => { export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_TAG);
const nodeElement = hasClosestBlock(tagElement); const nodeElement = hasClosestBlock(tagElement);
if (!nodeElement) { if (!nodeElement) {
return; return;
@ -1900,6 +1906,7 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
export const inlineMathMenu = (protyle: IProtyle, element: Element) => { export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_INLINE_MATH);
const nodeElement = hasClosestBlock(element); const nodeElement = hasClosestBlock(element);
if (!nodeElement) { if (!nodeElement) {
return; return;

View file

@ -13,6 +13,7 @@ import {getAllWnds} from "../layout/getAll";
import {Asset} from "../asset"; import {Asset} from "../asset";
import {writeText} from "../protyle/util/compatibility"; import {writeText} from "../protyle/util/compatibility";
import {getAssetName, pathPosix} from "../util/pathName"; import {getAssetName, pathPosix} from "../util/pathName";
import {Constants} from "../constants";
const closeMenu = (tab: Tab) => { const closeMenu = (tab: Tab) => {
const unmodifiedTabs: Tab[] = []; const unmodifiedTabs: Tab[] = [];
@ -181,6 +182,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
export const initTabMenu = (app: App, tab: Tab) => { export const initTabMenu = (app: App, tab: Tab) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_TAB);
closeMenu(tab); closeMenu(tab);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "split", id: "split",

View file

@ -5,10 +5,11 @@ import {escapeHtml} from "../util/escape";
import {renameTag} from "../util/noRelyPCFunction"; import {renameTag} from "../util/noRelyPCFunction";
import {getDockByType} from "../layout/tabUtil"; import {getDockByType} from "../layout/tabUtil";
import {Tag} from "../layout/dock/Tag"; import {Tag} from "../layout/dock/Tag";
import {Constants} from "../constants";
export const openTagMenu = (element: HTMLElement, event: MouseEvent, labelName: string) => { export const openTagMenu = (element: HTMLElement, event: MouseEvent, labelName: string) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "tagMenu") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_TAG) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
@ -36,6 +37,6 @@ export const openTagMenu = (element: HTMLElement, event: MouseEvent, labelName:
}, undefined, true); }, undefined, true);
} }
}).element); }).element);
window.siyuan.menus.menu.element.setAttribute("data-name", "tagMenu"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_TAG);
window.siyuan.menus.menu.popup({x: event.clientX - 11, y: event.clientY + 11, h: 22, w: 12}); window.siyuan.menus.menu.popup({x: event.clientX - 11, y: event.clientY + 11, h: 22, w: 12});
}; };

View file

@ -145,13 +145,13 @@ const togglePinDock = (id: string, dock: Dock, icon: string) => {
export const workspaceMenu = (app: App, rect: DOMRect) => { export const workspaceMenu = (app: App, rect: DOMRect) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "barWorkspace") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_BAR_WORKSPACE) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
fetchPost("/api/system/getWorkspaces", {}, (response) => { fetchPost("/api/system/getWorkspaces", {}, (response) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "barWorkspace"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BAR_WORKSPACE);
if (!window.siyuan.config.readonly) { if (!window.siyuan.config.readonly) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "config", id: "config",

View file

@ -27,7 +27,7 @@ import {showMessage} from "../../dialog/message";
let custom: MobileCustom; let custom: MobileCustom;
const openDockMenu = (app: App) => { const openDockMenu = (app: App) => {
const menu = new Menu("dockMobileMenu"); const menu = new Menu(Constants.MENU_DOCK_MOBILE);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }

View file

@ -18,7 +18,9 @@ export class Menu {
} }
this.menu.remove(); this.menu.remove();
if (!this.isOpen) { if (!this.isOpen) {
this.menu.element.setAttribute("data-name", id || ""); if (id) {
this.menu.element.setAttribute("data-name", id);
}
this.menu.removeCB = closeCB; this.menu.removeCB = closeCB;
} }
} }

View file

@ -7,7 +7,7 @@ import {openSetting} from "../config";
import {Constants} from "../constants"; import {Constants} from "../constants";
export const openTopBarMenu = (app: App, target?: Element) => { export const openTopBarMenu = (app: App, target?: Element) => {
const menu = new Menu("topBarPlugin"); const menu = new Menu(Constants.MENU_BAR_PLUGIN);
/// #if !MOBILE /// #if !MOBILE
menu.addItem({ menu.addItem({
id: "manage", id: "manage",

View file

@ -96,7 +96,7 @@ ${padHTML}
}); });
} else { } else {
const targetRect = target.getBoundingClientRect(); const targetRect = target.getBoundingClientRect();
openTitleMenu(protyle, {x: targetRect.right, y: targetRect.bottom, isLeft: true}); openTitleMenu(protyle, {x: targetRect.right, y: targetRect.bottom, isLeft: true}, Constants.MENU_TITLE_BREADCRUMB);
} }
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
@ -199,7 +199,7 @@ ${padHTML}
} }
private genMobileMenu(protyle: IProtyle) { private genMobileMenu(protyle: IProtyle) {
const menu = new Menu("breadcrumb-mobile-path"); const menu = new Menu(Constants.MENU_BREADCRUMB_MOBILE_PATH);
let blockElement: Element; let blockElement: Element;
if (getSelection().rangeCount > 0) { if (getSelection().rangeCount > 0) {
const range = getSelection().getRangeAt(0); const range = getSelection().getRangeAt(0);
@ -245,7 +245,7 @@ ${padHTML}
public showMenu(protyle: IProtyle, position: IPosition) { public showMenu(protyle: IProtyle, position: IPosition) {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "breadcrumbMore") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_BREADCRUMB_MORE) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
@ -256,7 +256,7 @@ ${padHTML}
} }
fetchPost("/api/block/getTreeStat", {id: id || (protyle.block.showAll ? protyle.block.id : protyle.block.rootID)}, (response) => { fetchPost("/api/block/getTreeStat", {id: id || (protyle.block.showAll ? protyle.block.id : protyle.block.rootID)}, (response) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "breadcrumbMore"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BREADCRUMB_MORE);
if (!protyle.contentElement.classList.contains("fn__none") && !protyle.disabled) { if (!protyle.contentElement.classList.contains("fn__none") && !protyle.disabled) {
let uploadHTML = ""; let uploadHTML = "";
uploadHTML = '<input class="b3-form__upload" type="file" multiple="multiple"'; uploadHTML = '<input class="b3-form__upload" type="file" multiple="multiple"';

View file

@ -929,6 +929,7 @@ export class Gutter {
const id = buttonElement.getAttribute("data-node-id"); const id = buttonElement.getAttribute("data-node-id");
const selectsElement = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"); const selectsElement = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
if (selectsElement.length > 1) { if (selectsElement.length > 1) {
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BLOCK_MULTI);
const match = Array.from(selectsElement).find(item => { const match = Array.from(selectsElement).find(item => {
if (id === item.getAttribute("data-node-id")) { if (id === item.getAttribute("data-node-id")) {
return true; return true;
@ -937,6 +938,8 @@ export class Gutter {
if (match) { if (match) {
return this.renderMultipleMenu(protyle, Array.from(selectsElement)); return this.renderMultipleMenu(protyle, Array.from(selectsElement));
} }
} else {
window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_BLOCK_SINGLE);
} }
let nodeElement: Element; let nodeElement: Element;

View file

@ -183,9 +183,10 @@ export class Title {
event.stopPropagation(); event.stopPropagation();
} }
}); });
const iconElement = this.element.querySelector(".protyle-title__icon"); const iconElement = this.element.querySelector(".protyle-title__icon") as HTMLElement;
iconElement.addEventListener("click", () => { iconElement.addEventListener("click", (event) => {
if (window.siyuan.shiftIsPressed) { // 不使用 window.siyuan.shiftIsPressed ,否则窗口未激活时按 Shift 点击块标无法打开属性面板 https://github.com/siyuan-note/siyuan/issues/15075
if (event.shiftKey) {
fetchPost("/api/block/getDocInfo", { fetchPost("/api/block/getDocInfo", {
id: protyle.block.rootID id: protyle.block.rootID
}, (response) => { }, (response) => {
@ -193,15 +194,15 @@ export class Title {
}); });
} else { } else {
const iconRect = iconElement.getBoundingClientRect(); const iconRect = iconElement.getBoundingClientRect();
openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom}); openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom}, Constants.MENU_TITLE_PROTYLE);
} }
}); });
this.element.addEventListener("contextmenu", (event) => { this.element.addEventListener("contextmenu", (event) => {
if (event.shiftKey) { if (event.shiftKey) {
return; return;
} }
if (getSelection().rangeCount === 0) { if (iconElement.contains((event.target as HTMLElement))) {
openTitleMenu(protyle, {x: event.clientX, y: event.clientY}); openTitleMenu(protyle, {x: event.clientX, y: event.clientY}, Constants.MENU_TITLE_PROTYLE);
return; return;
} }
protyle.toolbar?.element.classList.add("fn__none"); protyle.toolbar?.element.classList.add("fn__none");

View file

@ -26,10 +26,10 @@ import {addEditorToDatabase} from "../render/av/addToDatabase";
import {openFileById} from "../../editor/util"; import {openFileById} from "../../editor/util";
import {hasTopClosestByClassName} from "../util/hasClosest"; import {hasTopClosestByClassName} from "../util/hasClosest";
export const openTitleMenu = (protyle: IProtyle, position: IPosition) => { export const openTitleMenu = (protyle: IProtyle, position: IPosition, subname: string) => {
hideTooltip(); hideTooltip();
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "titleMenu") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_TITLE) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
@ -37,7 +37,8 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
id: protyle.block.rootID id: protyle.block.rootID
}, (response) => { }, (response) => {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "titleMenu"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_TITLE);
window.siyuan.menus.menu.element.setAttribute("data-subname", subname);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
id: "copy", id: "copy",
label: window.siyuan.languages.copy, label: window.siyuan.languages.copy,

View file

@ -606,7 +606,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
menu.addSeparator({id: "separator_1"}); menu.addSeparator({id: "separator_1"});
} }
menu.addItem({ menu.addItem({
id: "insertRowBefore", id: avType === "table" ? "insertRowBefore" : "insertItemBefore",
icon: "iconBefore", icon: "iconBefore",
label: `<div class="fn__flex" style="align-items: center;"> label: `<div class="fn__flex" style="align-items: center;">
${window.siyuan.languages[avType === "table" ? "insertRowBefore" : "insertItemBefore"].replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" value="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field"><span class="fn__space"></span>`)} ${window.siyuan.languages[avType === "table" ? "insertRowBefore" : "insertItemBefore"].replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" value="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field"><span class="fn__space"></span>`)}
@ -641,7 +641,7 @@ ${window.siyuan.languages[avType === "table" ? "insertRowBefore" : "insertItemBe
} }
}); });
menu.addItem({ menu.addItem({
id: "insertRowAfter", id: avType === "table" ? "insertRowAfter" : "insertItemAfter",
icon: "iconAfter", icon: "iconAfter",
label: `<div class="fn__flex" style="align-items: center;"> label: `<div class="fn__flex" style="align-items: center;">
${window.siyuan.languages[avType === "table" ? "insertRowAfter" : "insertItemAfter"].replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field" value="1"><span class="fn__space"></span>`)} ${window.siyuan.languages[avType === "table" ? "insertRowAfter" : "insertItemAfter"].replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field" value="1"><span class="fn__space"></span>`)}

View file

@ -199,7 +199,7 @@ export const editAssetItem = (options: {
}) => { }) => {
const linkAddress = removeCompressURL(options.content); const linkAddress = removeCompressURL(options.content);
const type = options.type as "image" | "file"; const type = options.type as "image" | "file";
const menu = new Menu("av-asset-edit", () => { const menu = new Menu(Constants.MENU_AV_ASSET_EDIT, () => {
if ((!textElements[1] && textElements[0].value === linkAddress) || if ((!textElements[1] && textElements[0].value === linkAddress) ||
(textElements[1] && textElements[0].value === linkAddress && textElements[1].value === options.name)) { (textElements[1] && textElements[0].value === linkAddress && textElements[1].value === options.name)) {
return; return;
@ -382,7 +382,7 @@ export const editAssetItem = (options: {
}; };
export const addAssetLink = (protyle: IProtyle, cellElements: HTMLElement[], target: HTMLElement, blockElement: Element) => { export const addAssetLink = (protyle: IProtyle, cellElements: HTMLElement[], target: HTMLElement, blockElement: Element) => {
const menu = new Menu("av-asset-link", () => { const menu = new Menu(Constants.MENU_AV_ASSET_EDIT, () => {
const textElements = menu.element.querySelectorAll("textarea"); const textElements = menu.element.querySelectorAll("textarea");
if (!textElements[0].value && !textElements[1].value) { if (!textElements[0].value && !textElements[1].value) {
return; return;

View file

@ -3,6 +3,7 @@ import {transaction} from "../../wysiwyg/transaction";
import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest"; import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
import {fetchSyncPost} from "../../../util/fetch"; import {fetchSyncPost} from "../../../util/fetch";
import {getFieldsByData} from "./view"; import {getFieldsByData} from "./view";
import {Constants} from "../../../constants";
const calcItem = (options: { const calcItem = (options: {
menu: Menu, menu: Menu,
@ -112,7 +113,7 @@ export const openCalcMenu = async (protyle: IProtyle, calcElement: HTMLElement,
if (type === "lineNumber") { if (type === "lineNumber") {
return; return;
} }
const menu = new Menu("av-calc", () => { const menu = new Menu(Constants.MENU_AV_CALC, () => {
if (rowElement) { if (rowElement) {
rowElement.classList.remove("av__row--show"); rowElement.classList.remove("av__row--show");
} }

View file

@ -666,7 +666,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
const blockID = blockElement.getAttribute("data-node-id"); const blockID = blockElement.getAttribute("data-node-id");
const oldValue = cellElement.querySelector(".av__celltext").textContent.trim(); const oldValue = cellElement.querySelector(".av__celltext").textContent.trim();
const oldDesc = cellElement.dataset.desc; const oldDesc = cellElement.dataset.desc;
const menu = new Menu("av-header-cell", () => { const menu = new Menu(Constants.MENU_AV_HEADER_CELL, () => {
const newValue = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value; const newValue = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
if (newValue !== oldValue) { if (newValue !== oldValue) {
transaction(protyle, [{ transaction(protyle, [{
@ -1235,7 +1235,7 @@ const genUpdateColItem = (type: TAVCol, oldType: TAVCol) => {
}; };
export const addCol = (protyle: IProtyle, blockElement: Element, previousID?: string) => { export const addCol = (protyle: IProtyle, blockElement: Element, previousID?: string) => {
const menu = new Menu("av-header-add"); const menu = new Menu(Constants.MENU_AV_HEADER_ADD);
const avID = blockElement.getAttribute("data-av-id"); const avID = blockElement.getAttribute("data-av-id");
if (typeof previousID === "undefined" && blockElement.getAttribute("data-av-type") === "table") { if (typeof previousID === "undefined" && blockElement.getAttribute("data-av-type") === "table") {
previousID = Array.from(blockElement.querySelectorAll(".av__row--header .av__cell")).pop().getAttribute("data-col-id"); previousID = Array.from(blockElement.querySelectorAll(".av__row--header .av__cell")).pop().getAttribute("data-col-id");

View file

@ -12,6 +12,7 @@ import {fetchPost, fetchSyncPost} from "../../../util/fetch";
import {showMessage} from "../../../dialog/message"; import {showMessage} from "../../../dialog/message";
import {upDownHint} from "../../../util/upDownHint"; import {upDownHint} from "../../../util/upDownHint";
import {getFieldsByData} from "./view"; import {getFieldsByData} from "./view";
import {Constants} from "../../../constants";
export const getDefaultOperatorByType = (type: TAVCol) => { export const getDefaultOperatorByType = (type: TAVCol) => {
if (["select", "number", "date", "created", "updated"].includes(type)) { if (["select", "number", "date", "created", "updated"].includes(type)) {
@ -676,7 +677,7 @@ export const addFilter = (options: {
protyle: IProtyle protyle: IProtyle
blockElement: Element blockElement: Element
}) => { }) => {
const menu = new Menu("av-add-filter"); const menu = new Menu(Constants.MENU_AV_ADD_FILTER);
getFieldsByData(options.data).forEach((column) => { getFieldsByData(options.data).forEach((column) => {
let filter: IAVFilter; let filter: IAVFilter;
options.data.view.filters.find((item) => { options.data.view.filters.find((item) => {

View file

@ -6,6 +6,7 @@ import {getFieldsByData} from "./view";
import {fetchSyncPost} from "../../../util/fetch"; import {fetchSyncPost} from "../../../util/fetch";
import {Menu} from "../../../plugin/Menu"; import {Menu} from "../../../plugin/Menu";
import {objEquals} from "../../../util/functions"; import {objEquals} from "../../../util/functions";
import {Constants} from "../../../constants";
export const getPageSize = (blockElement: Element) => { export const getPageSize = (blockElement: Element) => {
const groupPageSize: { const groupPageSize: {
@ -304,7 +305,7 @@ export const goGroupsDate = (options: {
data: IAV; data: IAV;
blockElement: Element; blockElement: Element;
}) => { }) => {
const menu = new Menu("avGroupDate"); const menu = new Menu(Constants.MENU_AV_GROUP_DATE);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }
@ -351,7 +352,7 @@ export const goGroupsSort = (options: {
menuElement: HTMLElement; menuElement: HTMLElement;
blockElement: Element; blockElement: Element;
}) => { }) => {
const menu = new Menu("avGroupSort"); const menu = new Menu(Constants.MENU_AV_GROUP_SORT);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }

View file

@ -1,5 +1,6 @@
import {Menu} from "../../../plugin/Menu"; import {Menu} from "../../../plugin/Menu";
import {transaction} from "../../wysiwyg/transaction"; import {transaction} from "../../wysiwyg/transaction";
import {Constants} from "../../../constants";
const addFormatItem = (options: { const addFormatItem = (options: {
menu: Menu, menu: Menu,
@ -40,7 +41,7 @@ export const formatNumber = (options: {
avID: string, avID: string,
oldFormat: string oldFormat: string
}) => { }) => {
const menu = new Menu("av-col-format-number"); const menu = new Menu(Constants.MENU_AV_COL_FORMAT_NUMBER);
addFormatItem({ addFormatItem({
menu, menu,
protyle: options.protyle, protyle: options.protyle,

View file

@ -263,7 +263,7 @@ export const setPageSize = (options: {
avID: string, avID: string,
nodeElement: Element nodeElement: Element
}) => { }) => {
const menu = new Menu("av-page-size"); const menu = new Menu(Constants.MENU_AV_PAGE_SIZE);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }

View file

@ -11,6 +11,7 @@ import {genCellValueByElement, getTypeByCellElement} from "./cell";
import * as dayjs from "dayjs"; import * as dayjs from "dayjs";
import {getFieldsByData} from "./view"; import {getFieldsByData} from "./view";
import {getFieldIdByCellElement} from "./row"; import {getFieldIdByCellElement} from "./row";
import {Constants} from "../../../constants";
let cellValues: IAVCellValue[]; let cellValues: IAVCellValue[];
@ -152,7 +153,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
let desc = target.parentElement.dataset.desc; let desc = target.parentElement.dataset.desc;
let color = target.parentElement.dataset.color; let color = target.parentElement.dataset.color;
const fields = getFieldsByData(data); const fields = getFieldsByData(data);
const menu = new Menu("av-col-option", () => { const menu = new Menu(Constants.MENU_AV_COL_OPTION, () => {
if ((name === inputElement.value && desc === descElement.value) || !inputElement.value) { if ((name === inputElement.value && desc === descElement.value) || !inputElement.value) {
return; return;
} }

View file

@ -4,6 +4,7 @@ import {transaction} from "../../wysiwyg/transaction";
import {setPosition} from "../../../util/setPosition"; import {setPosition} from "../../../util/setPosition";
import {unicode2Emoji} from "../../../emoji"; import {unicode2Emoji} from "../../../emoji";
import {getFieldsByData} from "./view"; import {getFieldsByData} from "./view";
import {Constants} from "../../../constants";
export const addSort = (options: { export const addSort = (options: {
data: IAV, data: IAV,
@ -14,7 +15,7 @@ export const addSort = (options: {
protyle: IProtyle, protyle: IProtyle,
blockID: string, blockID: string,
}) => { }) => {
const menu = new Menu("av-add-sort"); const menu = new Menu(Constants.MENU_AV_ADD_SORT);
const fields = getFieldsByData(options.data); const fields = getFieldsByData(options.data);
fields.forEach((column) => { fields.forEach((column) => {
let hasSort = false; let hasSort = false;
@ -131,11 +132,11 @@ export const getSortsHTML = (columns: IAVColumn[], sorts: IAVSort[]) => {
${html} ${html}
<button class="b3-menu__item${sorts.length === columns.length ? " fn__none" : ""}" data-type="addSort"> <button class="b3-menu__item${sorts.length === columns.length ? " fn__none" : ""}" data-type="addSort">
<svg class="b3-menu__icon"><use xlink:href="#iconAdd"></use></svg> <svg class="b3-menu__icon"><use xlink:href="#iconAdd"></use></svg>
<span class="b3-menu__label">${window.siyuan.languages.new}</span> <span class="b3-menu__label">${window.siyuan.languages.addSort}</span>
</button> </button>
<button class="b3-menu__item b3-menu__item--warning${html ? "" : " fn__none"}" data-type="removeSorts"> <button class="b3-menu__item b3-menu__item--warning${html ? "" : " fn__none"}" data-type="removeSorts">
<svg class="b3-menu__icon"><use xlink:href="#iconTrashcan"></use></svg> <svg class="b3-menu__icon"><use xlink:href="#iconTrashcan"></use></svg>
<span class="b3-menu__label">${window.siyuan.languages.delete}</span> <span class="b3-menu__label">${window.siyuan.languages.removeSorts}</span>
</button> </button>
</div>`; </div>`;
}; };

View file

@ -12,7 +12,7 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
if (options.protyle.disabled) { if (options.protyle.disabled) {
return; return;
} }
const menu = new Menu("av-view"); const menu = new Menu(Constants.MENU_AV_VIEW);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }

View file

@ -259,12 +259,12 @@ export const renderNextAssetMark = (element: Element) => {
export const assetMethodMenu = (target: HTMLElement, cb: () => void) => { export const assetMethodMenu = (target: HTMLElement, cb: () => void) => {
const method = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method; const method = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].method;
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "searchAssetMethod") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_SEARCH_ASSET_METHOD) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "searchAssetMethod"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_SEARCH_ASSET_METHOD);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
icon: "iconExact", icon: "iconExact",
label: window.siyuan.languages.keyword, label: window.siyuan.languages.keyword,
@ -345,12 +345,12 @@ export const assetFilterMenu = (assetsElement: Element) => {
export const assetMoreMenu = (target: Element, element: Element, cb: () => void) => { export const assetMoreMenu = (target: Element, element: Element, cb: () => void) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "searchAssetMore") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_SEARCH_ASSET_MORE) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "searchAssetMore"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_SEARCH_ASSET_MORE);
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHASSET]; const localData = window.siyuan.storage[Constants.LOCAL_SEARCHASSET];
const sortMenu = [{ const sortMenu = [{
iconHTML: "", iconHTML: "",

View file

@ -233,12 +233,12 @@ export const replaceFilterMenu = (config: Config.IUILayoutTabSearchConfig) => {
export const queryMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => void) => { export const queryMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => void) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "searchMethod") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_SEARCH_METHOD) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "searchMethod"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_SEARCH_METHOD);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
icon: "iconExact", icon: "iconExact",
label: window.siyuan.languages.keyword, label: window.siyuan.languages.keyword,
@ -410,12 +410,12 @@ export const moreMenu = async (config: Config.IUILayoutTabSearchConfig,
removeCriterion: () => void, removeCriterion: () => void,
layoutMenu?: () => void) => { layoutMenu?: () => void) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "searchMore") { window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_SEARCH_MORE) {
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
return; return;
} }
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "searchMore"); window.siyuan.menus.menu.element.setAttribute("data-name", Constants.MENU_SEARCH_MORE);
/// #if MOBILE /// #if MOBILE
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
iconHTML: "", iconHTML: "",

View file

@ -16,7 +16,7 @@ export const toggleReplaceHistory = (replaceInputElement: HTMLInputElement) => {
if (!list.replaceKeys || list.replaceKeys.length === 0 || (list.length === 1 && list[0] === replaceInputElement.value)) { if (!list.replaceKeys || list.replaceKeys.length === 0 || (list.length === 1 && list[0] === replaceInputElement.value)) {
return; return;
} }
const menu = new Menu("search-replace-history"); const menu = new Menu(Constants.MENU_SEARCH_REPLACE_HISTORY);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }
@ -84,7 +84,7 @@ export const toggleSearchHistory = (searchElement: Element, config: Config.IUILa
if (!list.keys || list.keys.length === 0 || (list.length === 1 && list[0] === searchInputElement.value)) { if (!list.keys || list.keys.length === 0 || (list.length === 1 && list[0] === searchInputElement.value)) {
return; return;
} }
const menu = new Menu("search-history"); const menu = new Menu(Constants.MENU_SEARCH_HISTORY);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }
@ -158,7 +158,7 @@ export const toggleAssetHistory = (assetElement: Element) => {
if (!keys || keys.length === 0 || (keys.length === 1 && keys[0] === assetInputElement.value)) { if (!keys || keys.length === 0 || (keys.length === 1 && keys[0] === assetInputElement.value)) {
return; return;
} }
const menu = new Menu("search-asset-history"); const menu = new Menu(Constants.MENU_SEARCH_ASSET_HISTORY);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }

View file

@ -133,7 +133,7 @@ ${getAttr(item)}
}; };
export const unRefMoreMenu = (target: Element, element: Element, edit: Protyle) => { export const unRefMoreMenu = (target: Element, element: Element, edit: Protyle) => {
const menu = new Menu("searchUnRefMore"); const menu = new Menu(Constants.MENU_SEARCH_UNREF_MORE);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }

View file

@ -272,7 +272,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
if (!keys || keys.length === 0 || (keys.length === 1 && keys[0] === inputElement.value)) { if (!keys || keys.length === 0 || (keys.length === 1 && keys[0] === inputElement.value)) {
return; return;
} }
const menu = new Menu("move-path-history"); const menu = new Menu(Constants.MENU_MOVE_PATH_HISTORY);
if (menu.isOpen) { if (menu.isOpen) {
return; return;
} }
@ -364,7 +364,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
toggleMovePathHistory(); toggleMovePathHistory();
return; return;
} }
if (window.siyuan.menus.menu.element.getAttribute("data-name") === "move-path-history") { if (window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_MOVE_PATH_HISTORY) {
return; return;
} }
const currentPanelElement = searchListElement.classList.contains("fn__none") ? searchTreeElement : searchListElement; const currentPanelElement = searchListElement.classList.contains("fn__none") ? searchTreeElement : searchListElement;