-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(monaco-editor): 调整文件资源管理器图标与提示文本 | Adjust the icon and promp…
…t text of the file explorer.
- Loading branch information
1 parent
1481c23
commit 32fff26
Showing
9 changed files
with
217 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright (C) 2023 Zuoqiu Yingyi | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { FileTreeNodeType, type IFileTreeNode, type IFileTreeNodeStores } from "@workspace/components/siyuan/tree/file"; | ||
import { parse } from "@workspace/utils/path/browserify"; | ||
import { get } from "svelte/store"; | ||
|
||
/* 图标管理 */ | ||
export class Icon { | ||
public static ICONS = { | ||
file: "#iconFile", | ||
filetree: "#icon-monaco-editor-file-tree", | ||
folder_closed: "#icon-monaco-editor-folder-closed", | ||
folder_opend: "#icon-monaco-editor-folder-opend", | ||
siyuan: "#iconSiYuan", | ||
workspace: "#iconWorkspace", | ||
} as const; | ||
|
||
/* 展开节点 */ | ||
public static expand(node: IFileTreeNodeStores) { | ||
if (get(node.type) === FileTreeNodeType.Folder) { | ||
node.icon.set(Icon.ICONS.folder_opend); | ||
} | ||
} | ||
|
||
/* 收缩节点 */ | ||
public static collapse(node: IFileTreeNodeStores) { | ||
if (get(node.type) === FileTreeNodeType.Folder) { | ||
node.icon.set(Icon.ICONS.folder_closed); | ||
} | ||
} | ||
|
||
/* 根据节点信息生成图标 ID */ | ||
public static make(type: FileTreeNodeType, path: string): string { | ||
switch (type) { | ||
case FileTreeNodeType.Root: | ||
return Icon.ICONS.workspace; | ||
case FileTreeNodeType.Folder: | ||
return Icon.ICONS.folder_closed; | ||
case FileTreeNodeType.File: { | ||
const info = parse(path); // 节点路径信息 | ||
switch (true) { | ||
case info.ext === ".sy": // 思源文件 | ||
return Icon.ICONS.siyuan; | ||
default: | ||
return Icon.ICONS.file; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (C) 2023 Zuoqiu Yingyi | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import type { IFileTreeNodeStores } from "@workspace/components/siyuan/tree/file"; | ||
|
||
/* 管理节点的选中 */ | ||
export class Select { | ||
/* 选中的节点集合 */ | ||
protected readonly selected: Set<IFileTreeNodeStores> = new Set(); | ||
|
||
/** | ||
* 仅选中一个节点 | ||
* 取消其他所有节点的选中状态 | ||
*/ | ||
public one(node: IFileTreeNodeStores) { | ||
node.focus.set(true); | ||
this.selected.delete(node); | ||
this.selected.forEach(node => node.focus.set(false)); | ||
this.selected.clear(); | ||
this.selected.add(node); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright (C) 2023 Zuoqiu Yingyi | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import type MonacoEditorPlugin from "@/index"; | ||
import { FileTreeNodeType } from "@workspace/components/siyuan/tree/file"; | ||
import { parse } from "@workspace/utils/path/browserify"; | ||
import { Icon } from "./icon"; | ||
|
||
/* 提示信息管理 */ | ||
export class Tooltip { | ||
protected readonly i18n: MonacoEditorPlugin["i18n"]; | ||
constructor( | ||
public readonly plugin: InstanceType<typeof MonacoEditorPlugin>, // 插件对象 | ||
) { | ||
this.i18n = this.plugin.i18n; | ||
} | ||
|
||
/* 根据节点信息生成提示信息 */ | ||
public make(type: FileTreeNodeType, path: string): string { | ||
switch (type) { | ||
case FileTreeNodeType.Root: | ||
return this.i18n.explorer.workspace.name; | ||
case FileTreeNodeType.Folder: | ||
return this.i18n.explorer.folder.ariaLabel; | ||
case FileTreeNodeType.File: { | ||
const info = parse(path); // 节点路径信息 | ||
switch (true) { | ||
case info.ext === ".sy": // 思源文件 | ||
return this.i18n.explorer.tooltips.siyuanDoc; | ||
default: | ||
return this.i18n.explorer.file.ariaLabel; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.