Skip to content

Commit 625c266

Browse files
JackYansongLiclaude
andcommitted
[0603] 修复边注直接编辑交互
参考 comments 插件模式,将 marginal-note 的 accessible 属性从 none 改为 2, 使 body 可直接编辑;同时去掉 make-marginal-note 中的 inactive 包裹, 插入后不再显示 <marginal-note|...> 源代码形式。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 8c31f92 commit 625c266

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

TeXmacs/packages/standard/std-markup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@
531531

532532
<assign|marginal-note|<macro|hpos|vpos|body|<with|dummy1|<value|marginal-note-width>|dummy2|<value|marginal-note-sep>|<compound|<merge|marginal-|<arg|hpos>|-note>|<arg|vpos>|<arg|body>|<arg|hpos>>>>>
533533

534-
<drd-props|marginal-note|arity|3|accessible|none>
534+
<drd-props|marginal-note|arity|3|accessible|2>
535535

536536
<\active*>
537537
<\src-comment>

TeXmacs/progs/generic/generic-edit.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ TODO: 在文本模式中,可以自动识别剪贴板中的内容,并智能
16431643
(tm-define (make-marginal-note)
16441644
(:synopsis "Insert a marginal note")
16451645
(wrap-selection-small
1646-
(insert-go-to `(inactive (marginal-note "normal" "c" "")) '(0 2 0))))
1646+
(insert-go-to `(marginal-note "normal" "c" "") '(2 0))))
16471647

16481648
(tm-define (test-marginal-note-hpos? hp)
16491649
(and-with t (tree-innermost 'marginal-note #t)

devel/0603.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# [0603] 修复边注直接编辑交互
2+
3+
## 如何测试
4+
5+
1. 编译并启动 Mogan
6+
2. 新建一个文档
7+
3. 点击菜单:插入 → 注记 → 边注(或输入 `\marginal-note` 后回车)
8+
4. **预期结果**:不应出现 `<marginal-note|normal|c|>` 的源代码形式,而是直接渲染在页面边缘的边注,光标位于边注 body 中,可直接输入文字
9+
5. 选中文档中一段文字后,再插入边注,确认选中内容自动进入边注 body
10+
6. 点击边注使其获得焦点,确认浮动工具栏中的位置(左/右/自动)和对齐(上/中/下)设置仍可正常使用
11+
12+
## 修改内容
13+
14+
### 问题描述
15+
16+
此前插入边注时,由于 `marginal-note` 的 DRD 属性为 `accessible|none`,且 `make-marginal-note` 显式包裹了 `inactive`,导致:
17+
- 插入后显示源代码形式 `<marginal-note|normal|c|正文>`
18+
- 用户需要按 Enter 激活后才能看到渲染效果
19+
- 再次编辑时需要按 Backspace 重新进入 inactive 编辑模式
20+
21+
### 修复方案
22+
23+
参考 comments 插件的实现模式(`unfolded-comment` 的 DRD 设为 `accessible|6`,插入时不包裹 `inactive`):
24+
25+
1. **修改 DRD**:将 `marginal-note``accessible` 属性从 `none` 改为 `2`,使第三个参数(body)可直接编辑
26+
- 文件:`TeXmacs/packages/standard/std-markup.ts`
27+
28+
2. **修改插入命令**:去掉 `inactive` 包裹,光标路径从 `(0 2 0)` 改为 `(2 0)`
29+
- 文件:`TeXmacs/progs/generic/generic-edit.scm`
30+
31+
### 相关文件
32+
33+
- `TeXmacs/packages/standard/std-markup.ts`
34+
- `TeXmacs/progs/generic/generic-edit.scm`

0 commit comments

Comments
 (0)