Skip to content

Commit

Permalink
✨ feat: 配置是否聚焦块 close #30
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Dec 27, 2024
1 parent 33e7cd5 commit 32cdfe8
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 126 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"vite-plugin-zip-pack": "^1.2.2"
},
"dependencies": {
"@frostime/siyuan-plugin-kits": "^1.3.6",
"@frostime/solid-signal-ref": "^2.0.0",
"solid-transition-group": "^0.2.3"
}
Expand Down
205 changes: 108 additions & 97 deletions public/i18n/en_US.yaml
Original file line number Diff line number Diff line change
@@ -1,130 +1,141 @@
---
msg:
ruleFailed: 'Failed to correctly parse the configuration rule: {0}'
ruleInvalid: 'The format of the group rule input is incorrect: {0}'
itemHasInGroup: The item is already in the target group
itemNotFoundInGroup: The item was not found in the source group
groupNameEmpty: The name of the bookmark group cannot be empty!
itemErr:
closed: 'The notebook "{0}" is already closed'
deleted: 'Content block not found, it may have been deleted! Old block content: [{0}]'
setting:
replaceDefault:
title: Replace Built-in Bookmarks
description: 'If enabled, the default bookmarks will be blocked, and bookmark shortcut keys (default is Alt+3) will be bound;<br/>Takes effect after restart; Notice: not appliable in mobile devices!'
viewMode:
title: Display Mode
description: Select the style of the bookmark bar display
hideClosed:
title: Hide Closed Items
description: When enabled, hide items from closed notebooks
hideDeleted:
title: Hide Invalid Items
description: When enabled, hide items that have been deleted
grouplist:
title: Bookmark Groups
description: Set up bookmark groups
autoRefreshOnExpand:
title: Auto Refresh on Expand
description: Automatically refreshes the items within a dynamic group when it is expanded from a collapsed state.
ariaLabel:
title: Display Hover Box
description: Display full title of the bookmark item in a hover box when the mouse hovers
viewMode:
bookmark: Bookmark Style
card: Card Style
bookmark:
new: Create New Bookmark Group
cache: Cache Current Bookmarks
delete:
title: Delete the bookmark group {0}[{1}]?
desc: ⚠️ Cannot be recovered after deletion! Are you sure you want to delete?
cache: Cache Current Bookmarks
title: Delete the bookmark group {0}[{1}]?
logo:
name: Bookmark
setting: Settings
add: Add Bookmark Group
refresh: Refresh
expand: Expand Ctrl+↓
collapse: Collapse Ctrl+↑
expand: Expand Ctrl+↓
min: Minimize Ctrl+W
name: Bookmark
refresh: Refresh
setting: Settings
new: Create New Bookmark Group
bookmarktype:
composed: Composite Bookmark
dynamic: Dynamic Bookmark
normal: Normal Bookmark
group:
msgexist: 'Cannot add: Block with ID [{0}] already exists in the bookmark group'
msg404: 'Cannot add: Block with ID [{0}] not found'
refresh: Refresh
copyref: Copy as Reference List
bottom: Move to Bottom
copylink: Copy as Link List
msgcopy: Copy Successful
copyref: Copy as Reference List
currentdoc: Add Current Document Block
delete: Delete Bookmark Group
docflow: Document Flow
rename: Rename Bookmark Group
down: Move Down
edit: Edit Rule Value
delete: Delete Bookmark Group
fromclipboard: Insert Block from Clipboard
move: Move
msg404: 'Cannot add: Block with ID [{0}] not found'
msgcopy: Copy Successful
msgdelconfirm:
- Delete bookmark item {0}?
- ⚠️ Cannot be recovered after deletion! Are you sure you want to delete?
msgexist: 'Cannot add: Block with ID [{0}] already exists in the bookmark group'
msgparse: Unable to parse block from [{0}]
refresh: Refresh
rename: Rename Bookmark Group
top: Move to Top
up: Move Up
down: Move Down
bottom: Move to Bottom
fromclipboard: Insert Block from Clipboard
msgparse: Unable to parse block from [{0}]
currentdoc: Add Current Document Block
msgdelconfirm:
- Delete bookmark item {0}?
- ⚠️ Cannot be recovered after deletion! Are you sure you want to delete?
item:
copyref: Copy as Reference
bottom: Move to Bottom
checkerritem: Check detail
copyitem: Copy to
copylink: Copy as Link
copyref: Copy as Reference
del: Delete Bookmark
move: Move
msgcopy: Copy Successful
style: Style
transfer: Move to
move: Move
top: Move to Top
bottom: Move to Bottom
del: Delete Bookmark
checkerritem: Check detail
copyitem: Copy to
transfer: Move to
itemErr:
closed: The notebook "{0}" is already closed
deleted: 'Content block not found, it may have been deleted! Old block content:
[{0}]'
msg:
groupNameEmpty: The name of the bookmark group cannot be empty!
itemHasInGroup: The item is already in the target group
itemNotFoundInGroup: The item was not found in the source group
ruleFailed: 'Failed to correctly parse the configuration rule: {0}'
ruleInvalid: 'The format of the group rule input is incorrect: {0}'
newgroup:
name:
- Bookmark Group Name
- Please enter the name of the new bookmark group
type:
- Bookmark Group Type
- Select Bookmark Group Type
rtype:
- Rule Type
- Select Dynamic Rule Type
rinput: Rule Value
choosetemplate: Template
desc:
sql: Please enter the SQL query below
attr: Please enter the attribute to search for; You can fill in [attribute name],
or [attribute name][= or like][attribute value]
backlinks: Please enter the block ID of the backlink
attr: Please enter the attribute to search for; You can fill in [attribute name], or [attribute name][= or like][attribute value]
choosetemplate: Template
sql: Please enter the SQL query below
icondesc: Select the icon for the group; if not set, the plugin will assign a default
icon based on the group type.
icontitle: Group Icon
name:
- Bookmark Group Name
- Please enter the name of the new bookmark group
postprocess:
ariaLabel: '<b>First child of container: </b>Display the full container block when the referenced block is the first child of a list item or quote block.<br/><b>Display as document block: </b>Display the document containing the referenced block, rather than the referenced block itself.<br/><b>See README for details</b>'
ariaLabel: '<b>First child of container: </b>Display the full container block
when the referenced block is the first child of a list item or quote block.<br/><b>Display
as document block: </b>Display the document containing the referenced block,
rather than the referenced block itself.<br/><b>See README for details</b>'
b2doc: Display as document block
fb2p: First child of container
name: Post-process
omit: No Process
fb2p: First child of container
b2doc: Display as document block
icontitle: Group Icon
# icondesc: 可以手动选择分组的图标;如果不设置,插件会根据分组类型分配默认的图标。
icondesc: Select the icon for the group; if not set, the plugin will assign a default icon based on the group type.

bookmarktype:
normal: 'Normal Bookmark'
dynamic: 'Dynamic Bookmark'
composed: 'Composite Bookmark'
rinput: Rule Value
rtype:
- Rule Type
- Select Dynamic Rule Type
type:
- Bookmark Group Type
- Select Bookmark Group Type
ruletype:
sql: SQL
backlinks: Backlinks
attr: Block Attributes
backlinks: Backlinks
js: Javascript
sql: SQL
selecticon:
h3: Please select an icon
reset: Reset
title: Change Group Icon
setting:
ariaLabel:
description: Display full title of the bookmark item in a hover box when the mouse
hovers
title: Display Hover Box
autoRefreshOnExpand:
description: Automatically refreshes the items within a dynamic group when it
is expanded from a collapsed state.
title: Auto Refresh on Expand
grouplist:
description: Set up bookmark groups
title: Bookmark Groups
hideClosed:
description: When enabled, hide items from closed notebooks
title: Hide Closed Items
hideDeleted:
description: When enabled, hide items that have been deleted
title: Hide Invalid Items
replaceDefault:
description: 'If enabled, the default bookmarks will be blocked, and bookmark
shortcut keys (default is Alt+3) will be bound;<br/>Takes effect after restart;
Notice: not appliable in mobile devices!'
title: Replace Built-in Bookmarks
viewMode:
description: Select the style of the bookmark bar display
title: Display Mode
zoomInWhenClick:
description: When clicking on the bookmark item and opening the content block
in the tab, automatically enter the focus mode
title: Enter focus mode after jumping to the block
template:
attr:
dailynote: Daily Note
sql:
random: Random Roam
updated: Recently Updated
thisday: On this day
todo: Unsolved Task
attr:
dailynote: Daily Note
selecticon:
title: Change Group Icon
h3: Please select an icon
reset: Reset
updated: Recently Updated
viewMode:
bookmark: Bookmark Style
card: Card Style
3 changes: 3 additions & 0 deletions public/i18n/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ setting:
ariaLabel:
title: 显示悬浮框
description: 鼠标悬停在书签项目上时,在悬浮框中显示书签项目的完整标题
zoomInWhenClick:
title: 跳转到块后进入聚焦
description: 当点击书签项目,在标签页中打开内容块的时候,自动进入聚焦模式
viewMode:
bookmark: 书签样式
card: 卡片样式
Expand Down
14 changes: 12 additions & 2 deletions src/components/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { render } from "solid-js/web";
import { Menu, openTab, showMessage, openMobileFileById } from "siyuan";
import { buildItemDetail } from "../libs/dom";

import { itemInfo, setGroups, groupMap, configs } from "../model";
import { itemInfo, setGroups, groupMap, configs, configRef } from "../model";

import { BookmarkContext, itemMoving, setItemMoving } from "./context";

import { i18n, renderI18n } from "@/utils/i18n";
import { simpleDialog } from "@/libs/dialog";
import Typography from "@/libs/components/typography";
import { getNotebook, isMobile } from "@/utils";
import { getBlockByID } from "@/api";

interface IProps {
group: TBookmarkGroupId;
Expand Down Expand Up @@ -267,11 +268,20 @@ const Item: Component<IProps> = (props) => {
if (isMobile()) {
openMobileFileById(plugin.app, item().id);
} else {
let zoomIn = configRef().zoomInWhenClick;
// if (item().type === 'd') {
// zoomIn = false;
// } else {
// let block = await getBlockByID(item().id);
// let root_id = block.root_id;
// let protyle = document.querySelector(`.protyle-title[data-node-id="${root_id}"]`);
// if (protyle) zoomIn = false; //如果文档已经打开了,就直接调整不聚焦
// }
openTab({
app: plugin.app,
doc: {
id: item().id,
zoomIn: item().type === 'd' ? false : true,
zoomIn: zoomIn,
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/select-icon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSignal, For, Show } from "solid-js";
import Icon from "./icon";
import { inject } from "@/libs/inject";
// import { inject } from "@/libs/inject";
import { solidDialog } from "@/libs/dialog";

import { i18n } from "@/utils/i18n";
Expand All @@ -20,7 +20,7 @@ const SelectIcons = (props: IProps) => {
const [activeTab, setActiveTab] = createSignal<'symbols' | 'emojis'>('symbols');
const symbols = Array.from(document.querySelectorAll('symbol'));

const i18n = inject<I18n>('i18n');
// const i18n = inject<I18n>('i18n');

const ALLOWED_EMOJI_GROUP = ['activity', 'travel', 'people', 'nature', 'food', 'symbols', 'object', 'flags'];
let EmojisGroups = (window.siyuan.emojis as ImojiGroup[]).filter(emoji => ALLOWED_EMOJI_GROUP.includes(emoji.id));
Expand Down
13 changes: 13 additions & 0 deletions src/components/setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ const App = () => {
}}
/>
</SettingItemWrap>
<SettingItemWrap
title={i18n_.zoomInWhenClick.title}
description={i18n_.zoomInWhenClick.description}
>
<InputItem
type='checkbox'
key='zoomInWhenClick'
value={configs['zoomInWhenClick']}
changed={(v: boolean) => {
setConfigs('zoomInWhenClick', v);
}}
/>
</SettingItemWrap>
<SettingItemWrap
title={i18n_.grouplist.title}
description={i18n_.grouplist.description}
Expand Down
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author : frostime
* @Date : 2024-06-12 19:48:53
* @FilePath : /src/index.ts
* @LastEditTime : 2024-12-15 20:04:24
* @LastEditTime : 2024-12-28 01:30:14
* @Description :
*/
import {
Expand All @@ -26,9 +26,11 @@ import { setI18n } from "@/utils/i18n";

import "@/index.scss";
import { isMobile } from "./utils";
import { provide, purge } from "./libs/inject";

import { loadSdk, unloadSdk } from "./sdk";

import { registerPlugin } from "@frostime/siyuan-plugin-kits";

let model: BookmarkDataModel;

const initBookmark = async (ele: HTMLElement, plugin: PluginBookmarkPlus) => {
Expand Down Expand Up @@ -67,9 +69,9 @@ export default class PluginBookmarkPlus extends Plugin {
}

async onload() {
//@ts-ignore
registerPlugin(this);
setI18n(this.i18n as I18n);
provide<I18n>('i18n', this.i18n as I18n);
provide<PluginBookmarkPlus>('plugin', this);

let svgs = Object.values(Svg);
this.addIcons(svgs.join(''));
Expand Down Expand Up @@ -127,7 +129,6 @@ export default class PluginBookmarkPlus extends Plugin {

onunload(): void {
unloadSdk();
purge();
destroyBookmark();
bookmarkKeymap.custom = bookmarkKeymap.default;
// this.commands = this.commands.filter((command) => command.langKey !== 'F-Misc::Bookmark');
Expand Down
19 changes: 0 additions & 19 deletions src/libs/inject.ts

This file was deleted.

Loading

0 comments on commit 32cdfe8

Please sign in to comment.