Skip to content

Commit 7b61343

Browse files
committed
feat(typewriter): 适配属性视图 | Adapt to the attribute view.
1 parent 1144a24 commit 7b61343

File tree

10 files changed

+90
-12
lines changed

10 files changed

+90
-12
lines changed

public/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,18 @@ This is a plug-in for [SiYuan Note](https://github.com/siyuan-note/siyuan) that
9595
* `Enable Typewriter Mode`
9696

9797
* When enabled, the block where the cursor is located will automatically scroll to the middle of the editor while editing
98-
* `Code Block Focus Follows Line`
98+
* `Code Block Line Focus Follow`
9999

100100
* When enabled, the line of code where the cursor is located will be scrolled to the middle of the editor while editing a code block
101101
* When disabled, the code block will be scrolled to the middle of the editor while editing a code block
102-
* `Table Block Focus Follows Cell`
102+
* `Table Block Cell Focus Follow`
103103

104104
* When enabled, the table cell where the cursor is located will be scrolled to the middle of the editor while editing a table block
105105
* When disabled, the table block will be scrolled to the middle of the editor while editing a table block
106+
* `Database Block Cell Focus Follow`
107+
108+
* When enabled, the cell where the cursor is located will be scrolled to the middle of the editor while editing a database block (property view).
109+
* When disabled, the entire database block will be scrolled to the middle of the editor while editing a database block (property view).
106110
* `Scroll Delay`
107111

108112
* After the cursor moves to another block, the block where the cursor is located will scroll to the middle of the editor after a certain delay

public/README_zh_CN.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@
101101
* 关闭后在编辑代码块时, 将该代码块滚动至编辑区中间
102102
* `表格块焦点跟随单元格`
103103

104-
* 开启后在编辑表格块时, 将光标所在的表格单元格滚动至编辑器中间
105-
* 开启后在编辑表格块时, 将该表格块滚动至编辑区中间
104+
* 开启后在编辑表格块时, 将光标所在的表格单元格滚动至编辑区中间
105+
* 关闭后在编辑表格块时, 将该表格块滚动至编辑区中间
106+
* `数据库焦点跟随单元格`
107+
108+
* 开启后在编辑数据库块(属性视图)时, 将光标所在的单元格滚动至编辑区中间
109+
* 关闭后在编辑数据库块(属性视图)时, 将该数据库块滚动至编辑区中间
106110
* `滚动延时时间`
107111

108112
* 当光标位置移动至其他块时, 经过一定延时后光标所在的块再滚动至编辑区中间

public/i18n/en_US.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,26 @@
2727
},
2828
"typewriterSettings": {
2929
"code": {
30-
"description": "Scroll line by line when focus is inside a code block",
31-
"title": "Code Block Line Focus"
30+
"description": "Scroll in lines when focus is inside a code block",
31+
"title": "Code Block Line Focus Follow"
3232
},
3333
"enable": {
3434
"description": "When Typewriter Mode is enabled, the block with focus will automatically scroll to the middle of the editing area",
3535
"title": "Enable Typewriter Mode"
3636
},
3737
"table": {
38-
"description": "Scroll cell by cell when focus is inside a table block",
39-
"title": "Table Block Cell Focus"
38+
"description": "Scroll in cells when focus is inside a table block",
39+
"title": "Table Block Cell Focus Follow"
4040
},
4141
"timeout": {
4242
"description": "Set the time interval between edit actions and the start of scrolling.<br/>Unit: milliseconds",
4343
"title": "Scroll Delay Time"
4444
},
45-
"title": "Typewriter"
45+
"title": "Typewriter",
46+
"view": {
47+
"description": "Scroll in cells when the focus is inside the database block",
48+
"title": "Database Block Cell Focus"
49+
}
4650
}
4751
}
4852
}

public/i18n/zh_CHT.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
"description": "設置編輯操作與開始滾動之間的時間間隔<br/>單位:毫秒",
4343
"title": "滾動延時時間"
4444
},
45-
"title": "打字機設置"
45+
"title": "打字機設置",
46+
"view": {
47+
"description": "焦點位於數據庫塊內部時以單元格為單位進行滾動",
48+
"title": "數據庫焦點跟隨單元格"
49+
}
4650
}
4751
}
4852
}

public/i18n/zh_CN.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
"description": "设置编辑操作与开始滚动之间的时间间隔<br/>单位:毫秒",
4343
"title": "滚动延时时间"
4444
},
45-
"title": "打字机设置"
45+
"title": "打字机设置",
46+
"view": {
47+
"description": "焦点位于数据库块内部时以单元格为单位进行滚动",
48+
"title": "数据库焦点跟随单元格"
49+
}
4650
}
4751
}
4852
}

src/components/Settings.svelte

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@
176176
/>
177177
</Item>
178178

179+
<!-- 属性表焦点跟随单元格 -->
180+
<Item
181+
title={i18n.settings.typewriterSettings.view.title}
182+
text={i18n.settings.typewriterSettings.view.description}
183+
>
184+
<Input
185+
slot="input"
186+
type={ItemType.checkbox}
187+
settingKey="view"
188+
settingValue={config.typewriter.view.row}
189+
on:changed={async e => {
190+
config.typewriter.view.row = e.detail.value;
191+
await updated();
192+
}}
193+
/>
194+
</Item>
195+
179196
<!-- 滚动延时时间 -->
180197
<Item
181198
title={i18n.settings.typewriterSettings.timeout.title}

src/configs/default.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export const DEFAULT_CONFIG: IConfig = {
2727
table: {
2828
row: true,
2929
},
30+
view: {
31+
row: true,
32+
},
3033
},
3134
focus: {
3235
enable: true,

src/index.less

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
--custom-focus-table-row-outline-color: var(--b3-theme-on-surface); // 焦点所在表格行的轮廓颜色
2424

2525
--custom-focus-table-cell-shadow-blur: 0.25em; // 焦点所在表格单元格的阴影模糊半径
26+
27+
--custom-focus-view-row-outline-width: 1px; // 焦点所在属性视图行的轮廓宽度
28+
--custom-focus-view-row-outline-color: var(--b3-theme-on-surface); // 焦点所在属性视图行的轮廓颜色
29+
30+
--custom-focus-view-cell-shadow-blur: 0.25em; // 焦点所在属性视图单元格的阴影模糊半径
2631
}
2732

2833
.protyle-wysiwyg {
@@ -62,5 +67,26 @@
6267
}
6368
}
6469
}
70+
71+
&.av {
72+
.av__row {
73+
&:has(.av__cell[data-plugin-focus=true]) {
74+
// 焦点所在属性视图行
75+
outline: var(--custom-focus-view-row-outline-width) solid var(--custom-focus-table-row-outline-color);
76+
}
77+
78+
.av__cell {
79+
&[data-plugin-focus=true] {
80+
// 焦点所在属性视图单元格
81+
box-shadow: 0 0 var(--custom-focus-view-cell-shadow-blur) 0 var(--custom-focus-shadow-color) inset;
82+
}
83+
84+
&#plugin-focus-unique-id {
85+
// 全局唯一焦点所在属性视图单元格
86+
box-shadow: 0 0 var(--custom-focus-view-cell-shadow-blur) 0 var(--custom-focus-unique-shadow-color) inset;
87+
}
88+
}
89+
}
90+
}
6591
}
6692
}

src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ export default class TypewriterPlugin extends siyuan.Plugin {
358358
element = cell ?? block;
359359
break;
360360
}
361+
case "NodeAttributeView": {
362+
const cell = block.querySelector<HTMLElement>(".av__cell--select");
363+
element = cell ?? block;
364+
break;
365+
}
361366
default:
362367
element = block;
363368
break;
@@ -426,7 +431,7 @@ export default class TypewriterPlugin extends siyuan.Plugin {
426431
}
427432
break;
428433
case "NodeTable":
429-
if (this.config.typewriter.table.row) { // 定位到行
434+
if (this.config.typewriter.view.row) { // 定位到行
430435
let focus = globalThis.getSelection()?.focusNode;
431436
while (true) {
432437
if (!focus) { // 元素不存在
@@ -444,6 +449,12 @@ export default class TypewriterPlugin extends siyuan.Plugin {
444449
element = focus ?? block;
445450
}
446451
break;
452+
case "NodeAttributeView":
453+
if (this.config.typewriter.table.row) { // 定位到行
454+
const focus = block.querySelector<HTMLElement>(".av__cell--select");
455+
element = focus ?? block;
456+
}
457+
break;
447458
default:
448459
break;
449460
}

src/types/config.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface ITypewriter {
2424
timeout: number; // 延时 (ms)
2525
code: IBlockConfig; // 代码块
2626
table: IBlockConfig; // 表格块
27+
view: IBlockConfig; // 属性视图块
2728
}
2829

2930
export interface IFocus {

0 commit comments

Comments
 (0)