ElyMark: right-click menu by target; Copy as HTML Code and Plain Text
R4.10. Clipboard row, Copy / Paste As, format and block rows, Table or Paragraph, Insert, link, image, code and raw-block items; source and preview menus. Component pin 1b5fb07. Records the user's rule that ElyMark must work, not match Typora one to one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f012eaa624
commit
d5ceaf9aac
18 files changed
+840
-67
No files matched your search
Generated
+1
-1
@@ -1923,7 +1923,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ely-gpui-component"
|
||||
version = "0.1.1"
|
||||
source = "git+https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components?rev=6c2d28c56e9e3e3fe59272fe5da28efb0664ec3d#6c2d28c56e9e3e3fe59272fe5da28efb0664ec3d"
|
||||
source = "git+https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components?rev=1b5fb07cda3df9e96e17c2aceff187a70c67d28d#1b5fb07cda3df9e96e17c2aceff187a70c67d28d"
|
||||
dependencies = [
|
||||
"alacritty_terminal",
|
||||
"anyhow",
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ jiff = "0.2"
|
||||
anyhow = "1"
|
||||
directories = "6"
|
||||
dunce = "1"
|
||||
ely-gpui-component = { git = "https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components", rev = "6c2d28c56e9e3e3fe59272fe5da28efb0664ec3d" }
|
||||
ely-gpui-component = { git = "https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components", rev = "1b5fb07cda3df9e96e17c2aceff187a70c67d28d" }
|
||||
env_logger = "0.11"
|
||||
gpui = { package = "gpui-pre", version = "=0.3.8", default-features = false, features = ["stacker"] }
|
||||
gpui_platform = { package = "gpui-pre-platform", version = "=0.3.8", features = ["font-kit", "wayland", "x11"] }
|
||||
|
||||
@@ -40,7 +40,7 @@ site/ 官网(Vite 8、pnpm、TypeScript,无框架;等轴 SVG 积木
|
||||
|
||||
## 组件映射
|
||||
|
||||
依赖 `ely-gpui-component`(pin 6c2d28c,gpui 为 crates.io 的 `gpui-pre` =0.3.8)。名字取自 `reference/Ely-GPUI-Components/src`。gpui 用法规则见该仓库 `AGENTS.md`。`tests/scripts/agents_md.py` 核对下表每个名字都是组件库公开项。
|
||||
依赖 `ely-gpui-component`(pin 1b5fb07,gpui 为 crates.io 的 `gpui-pre` =0.3.8)。名字取自 `reference/Ely-GPUI-Components/src`。gpui 用法规则见该仓库 `AGENTS.md`。`tests/scripts/agents_md.py` 核对下表每个名字都是组件库公开项。
|
||||
|
||||
| 需要 | 用 |
|
||||
| --- | --- |
|
||||
@@ -55,7 +55,7 @@ site/ 官网(Vite 8、pnpm、TypeScript,无框架;等轴 SVG 积木
|
||||
| Table | `tables::{PivotTable, FilterBuilder, SortBuilder}` `misc::{CsvImporter, ExportDialog}` `editor::{CompletionMenu, SignatureHelp, FindWidget}` `forms::{CheckboxGroup, ColorPalette}` |
|
||||
| Mail | `mail::{MailboxList, MailList, MailThreadView, MailReader, MailComposer, SignatureEditor, ScheduleSend}` |
|
||||
| Tree | `git::{ChangesList, CommitInput, CommitList, lanes, DiffViewer, ConflictResolver, BlameView, BranchList, TagList, StashList, FileHistory}` |
|
||||
| Mark | `documents::{MarkdownDocument, MarkdownRenderer, ZenMode, MarkdownReader, MarkdownBlock, alert, is_toc, BlockCommand, InlineFormat, TableEdit, EditRefusal, TableRefusal}` `editor::{CodeEditor, FindWidget}`;导出与复制调用可视同一组读法;段落、格式与表格菜单经文档的 `block`、`format`、`edit_table` |
|
||||
| Mark | `documents::{MarkdownDocument, MarkdownRenderer, ZenMode, MarkdownReader, MarkdownBlock, alert, is_toc, BlockCommand, InlineFormat, TableEdit, EditRefusal, TableRefusal, DocumentTarget, TargetBlock}` `editor::{CodeEditor, FindWidget}`;导出与复制调用可视同一组读法;段落、格式与表格菜单经文档的 `block`、`format`、`edit_table`;右键菜单听 `DocumentEvent::Pointed` |
|
||||
| Agent | `agent::{ToolCallCard, PermissionPrompt, ToolApprovalDialog, AgentStepList, FileChangeCard, MultiFileDiffReview, ArtifactPanel, CostBreakdown}` `chat::{MessageList, PromptInput, StreamingMarkdown, ConversationList}` |
|
||||
| 动效 | `motion::{duration, Flip, Reorder, Transition, Stagger, ProgressBar, Spinner, Skeleton}` |
|
||||
| 主题 | `theme::{Theme, Mode}`;Omarchy 色板由 `ely-ui` 映射成组件库的调色板 |
|
||||
@@ -287,8 +287,10 @@ cargo run -p ely-doc 启动一个应用(ElyDoc 先 cargo build -p ely
|
||||
- 2026-10-12(用户报:Windows 上 ElyMark 的最近列表显示 `\\?\C:\…`):凡取真实路径一律 `dunce::canonicalize`(ely-files 的会话登记、ely-lok 的内核目录与配置目录、ElyMark 的文件夹、最近列表、会话与标签比对;ElyTree 原已如此):Windows 上能写成普通路径即普通路径,他处同 `std::fs::canonicalize`。只供读写的路径照旧保留 `\\?\`(`ely_files::save` 的落盘与同文件判定:在 250 字的文件夹里,普通写法的暂存文件名越过 260 而写不进),保存后交给会话与 `Saved` 的路径以 `dunce::simplified` 整体判定后为普通写法;ely-office 另存的目标先以完整路径求出,再以 `dunce::simplified` 整体判定能否写成普通路径(先简化文件夹再接文件名时,结尾带空格的名字会被 Windows 削成另一个已打开的文件)。`ely_files::recent` 读入时以 `dunce::simplified` 去掉旧版写下的 `\\?\` 并去重,下次写入即为普通路径。
|
||||
- 2026-10-12(用户报:ElyTable 的网格上一直是文字指针):`LokView` 原把指针写死为文字指针。现不按键的鼠标移动也交内核(悬停,不算编辑、不加修订),内核以 `LOK_CALLBACK_MOUSE_POINTER` 回报 CSS 指针名(`vcl` 的 `gaLOKPointerMap`),随事件批次到视图,换成 gpui 的指针:单元格上为箭头,编辑单元格或文字时为文字指针,链接为手;未知的名字记警告并用箭头。
|
||||
- 2026-10-13(用户定):ElyMark 以 Typora 1.14.10 为对照(R4;安装包与解包放在 `TyporaRef`,不入库):可视模式仍是按下的块以原文编辑;语法照 Typora 默认(`:表情:`、行内与块级 HTML 的常用标签、GitHub 提示块、`[toc]`、front matter 框;`==`、`^`、单个 `~` 照 GFM);快捷键照 Typora(Ctrl+1–6 标题、Ctrl+0 段落、Ctrl+/ 源码、Ctrl+Shift+=/-/0 字号、F8 专注、F9 打字机);右键菜单照 Typora 的布局,剪贴板与格式为图标行(组件库 `Menu` 新增)。Typora 与 GitHub 读同一份文件不同时随 GitHub(GFM,§14.3):表情名取 GitHub 现行的 gemoji(`emojis` 库,`:cricket:` 为蟋蟀),转义与字符引用之后照样是表情,自动链接与 `<code>` 里不是,同一 DOM 文字节点里第一个 `:名:` 前为空白或空格才全部转、否则全不转(`x:smile: :smile:` 原样,过滤标签不分节点),HTML 标签与强调交叉时照浏览器修复 CommonMark 输出,`</br>` 照 HTML5 也是换行,GFM 标签过滤的九种(`script`、`style` 等)照原文显示,提示块的标记读解析后的纯文字;Typora 只决定哪些扩展显示。导出、纯文本与富文本复制经组件 `MarkdownReader` 照可视读每个段落、标题、单元格与 HTML 块(各自一套新栈,块尾关闭未闭合的标签):脚注在原处、写作 `[号]`,链接不带标题(可视不显示),取代 C14.14 的页末脚注与 HTML 一律转义。审查改用 gpt-6-astra,effort max,fast。
|
||||
- 2026-10-14(用户定):Typora 是参照,不求一一相同;ElyMark 的验收与评审只看每项功能是否可用,缺 Typora 的某行、次序或措辞不同不算缺陷。
|
||||
- 2026-10-14(用户要求照 Word):ElyDoc 的右键与表格(R5)。右键菜单由 Ely 按目标自建(`apps/ely-doc/src/menu.rs`),开在所点之处(`LokView` 记下右键点,`take_menu` 一并交出):目标、各项可否与拼写建议都取自内核这次给的菜单(`ely_lok::menu`:有 `WrapMenu` 为图片,有 `TableInsertMenu` 为表格,否则正文;缺 `enabled` 即报错),命令只经 `COMMANDS`。剪切、复制、粘贴为图标行(组件库 `Menu::buttons`);正文为链接…、新建批注;表格另有插入、删除、合并、拆分、平均分布;图片为文字环绕(嵌入、四周、上下、浮于文字上方;内核无紧密、穿越、衬于文字下方的对应项,不列)、置于顶层、置于底层、插入题注…,新建批注灰显(内核的图片菜单无批注)。链接…随内核的 `.uno:InsertHyperlink`:须选中可编辑的文字,未选中时灰显(Word 未选中也可用;照做须改内核,未做)。拖动表格边线:worker 把 `LOK_CALLBACK_TABLE_SELECTED` 读成 `ely_lok::table::Table`(列与行边线、上下限),视图在边线上显示调整指针(命中范围不超过与邻线距离的四分之一,矮行的中间仍落在文档),按住时记下读到它的批次的修订与按住处的偏移,拖动时画参考线(出视图照跟),松开以 `.uno:TableChangeCurrentBorderPosition` 发一条命令(一步撤销),原地松开不发;其间文档变了即以过期拒绝(`view/borders.rs`)。内核在 LOK 下不处理边线的指针与拖动(依赖 LOK 没有的标尺)。属性栏在光标进表格时把表格组排在最前(组件库 9ff403d 起按标题记折叠)。Windows 真窗口逐项核对过(右键三种目标、插入行列、拖动列宽行高、撤销、保存后重开);拼写建议在 Windows 上内核不给(P3-01),未核对。
|
||||
- 2026-10-14(用户要求核对 ElyTable 与 ElyShow):ElyTable 的右键(R5.5)。菜单机制移入 `ely_office::menu`(取内核这次给的菜单、开在所点之处、剪贴板图标行、子菜单可否随其中各项),ElyDoc 与 ElyTable 共用;`ely_lok::menu` 的目标另有单元格(有 `.uno:InsertCell`)与 Writer 之外的绘图对象(有 `.uno:ArrangeMenu`)。网格照 Excel:插入 ▸、删除 ▸、清除内容(`.uno:ClearContents`,同 Delete 键,不弹内核的删除内容对话框)、合并、拆分、设置单元格格式(打开格式面板);对象为置于顶层、置于底层;编辑单元格时只有剪贴板行。行列表头由 Ely 自画,内核不给菜单:右键先选中该行或列(已选的整行整列含它即不动,同 Excel)。选中对象或正编辑图形里的文字时,绘图外壳取代了单元格外壳,`.uno:SelectRow`/`.uno:SelectColumn` 原无处执行而被丢弃;补丁 `0046-lok-calc-headers-leave-drawings.patch` 让 LOK 下视图外壳接下这两条:先结束图形编辑(键入的文字留下)并取消选中,再选行列,同 Calc 自己的表头(`DrawDeselectAll`),菜单为插入、删除、清除内容、行高或列宽、隐藏、显示。ElyTable 每一项的可否都取自内核对它所发的那条命令此刻的状态(内核的菜单只定目标):补丁 `0045-lok-command-states.patch` 加 `getCommandValues(".uno:CommandStates?commands=…")`,先冲出调度器、再逐条问调度器(同菜单栏),未知的命令即报错(`ely_lok::menu::runs`);LOK 推送的状态只有固定的一组,且在空闲时才更新。因此受保护而许插入行列的工作表照样可插;行高、列宽只在文档只读时禁用(内核的规则),受保护时由内核拒绝并报出其错误。ElyTable 无批注界面,不列批注。
|
||||
- 2026-10-14:ElyShow 的右键(R5.6)。画布右键照 PowerPoint 按目标出 Ely 的菜单(`apps/ely-show/src/menu.rs`,共用 `ely_office::menu`);`ely_lok::menu` 的目标另有幻灯片(有 `.uno:SlideLayoutMenu`)与 Writer 之外的图片(有 `.uno:ChangePicture`)。幻灯片为版式 ▸、新建批注;编辑文字为项目符号、编号、新建批注;图形与文本框为组合 ▸、置于顶层 ▸、置于底层 ▸、新建批注;图片另有替换…、裁剪;表格为插入 ▸、删除 ▸、合并单元格、新建批注;剪贴板同为图标行。每项可否取自内核对其命令此刻的状态(补丁 0045):整表选中时可插入行列,删除与合并要光标进单元格(内核的规则)。Impress 的 `LOK_CALLBACK_TABLE_SELECTED` 由 boost 属性树写出,数值与真假都是文字,空列表是空串,`table::read` 照收;拖动表格边线走 R5.3 的同一路径(`.uno:TableChangeCurrentBorderPosition`,偏移为 twips,内核换算)。补丁 `0047-lok-impress-table-edges.patch`:Impress 原只给内侧边线的上下限,行的下限是布局器写死的 600(上游待办),参考线与落点不符;补丁让两轴都带首尾边线的上下限(`leftMin`、`leftMax`、`rightMin`、`rightMax`,列只限从左到右),内侧行线取行自身的最小高度,`table::Lines::ends` 收下,有则按它夹住(内侧线也直接用内核的上限),Writer 不给时照旧留 40 twips;已在界外的线从不逆着拖动方向移动,原地按下松开不发命令;最左列边线原什么也不做却记一步撤销(上游待办),LOK 下改为改首列宽并随边线移动表格,同一步撤销,桌面的拖动手柄不变。正编辑的单元格按编辑器量最小高度,略大于内核真正允许的(约 2 像素),新表的行因此不能再缩,参考线与落点仍一致。正编辑表格单元格时在幻灯片空白处右键,内核只结束编辑、不给菜单,再按一次才有(BUGS P3-11)。
|
||||
- 2026-10-14(Gitea #1,Linux Wayland 报):ElyShow 左侧缩略图条滚轮不滚。根因:列表包在 `ContextMenu` 宿主里,宿主无尺寸,列表随内容长高、从不溢出,滚轮无处可滚(右栏正常);宿主改为 `size_full`(同 ElyPDF 的三处),`tests/strip.rs` 以 24 张幻灯片核对滚轮滚到最后一张。各应用其余 `ContextMenu` 宿主已核:ElyPDF 三处本有尺寸,ElyTable 的工作表标签条与下拉选项不是滚动列表。
|
||||
- 2026-10-14:ElyMark 的菜单与快捷键(R4.9,MARK-15)。项与键取自 Typora 1.14.10 主进程字节码的字符串表(`.work/typora-main-menus.txt`)与其 `zh-Hans.lproj/Menu.json`;实际大小在字节码里有 Ctrl+Shift+9 与 Ctrl+Shift+0 两串,照用户所定用 Ctrl+Shift+0,R4.11 在真窗口核对。表格是“段落”的子菜单(照 Typora),顶层不再有“表格”。原 Ctrl+1/2/3 切模式、Ctrl+=/-/0 字号、Ctrl+Shift+F 专注让给 Typora 的键;可视、源码、预览留在“视图”菜单,无键。Ctrl+/ 另绑在 `ElyEditor` 上(gpui 同深度后绑者胜),盖过代码编辑器的 `//` 注释切换(Markdown 没有这种注释);`MarkdownDocument` 的键上下文只在可视模式有。带 Shift 的标点:Windows 写键名(`ctrl-shift-[`),macOS 与 Linux 写字符(`cmd-{`),见 `blocks::shifted`。Ctrl+Enter 在打开的块里原是输入框的 Submit(文档不处理),改绑为下方插入行。拒绝一律成信息提示:当场的由 `Desk::edit` 说,后台读出的经 `DocumentEvent::EditRefused`、`view::Refused` 到宿主。菜单打开时,打开的块把焦点借给菜单,块与选区都留着,菜单命令照样作用于所选(组件 6d90351)。复制为 Markdown 与粘贴为纯文本只作用于文档:焦点在文档外的输入框(查找框、对话框)时交给该框自己的复制、粘贴。表格子菜单末项为删除表格(组件 `TableEdit::Delete`,一步撤销,插入点不在表格里即拒绝;在打开的块里删除后焦点回到文档,撤销键照用,组件 6c2d28c)。Typora 有而组件库暂缺的不进菜单:行内公式、上下标、注释、提示块子菜单、任务状态、列表缩进 Ctrl+[/]、代码工具。
|
||||
- 2026-10-14:ElyMark 的右键菜单(R4.10)。项、次序与显隐规则取自 Typora 1.14.10 的 `resources/window.html`(`#context-menu` 与其子菜单)与 `frame.js` 的显隐函数,记在 `.work/R4.10/typora-context-menu.txt`。菜单在 `view/menu.rs`,`MarkView` 自持(`ely_office::menu::Offer` 与 `ContextMenu::manual`):可视模式由组件的 `DocumentEvent::Pointed` 开在指针处,源码与预览由视图自己的右键开。剪切、复制、粘贴、删除所选范围为图标行,按下即把其键交回菜单打开前的焦点(`dispatch_keystroke`),与键盘同一路径;无选区时剪切、复制、删除灰显。其余项经各自的动作,显示所绑的键。组件 013f142、1b5fb07:文本框与代码编辑器右键落在选区里时保留选区,否则把插入点移到所点处;可视模式打开的块右键不写回、不关闭,目标在后台按全文读出(块外的引用定义照样解析);`MarkdownDocument::delete_image`(删除图片,一步撤销,无图片即 `EditRefusal::NoImage`);可视无块时 Ctrl+V 粘贴文字(原只收图片,文字被丢弃)。复制为 HTML 代码的图片照原地址(`Pictures::Written`,同 Typora),复制为富文本照旧内嵌。“编辑”菜单的复制项照 Typora 次序:纯文本、Markdown、HTML 代码、富文本。Typora 有而不做的:缩进与减少缩进行(可视只在打开的块里有)、复制表格、代码自动缩进、图片上传、缩放、移动与语法切换、拼写、表情复制、检查元素。gpui 的测试只发按下,菜单在 Enter 松开时选中,测试另发松开(`blocks/context.rs` 的 `choose`)。
|
||||
@@ -45,7 +45,9 @@ actions!(
|
||||
Strike,
|
||||
Hyperlink,
|
||||
InsertImage,
|
||||
ClearFormat
|
||||
ClearFormat,
|
||||
DeleteBlock,
|
||||
DeleteImage
|
||||
]
|
||||
);
|
||||
|
||||
@@ -150,6 +152,7 @@ pub(crate) fn refusal(why: EditRefusal, cx: &App) -> SharedString {
|
||||
EditRefusal::FrontMatter => "mark.refused.front_matter",
|
||||
EditRefusal::Outside => "mark.refused.outside",
|
||||
EditRefusal::Table => "mark.refused.table",
|
||||
EditRefusal::NoImage => "mark.refused.no_image",
|
||||
EditRefusal::Present => "mark.refused.present",
|
||||
EditRefusal::Across => "mark.refused.across",
|
||||
EditRefusal::TooLong => "mark.refused.too_long",
|
||||
@@ -226,11 +229,15 @@ impl Desk {
|
||||
Hyperlink => |d, cx| d.format(F::Link, cx),
|
||||
InsertImage => |d, cx| d.format(F::Image, cx),
|
||||
ClearFormat => |d, cx| d.format(F::Clear, cx),
|
||||
DeleteBlock => |d, cx| d.block(B::Delete, cx),
|
||||
DeleteImage => |d, cx| d.delete_image(cx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// macOS menus are the system's, not drawn.
|
||||
#[cfg(test)]
|
||||
mod context;
|
||||
#[cfg(all(test, not(target_os = "macos")))]
|
||||
mod menus;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
//! The right-click menu, driven as a user would (R4.10).
|
||||
|
||||
use ely_gpui_component::theme::{ActiveTheme as _, TextSize};
|
||||
use gpui::{
|
||||
ClipboardItem, Entity, Modifiers, MouseButton, Point, TestAppContext, VisualTestContext, point,
|
||||
px,
|
||||
};
|
||||
|
||||
use super::tests::{current, document, opened, toasted};
|
||||
use crate::{desk::Desk, view::Mode};
|
||||
|
||||
/// A right press on block `ix`'s first line, character `k`.
|
||||
fn right_on(ix: usize, k: usize, cx: &mut VisualTestContext) {
|
||||
let block = cx
|
||||
.debug_bounds(Box::leak(format!("markdown-block-{ix}").into_boxed_str()))
|
||||
.expect("the block is drawn");
|
||||
let size = cx.update(|window, cx| {
|
||||
cx.theme()
|
||||
.text_size(TextSize::Base)
|
||||
.to_pixels(window.rem_size())
|
||||
});
|
||||
// The test text system sets glyphs 0.6 em apart.
|
||||
let x = block.left() + px(13.0) + size * 0.6 * (k as f32 + 0.25);
|
||||
right_at(point(x, block.top() + px(10.0)), cx);
|
||||
}
|
||||
|
||||
fn right_at(at: Point<gpui::Pixels>, cx: &mut VisualTestContext) {
|
||||
cx.simulate_mouse_down(at, MouseButton::Right, Modifiers::none());
|
||||
cx.simulate_mouse_up(at, MouseButton::Right, Modifiers::none());
|
||||
cx.run_until_parked();
|
||||
}
|
||||
|
||||
/// Arrow `keys`, then Enter; menus choose on its release.
|
||||
fn choose(keys: &str, cx: &mut VisualTestContext) {
|
||||
if !keys.is_empty() {
|
||||
cx.simulate_keystrokes(keys);
|
||||
}
|
||||
cx.simulate_keystrokes("enter");
|
||||
let enter = gpui::Keystroke::parse("enter").expect("a key");
|
||||
cx.simulate_event(gpui::KeyUpEvent { keystroke: enter });
|
||||
cx.run_until_parked();
|
||||
}
|
||||
|
||||
fn clipboard(cx: &mut VisualTestContext) -> Option<String> {
|
||||
cx.read_from_clipboard().and_then(|item| item.text())
|
||||
}
|
||||
|
||||
fn switch(desk: &Entity<Desk>, mode: Mode, cx: &mut VisualTestContext) {
|
||||
desk.update_in(cx, |desk, window, cx| desk.switch(mode, window, cx));
|
||||
cx.run_until_parked();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn paste_from_the_menu_lands_at_the_pressed_caret(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("Intro\n", cx);
|
||||
cx.write_to_clipboard(ClipboardItem::new_string("New ".into()));
|
||||
right_on(0, 0, cx);
|
||||
choose("down", cx);
|
||||
assert_eq!(current(&desk, cx), "New Intro\n");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_link_opens_and_copies_its_address(cx: &mut TestAppContext) {
|
||||
let (_desk, cx, _files) = opened("[docs](https://x.test)\n", cx);
|
||||
right_on(0, 1, cx);
|
||||
choose("down", cx);
|
||||
assert_eq!(cx.opened_url().as_deref(), Some("https://x.test"));
|
||||
right_on(0, 1, cx);
|
||||
choose("down down down", cx);
|
||||
assert_eq!(clipboard(cx).as_deref(), Some("https://x.test"));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_code_block_copies_its_code_and_deletes_by_name(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("```rust\nlet x = 1;\n```\n\nNext\n", cx);
|
||||
right_on(0, 0, cx);
|
||||
choose("down down down", cx);
|
||||
assert_eq!(clipboard(cx).as_deref(), Some("let x = 1;"));
|
||||
right_on(0, 0, cx);
|
||||
choose("up", cx);
|
||||
assert!(
|
||||
!current(&desk, cx).contains("let x"),
|
||||
"{}",
|
||||
current(&desk, cx)
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_quote_is_deleted_from_the_last_row(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("> quoted\n\nNext\n", cx);
|
||||
right_on(0, 1, cx);
|
||||
choose("up", cx);
|
||||
let text = current(&desk, cx);
|
||||
assert!(!text.contains("quoted") && text.contains("Next"), "{text}");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_picture_shows_its_file_or_goes(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("Lead.\n\n\n", cx);
|
||||
right_on(1, 1, cx);
|
||||
choose("down", cx);
|
||||
assert_eq!(toasted(&desk, "no file here", cx), 1);
|
||||
right_on(1, 1, cx);
|
||||
choose("down down", cx);
|
||||
assert!(!current(&desk, cx).contains("!["), "{}", current(&desk, cx));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn source_cuts_the_selection_a_right_press_keeps(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("alpha beta\n", cx);
|
||||
switch(&desk, Mode::Source, cx);
|
||||
let editor = document(&desk, cx).read_with(cx, |document, _| document.editor().clone());
|
||||
editor.update(cx, |editor, cx| editor.select(std::iter::once(0..5), cx));
|
||||
let line = cx.debug_bounds("editor-line-0").expect("drawn");
|
||||
right_at(point(line.left() + px(20.0), line.top() + px(6.0)), cx);
|
||||
choose("down", cx);
|
||||
assert_eq!(current(&desk, cx), " beta\n");
|
||||
assert_eq!(clipboard(cx).as_deref(), Some("alpha"));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn an_open_block_copies_its_selection_and_stays(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("Intro words\n", cx);
|
||||
let block = cx.debug_bounds("markdown-block-0").expect("drawn");
|
||||
cx.simulate_mouse_down(block.center(), MouseButton::Left, Modifiers::none());
|
||||
cx.simulate_mouse_up(block.center(), MouseButton::Left, Modifiers::none());
|
||||
cx.run_until_parked();
|
||||
cx.simulate_keystrokes("home shift-right shift-right shift-right shift-right shift-right");
|
||||
let field = cx.debug_bounds("markdown-open").expect("open");
|
||||
right_at(point(field.left() + px(20.0), field.top() + px(14.0)), cx);
|
||||
choose("down right", cx);
|
||||
assert_eq!(clipboard(cx).as_deref(), Some("Intro"));
|
||||
assert!(
|
||||
cx.debug_bounds("markdown-open").is_some(),
|
||||
"the block stays open"
|
||||
);
|
||||
assert_eq!(current(&desk, cx), "Intro words\n");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn preview_offers_copies_only(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("alpha **beta**\n", cx);
|
||||
switch(&desk, Mode::Preview, cx);
|
||||
let block = cx.debug_bounds("markdown-block-0").expect("drawn");
|
||||
right_at(block.center(), cx);
|
||||
choose("down", cx);
|
||||
assert_eq!(clipboard(cx).as_deref(), Some("alpha beta\n"));
|
||||
right_at(block.center(), cx);
|
||||
choose("down down", cx);
|
||||
assert_eq!(clipboard(cx).as_deref(), Some("alpha **beta**\n"));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn html_code_keeps_picture_addresses(cx: &mut TestAppContext) {
|
||||
let (_desk, cx, _files) = opened(" and *it*\n", cx);
|
||||
cx.dispatch_action(crate::export::CopyHtml);
|
||||
cx.run_until_parked();
|
||||
let html = clipboard(cx).expect("copied");
|
||||
assert!(
|
||||
html.contains("src=\"missing.png\"") && html.contains("<em>it</em>"),
|
||||
"{html}"
|
||||
);
|
||||
}
|
||||
@@ -58,7 +58,8 @@ fn a_menu_formats_the_open_blocks_selection(cx: &mut TestAppContext) {
|
||||
fn a_menu_copies_the_open_blocks_selection(cx: &mut TestAppContext) {
|
||||
let (desk, cx, _files) = opened("alpha beta\n", cx);
|
||||
select_alpha(&desk, cx);
|
||||
choose(edit_menu, 1, cx);
|
||||
// Copy as Markdown, after Copy as Plain Text.
|
||||
choose(edit_menu, 2, cx);
|
||||
let copied = cx.read_from_clipboard().and_then(|item| item.text());
|
||||
assert_eq!(copied.as_deref(), Some("alpha"));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ pub(super) fn press(keys: &str, cx: &mut VisualTestContext) {
|
||||
}
|
||||
|
||||
/// The window's toasts that hold `words`.
|
||||
fn toasted(desk: &Entity<Desk>, words: &str, cx: &mut VisualTestContext) -> usize {
|
||||
pub(super) fn toasted(desk: &Entity<Desk>, words: &str, cx: &mut VisualTestContext) -> usize {
|
||||
let root = desk.read_with(cx, |desk, _| desk.core.root.upgrade().expect("the window"));
|
||||
let toasts = root.read_with(cx, |root, cx| root.toasts(cx));
|
||||
toasts
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
//! Rich, HTML code and plain text copies (R4.10).
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use ely_gpui_component::primitives::Severity;
|
||||
use ely_office::prelude::*;
|
||||
use ely_platform::clipboard::{self, Clip};
|
||||
use ely_ui::i18n::text;
|
||||
use gpui::{ClipboardItem, Context, Div, InteractiveElement as _, actions};
|
||||
|
||||
use crate::desk::Desk;
|
||||
use crate::output::{self, Pictures};
|
||||
|
||||
actions!(mark, [CopyRich, CopyHtml, CopyPlain]);
|
||||
|
||||
impl Desk {
|
||||
pub(super) fn copy_actions(root: Div, cx: &mut Context<Self>) -> Div {
|
||||
root.on_action(cx.listener(|desk, _: &CopyRich, _, cx| desk.copy_rich(cx)))
|
||||
.on_action(cx.listener(|desk, _: &CopyHtml, _, cx| desk.copy_html(cx)))
|
||||
.on_action(cx.listener(|desk, _: &CopyPlain, _, cx| desk.copy_plain(cx)))
|
||||
}
|
||||
|
||||
/// The selection or whole text, and the file's folder.
|
||||
fn copied_text(&mut self, cx: &mut Context<Self>) -> Option<(String, Option<PathBuf>)> {
|
||||
let Some(view) = self.active_view() else {
|
||||
self.no_document(cx);
|
||||
return None;
|
||||
};
|
||||
let document = view.read(cx).document().read(cx);
|
||||
let selected = document.selected(cx);
|
||||
let markdown = match selected.is_empty() {
|
||||
true => document.text(cx),
|
||||
false => selected,
|
||||
};
|
||||
let beside = (self.active_tab())
|
||||
.and_then(|tab| tab.session.path())
|
||||
.and_then(|path| path.parent())
|
||||
.map(PathBuf::from);
|
||||
Some((markdown, beside))
|
||||
}
|
||||
|
||||
fn copy_failed(&mut self, error: &std::io::Error, cx: &mut Context<Self>) {
|
||||
let said = text(cx, "mark.copy.failed", &[("error", &error.to_string())]);
|
||||
self.toast(said, Severity::Danger, cx);
|
||||
}
|
||||
|
||||
/// HTML for pasting, the Markdown beside it.
|
||||
fn copy_rich(&mut self, cx: &mut Context<Self>) {
|
||||
let Some((markdown, beside)) = self.copied_text(cx) else {
|
||||
return;
|
||||
};
|
||||
let copied =
|
||||
output::body(&markdown, beside.as_deref(), &Pictures::Inline).and_then(|mut page| {
|
||||
let clip = Clip::Html {
|
||||
html: std::mem::take(&mut page.html),
|
||||
text: markdown,
|
||||
};
|
||||
clipboard::write(&clip)
|
||||
.map(|()| page)
|
||||
.map_err(|error| std::io::Error::other(format!("{error:#}")))
|
||||
});
|
||||
match copied {
|
||||
Ok(page) => self.left_out(&page, cx),
|
||||
Err(error) => self.copy_failed(&error, cx),
|
||||
}
|
||||
}
|
||||
|
||||
/// The HTML as text; pictures keep their addresses.
|
||||
fn copy_html(&mut self, cx: &mut Context<Self>) {
|
||||
let Some((markdown, beside)) = self.copied_text(cx) else {
|
||||
return;
|
||||
};
|
||||
match output::body(&markdown, beside.as_deref(), &Pictures::Written) {
|
||||
Ok(mut page) => {
|
||||
log::info!("mark: {} bytes copied as HTML code", page.html.len());
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(std::mem::take(&mut page.html)));
|
||||
self.left_out(&page, cx);
|
||||
}
|
||||
Err(error) => self.copy_failed(&error, cx),
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_plain(&mut self, cx: &mut Context<Self>) {
|
||||
let Some((markdown, _)) = self.copied_text(cx) else {
|
||||
return;
|
||||
};
|
||||
match output::plain(&markdown) {
|
||||
Ok(plain) => {
|
||||
log::info!("mark: {} bytes copied as plain text", plain.len());
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(plain));
|
||||
}
|
||||
Err(error) => self.copy_failed(&error, cx),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,20 +9,20 @@ use ely_gpui_component::{
|
||||
theme::ControlSize,
|
||||
};
|
||||
use ely_office::prelude::*;
|
||||
use ely_platform::clipboard::{self, Clip};
|
||||
use ely_ui::{
|
||||
commands::{Export, Print},
|
||||
i18n::text,
|
||||
};
|
||||
use gpui::{
|
||||
AnyElement, Context, Div, InteractiveElement, IntoElement, ParentElement as _, TaskExt as _,
|
||||
actions,
|
||||
};
|
||||
|
||||
use crate::desk::Desk;
|
||||
use crate::output::{self, Format, Page, Pictures, Target};
|
||||
use crate::output::{self, Format, Page, Target};
|
||||
|
||||
actions!(mark, [CopyRich]);
|
||||
mod copy;
|
||||
|
||||
pub use copy::{CopyHtml, CopyPlain, CopyRich};
|
||||
|
||||
const FORMATS: [(Format, &str, &str); 4] = [
|
||||
(Format::Page, "page", "html"),
|
||||
@@ -41,9 +41,10 @@ fn key(format: Format) -> &'static str {
|
||||
|
||||
impl Desk {
|
||||
pub fn output_actions(root: Div, cx: &mut Context<Self>) -> Div {
|
||||
root.on_action(cx.listener(|desk, _: &Export, _, cx| desk.ask_export(cx)))
|
||||
.on_action(cx.listener(|desk, _: &Print, _, cx| desk.print(cx)))
|
||||
.on_action(cx.listener(|desk, _: &CopyRich, _, cx| desk.copy_rich(cx)))
|
||||
let root = root
|
||||
.on_action(cx.listener(|desk, _: &Export, _, cx| desk.ask_export(cx)))
|
||||
.on_action(cx.listener(|desk, _: &Print, _, cx| desk.print(cx)));
|
||||
Self::copy_actions(root, cx)
|
||||
}
|
||||
|
||||
pub(crate) fn no_document(&self, cx: &mut Context<Self>) {
|
||||
@@ -275,39 +276,6 @@ impl Desk {
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
|
||||
/// The selection, or the whole text, as HTML.
|
||||
fn copy_rich(&mut self, cx: &mut Context<Self>) {
|
||||
let Some(view) = self.active_view() else {
|
||||
return self.no_document(cx);
|
||||
};
|
||||
let document = view.read(cx).document().clone();
|
||||
let selected = document.read(cx).selected(cx);
|
||||
let markdown = match selected.is_empty() {
|
||||
true => document.read(cx).text(cx),
|
||||
false => selected,
|
||||
};
|
||||
let beside = self
|
||||
.active_tab()
|
||||
.and_then(|tab| tab.session.path())
|
||||
.and_then(|path| path.parent());
|
||||
let copied = output::body(&markdown, beside, &Pictures::Inline).and_then(|mut page| {
|
||||
let clip = Clip::Html {
|
||||
html: std::mem::take(&mut page.html),
|
||||
text: markdown,
|
||||
};
|
||||
clipboard::write(&clip)
|
||||
.map(|()| page)
|
||||
.map_err(|error| std::io::Error::other(format!("{error:#}")))
|
||||
});
|
||||
match copied {
|
||||
Ok(page) => self.left_out(&page, cx),
|
||||
Err(error) => {
|
||||
let said = text(cx, "mark.copy.failed", &[("error", &error.to_string())]);
|
||||
self.toast(said, Severity::Danger, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A file of its own for each print job.
|
||||
|
||||
@@ -54,7 +54,9 @@ pub fn menus(look: &crate::look::Look, cx: &App) -> Vec<Menu> {
|
||||
let item = |key: &str, action: Box<dyn Action>| item(key, action, cx);
|
||||
vec![
|
||||
Menu::new(text(cx, "menu.edit", &[])).items([
|
||||
item("mark.copy.plain", Box::new(crate::export::CopyPlain)),
|
||||
item("mark.copy.markdown", Box::new(crate::clip::CopyMarkdown)),
|
||||
item("mark.copy.html", Box::new(crate::export::CopyHtml)),
|
||||
item("mark.copy.rich", Box::new(crate::export::CopyRich)),
|
||||
item("mark.paste.plain", Box::new(crate::clip::PastePlain)),
|
||||
MenuItem::separator(),
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::{io, path::Path};
|
||||
use ely_gpui_component::documents::markdown_options;
|
||||
|
||||
pub use files::{Format, Target, write};
|
||||
pub use pictures::Pictures;
|
||||
pub use pictures::{Pictures, picture_file};
|
||||
pub use plain::plain;
|
||||
|
||||
/// A page and what it could not carry.
|
||||
|
||||
@@ -19,6 +19,8 @@ pub enum Pictures {
|
||||
Folder(PathBuf),
|
||||
/// Copied into this folder, in formats MuPDF reads.
|
||||
Pdf(PathBuf),
|
||||
/// Addresses as the text writes them.
|
||||
Written,
|
||||
}
|
||||
|
||||
/// Picture formats MuPDF reads from files.
|
||||
@@ -40,6 +42,22 @@ pub(super) struct Placed<'a> {
|
||||
pub made: bool,
|
||||
}
|
||||
|
||||
/// A picture address's file; none for other schemes.
|
||||
pub fn picture_file(url: &str, beside: Option<&Path>) -> Option<PathBuf> {
|
||||
if url.to_lowercase().starts_with("file://") {
|
||||
return Some(file_path(&url["file://".len()..]));
|
||||
}
|
||||
if scheme(url).is_some() {
|
||||
return None;
|
||||
}
|
||||
let path = PathBuf::from(decoded(url));
|
||||
match (path.is_absolute(), beside) {
|
||||
(true, _) => Some(path),
|
||||
(false, Some(beside)) => Some(beside.join(path)),
|
||||
(false, None) => None,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Placed<'a> {
|
||||
pub fn new(beside: Option<&'a Path>, pictures: &'a Pictures) -> Self {
|
||||
Self {
|
||||
@@ -56,6 +74,9 @@ impl<'a> Placed<'a> {
|
||||
|
||||
/// The `src` for `url`; none when it is not carried.
|
||||
pub fn place(&mut self, url: &str) -> io::Result<Option<String>> {
|
||||
if matches!(self.pictures, Pictures::Written) {
|
||||
return Ok(Some(url.to_owned()));
|
||||
}
|
||||
let lower = url.to_lowercase();
|
||||
if lower.starts_with("http://") || lower.starts_with("https://") {
|
||||
return Ok((!self.pdf()).then(|| url.to_owned()));
|
||||
@@ -67,20 +88,10 @@ impl<'a> Placed<'a> {
|
||||
};
|
||||
return Ok(readable.then(|| url.to_owned()));
|
||||
}
|
||||
let path = match (lower.starts_with("file://"), scheme(url)) {
|
||||
(true, _) => file_path(&url["file://".len()..]),
|
||||
// Other schemes are no picture of the document's.
|
||||
(false, Some(_)) => return Ok(None),
|
||||
(false, None) => {
|
||||
let path = PathBuf::from(decoded(url));
|
||||
match (path.is_absolute(), self.beside) {
|
||||
(true, _) => path,
|
||||
(false, Some(beside)) => beside.join(path),
|
||||
(false, None) => return Ok(None),
|
||||
}
|
||||
}
|
||||
};
|
||||
self.carried(&path)
|
||||
match picture_file(url, self.beside) {
|
||||
Some(path) => self.carried(&path),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
fn carried(&mut self, path: &Path) -> io::Result<Option<String>> {
|
||||
@@ -98,6 +109,7 @@ impl<'a> Placed<'a> {
|
||||
}
|
||||
Pictures::Pdf(_) if !READABLE.contains(&extension.as_str()) => return Ok(None),
|
||||
Pictures::Folder(folder) | Pictures::Pdf(folder) => folder.clone(),
|
||||
Pictures::Written => unreachable!("written addresses are not carried"),
|
||||
};
|
||||
let named = match self.copied.iter().find(|(from, _)| from == path) {
|
||||
Some((_, name)) => name.clone(),
|
||||
|
||||
@@ -7,7 +7,8 @@ use ely_gpui_component::documents::{
|
||||
};
|
||||
use gpui::{
|
||||
AppContext as _, Context, Entity, EventEmitter, FocusHandle, Focusable as _,
|
||||
InteractiveElement as _, IntoElement, ParentElement as _, Render, Styled as _, Window, div,
|
||||
InteractiveElement as _, IntoElement, MouseButton, ParentElement as _, Render, Styled as _,
|
||||
Window, div,
|
||||
};
|
||||
|
||||
use crate::engine::{Doc, mark};
|
||||
@@ -86,6 +87,8 @@ pub struct MarkView {
|
||||
pub(crate) shown: bool,
|
||||
/// Trackpad pixels toward the next size step.
|
||||
wheel: f32,
|
||||
/// The last right-click menu asked.
|
||||
offer: Option<ely_office::menu::Offer<menu::Asked>>,
|
||||
pub focus: FocusHandle,
|
||||
}
|
||||
|
||||
@@ -132,6 +135,7 @@ impl MarkView {
|
||||
folder: None,
|
||||
shown: false,
|
||||
wheel: 0.0,
|
||||
offer: None,
|
||||
focus,
|
||||
}
|
||||
}
|
||||
@@ -278,6 +282,10 @@ impl MarkView {
|
||||
if let DocumentEvent::EditRefused(why) = event {
|
||||
return cx.emit(Refused(*why));
|
||||
}
|
||||
if let DocumentEvent::Pointed(target) = event {
|
||||
let at = window.mouse_position();
|
||||
return self.ask_menu(menu::Asked::Text(target.clone()), at, cx);
|
||||
}
|
||||
if *event == DocumentEvent::Changed {
|
||||
let text = document.read(cx).text(cx);
|
||||
self.doc.lock().expect("the text lock").current = text;
|
||||
@@ -313,7 +321,7 @@ impl MarkView {
|
||||
}
|
||||
|
||||
impl Render for MarkView {
|
||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let view = cx.entity();
|
||||
// Ctrl and the wheel size text, as Ctrl+= does.
|
||||
let zoom = ely_ui::wheel::zoom_layer(move |event, window, cx| {
|
||||
@@ -329,10 +337,16 @@ impl Render for MarkView {
|
||||
.relative()
|
||||
.size_full()
|
||||
.track_focus(&self.focus)
|
||||
.on_mouse_down(
|
||||
MouseButton::Right,
|
||||
cx.listener(|view, event, _, cx| view.pressed(event, cx)),
|
||||
)
|
||||
.child(self.document.clone())
|
||||
.child(zoom)
|
||||
.children(self.context_menu(window, cx))
|
||||
}
|
||||
}
|
||||
|
||||
mod menu;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,457 @@
|
||||
//! The right-click menu, as Typora's (R4.10).
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use ely_gpui_component::{
|
||||
documents::{DocumentTarget, TargetBlock},
|
||||
menus::{ContextMenu, Menu, MenuItem},
|
||||
primitives::IconName,
|
||||
};
|
||||
use ely_office::menu::Offer;
|
||||
use ely_ui::i18n::text;
|
||||
use gpui::{
|
||||
Action, App, ClipboardItem, Context, Keystroke, MouseDownEvent, Pixels, Point, SharedString,
|
||||
Window,
|
||||
};
|
||||
|
||||
use super::{Failed, MarkView, Mode};
|
||||
use crate::{blocks as b, clip, export, tools};
|
||||
|
||||
/// What a right press asked a menu for.
|
||||
pub(crate) enum Asked {
|
||||
/// The visual mode's target.
|
||||
Text(DocumentTarget),
|
||||
Source,
|
||||
Preview,
|
||||
}
|
||||
|
||||
impl MarkView {
|
||||
pub(super) fn ask_menu(&mut self, asked: Asked, at: Point<Pixels>, cx: &mut Context<Self>) {
|
||||
self.offer = Some(Offer::new(self.offer.as_ref(), 0, asked, at));
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// A right press the visual blocks left alone.
|
||||
pub(super) fn pressed(&mut self, event: &MouseDownEvent, cx: &mut Context<Self>) {
|
||||
let asked = match self.mode {
|
||||
Mode::Visual => return,
|
||||
Mode::Source => Asked::Source,
|
||||
Mode::Preview => Asked::Preview,
|
||||
};
|
||||
log::info!("mark: a right press in {}", self.mode.name());
|
||||
self.ask_menu(asked, event.position, cx);
|
||||
}
|
||||
|
||||
pub(super) fn context_menu(
|
||||
&self,
|
||||
window: &Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<ContextMenu> {
|
||||
let offer = self.offer.as_ref()?;
|
||||
let selected = !self.document.read(cx).selected(cx).is_empty();
|
||||
let menu = match &offer.what {
|
||||
Asked::Text(target) => self.text_menu(target, selected, window, cx),
|
||||
Asked::Source => Rows::default()
|
||||
.buttons(clipboard(selected, cx))
|
||||
.row(MenuItem::submenu(
|
||||
said("mark.menu.copy_as", cx),
|
||||
copy_as(window, cx),
|
||||
))
|
||||
.menu(),
|
||||
Asked::Preview => copies(window, cx).into_iter().fold(Menu::new(), Menu::item),
|
||||
};
|
||||
Some(offer.host("mark-menu", menu))
|
||||
}
|
||||
|
||||
/// Typora's groups, shown as the target allows.
|
||||
fn text_menu(
|
||||
&self,
|
||||
target: &DocumentTarget,
|
||||
selected: bool,
|
||||
window: &Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Menu {
|
||||
use TargetBlock as K;
|
||||
let view = cx.entity();
|
||||
let block = target.block;
|
||||
let is = |kinds: &[K]| block.is_some_and(|block| kinds.contains(&block));
|
||||
let inline = is(&[
|
||||
K::Paragraph,
|
||||
K::Quote,
|
||||
K::Alert,
|
||||
K::List,
|
||||
K::Table,
|
||||
K::Footnote,
|
||||
]) || matches!(block, Some(K::Heading(_)));
|
||||
let mut rows = Rows::default();
|
||||
if let Some(url) = &target.image {
|
||||
let url = url.clone();
|
||||
let key = match web(&url) {
|
||||
true => "mark.image.browser",
|
||||
false => "mark.image.location",
|
||||
};
|
||||
let view = view.clone();
|
||||
rows =
|
||||
rows.row(MenuItem::new(said(key, cx)).on_click(move |_, cx| {
|
||||
view.update(cx, |view, cx| view.show_picture(&url, cx))
|
||||
}))
|
||||
.row(run(
|
||||
said("mark.image.delete", cx),
|
||||
Box::new(b::DeleteImage),
|
||||
window,
|
||||
))
|
||||
.line();
|
||||
}
|
||||
if let Some(url) = &target.link {
|
||||
let (url, view) = (url.clone(), view.clone());
|
||||
rows = rows
|
||||
.row(
|
||||
MenuItem::new(said("mark.link.open", cx))
|
||||
.on_click(move |_, cx| view.update(cx, |view, cx| view.follow(&url, cx))),
|
||||
)
|
||||
.line();
|
||||
}
|
||||
if is(&[K::Math, K::Html]) {
|
||||
let (at, view) = (target.at, view.clone());
|
||||
rows = rows.row(MenuItem::new(said("mark.block.edit", cx)).on_click(
|
||||
move |window, cx| {
|
||||
let document = view.read(cx).document.clone();
|
||||
document.update(cx, |document, cx| document.show_match(at..at, window, cx));
|
||||
},
|
||||
));
|
||||
}
|
||||
rows = rows.buttons(clipboard(selected, cx));
|
||||
if let Some(url) = &target.link {
|
||||
rows = rows.row(copy_text(said("mark.link.copy", cx), url));
|
||||
}
|
||||
rows = rows.row(MenuItem::submenu(
|
||||
said("mark.menu.copy_as", cx),
|
||||
copy_as(window, cx),
|
||||
));
|
||||
if let Some(code) = &target.code {
|
||||
rows = rows.row(copy_text(said("mark.code.copy", cx), code));
|
||||
}
|
||||
rows = rows.line();
|
||||
if inline {
|
||||
rows = rows.buttons(formats(window, cx));
|
||||
}
|
||||
if !is(&[K::Math, K::Html, K::FrontMatter]) {
|
||||
rows = rows.buttons(wraps(window, cx));
|
||||
}
|
||||
rows = rows.line();
|
||||
if target.in_table {
|
||||
rows = rows.row(MenuItem::submenu(
|
||||
said("mark.menu.table", cx),
|
||||
table(window, cx),
|
||||
));
|
||||
} else if block.is_some() && !is(&[K::Math, K::Html]) {
|
||||
let name = kind(block, cx);
|
||||
rows = rows.row(MenuItem::submenu(name, paragraph(window, cx)));
|
||||
}
|
||||
rows = rows.row(MenuItem::submenu(
|
||||
said("mark.menu.insert", cx),
|
||||
insert(inline, window, cx),
|
||||
));
|
||||
if block.is_some() && !is(&[K::Paragraph]) && !matches!(block, Some(K::Heading(_))) {
|
||||
let name = kind(block, cx);
|
||||
let label = text(cx, "mark.block.delete", &[("block", &name)]);
|
||||
rows = rows
|
||||
.line()
|
||||
.row(run(label, Box::new(b::DeleteBlock), window));
|
||||
}
|
||||
rows.menu()
|
||||
}
|
||||
|
||||
/// Shows a local picture's file, or opens a web one.
|
||||
fn show_picture(&mut self, url: &str, cx: &mut Context<Self>) {
|
||||
if web(url) {
|
||||
log::info!("mark: a picture opens in the browser");
|
||||
return cx.open_url(url);
|
||||
}
|
||||
match crate::output::picture_file(url, self.folder.as_deref()) {
|
||||
Some(path) if path.is_file() => cx.reveal_path(&path),
|
||||
_ => {
|
||||
log::info!("mark: a picture with no file here");
|
||||
cx.emit(Failed(said("mark.image.no_file", cx).to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn web(url: &str) -> bool {
|
||||
let lower = url.to_lowercase();
|
||||
lower.starts_with("http://") || lower.starts_with("https://")
|
||||
}
|
||||
|
||||
fn said(key: &str, cx: &App) -> SharedString {
|
||||
text(cx, key, &[])
|
||||
}
|
||||
|
||||
/// Rows with lines only between groups.
|
||||
#[derive(Default)]
|
||||
struct Rows {
|
||||
menu: Menu,
|
||||
filled: bool,
|
||||
line: bool,
|
||||
}
|
||||
|
||||
impl Rows {
|
||||
fn row(self, item: MenuItem) -> Self {
|
||||
self.with(|menu| menu.item(item))
|
||||
}
|
||||
|
||||
fn buttons(self, items: Vec<MenuItem>) -> Self {
|
||||
self.with(|menu| menu.buttons(items))
|
||||
}
|
||||
|
||||
fn with(mut self, add: impl FnOnce(Menu) -> Menu) -> Self {
|
||||
if self.line && self.filled {
|
||||
self.menu = self.menu.separator();
|
||||
}
|
||||
self.menu = add(self.menu);
|
||||
(self.filled, self.line) = (true, false);
|
||||
self
|
||||
}
|
||||
|
||||
fn line(mut self) -> Self {
|
||||
self.line = true;
|
||||
self
|
||||
}
|
||||
|
||||
fn menu(self) -> Menu {
|
||||
self.menu
|
||||
}
|
||||
}
|
||||
|
||||
/// A row that runs `action`, its keys shown.
|
||||
fn run(label: SharedString, action: Box<dyn Action>, window: &Window) -> MenuItem {
|
||||
let keys = (window.highest_precedence_binding_for_action(action.as_ref())).map(|binding| {
|
||||
let strokes: Vec<String> = binding.keystrokes().iter().map(|k| k.unparse()).collect();
|
||||
strokes.join(" ")
|
||||
});
|
||||
let action: Rc<Box<dyn Action>> = Rc::new(action);
|
||||
let row = MenuItem::new(label)
|
||||
.on_click(move |window, cx| window.dispatch_action(action.boxed_clone(), cx));
|
||||
match keys {
|
||||
Some(keys) => row.keys(keys),
|
||||
None => row,
|
||||
}
|
||||
}
|
||||
|
||||
/// A button that presses `stroke` where focus went back.
|
||||
fn press(label: SharedString, icon: IconName, stroke: &str, shown: bool) -> MenuItem {
|
||||
let keystroke = Keystroke::parse(stroke).expect("a fixed keystroke");
|
||||
let button = MenuItem::new(label).icon(icon);
|
||||
let button = match shown {
|
||||
true => button.keys(keystroke.unparse()),
|
||||
false => button,
|
||||
};
|
||||
button.on_click(move |window, cx| {
|
||||
let keystroke = keystroke.clone();
|
||||
window.defer(cx, move |window, cx| {
|
||||
window.dispatch_keystroke(keystroke, cx);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
fn clipboard(selected: bool, cx: &App) -> Vec<MenuItem> {
|
||||
vec![
|
||||
press(
|
||||
said("mark.edit.cut", cx),
|
||||
IconName::Scissors,
|
||||
"secondary-x",
|
||||
true,
|
||||
)
|
||||
.disabled(!selected),
|
||||
press(
|
||||
said("mark.edit.copy", cx),
|
||||
IconName::Copy,
|
||||
"secondary-c",
|
||||
true,
|
||||
)
|
||||
.disabled(!selected),
|
||||
press(
|
||||
said("mark.edit.paste", cx),
|
||||
IconName::Clipboard,
|
||||
"secondary-v",
|
||||
true,
|
||||
),
|
||||
press(
|
||||
said("mark.edit.delete", cx),
|
||||
IconName::Trash2,
|
||||
"backspace",
|
||||
false,
|
||||
)
|
||||
.disabled(!selected),
|
||||
]
|
||||
}
|
||||
|
||||
fn copy_text(label: SharedString, copied: &str) -> MenuItem {
|
||||
let copied = copied.to_string();
|
||||
MenuItem::new(label).on_click(move |_, cx| {
|
||||
log::info!("mark: {} bytes copied from the menu", copied.len());
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(copied.clone()));
|
||||
})
|
||||
}
|
||||
|
||||
/// Typora's Copy / Paste As rows.
|
||||
fn copies(window: &Window, cx: &App) -> Vec<MenuItem> {
|
||||
vec![
|
||||
run(
|
||||
said("mark.copy.plain", cx),
|
||||
Box::new(export::CopyPlain),
|
||||
window,
|
||||
),
|
||||
run(
|
||||
said("mark.copy.markdown", cx),
|
||||
Box::new(clip::CopyMarkdown),
|
||||
window,
|
||||
),
|
||||
run(
|
||||
said("mark.copy.html", cx),
|
||||
Box::new(export::CopyHtml),
|
||||
window,
|
||||
),
|
||||
run(
|
||||
said("mark.copy.rich", cx),
|
||||
Box::new(export::CopyRich),
|
||||
window,
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
fn copy_as(window: &Window, cx: &App) -> Menu {
|
||||
let paste = run(
|
||||
said("mark.paste.plain", cx),
|
||||
Box::new(clip::PastePlain),
|
||||
window,
|
||||
);
|
||||
copies(window, cx)
|
||||
.into_iter()
|
||||
.fold(Menu::new(), Menu::item)
|
||||
.separator()
|
||||
.item(paste)
|
||||
}
|
||||
|
||||
fn formats(window: &Window, cx: &App) -> Vec<MenuItem> {
|
||||
let row = |key, action: Box<dyn Action>, name| run(said(key, cx), action, window).icon(name);
|
||||
vec![
|
||||
row("mark.format.strong", Box::new(b::Strong), IconName::Bold),
|
||||
row(
|
||||
"mark.format.emphasis",
|
||||
Box::new(b::Emphasis),
|
||||
IconName::Italic,
|
||||
),
|
||||
row("mark.format.code", Box::new(b::InlineCode), IconName::Code),
|
||||
row("mark.format.link", Box::new(b::Hyperlink), IconName::Link),
|
||||
]
|
||||
}
|
||||
|
||||
fn wraps(window: &Window, cx: &App) -> Vec<MenuItem> {
|
||||
let row = |key, action: Box<dyn Action>, name| run(said(key, cx), action, window).icon(name);
|
||||
vec![
|
||||
row("mark.block.quote", Box::new(b::Quote), IconName::Quote),
|
||||
row(
|
||||
"mark.block.ordered",
|
||||
Box::new(b::OrderedList),
|
||||
IconName::ListOrdered,
|
||||
),
|
||||
row("mark.block.bullet", Box::new(b::BulletList), IconName::List),
|
||||
row(
|
||||
"mark.block.task",
|
||||
Box::new(b::TaskList),
|
||||
IconName::ListChecks,
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
fn paragraph(window: &Window, cx: &App) -> Menu {
|
||||
let row = |key, action: Box<dyn Action>| run(said(key, cx), action, window);
|
||||
Menu::new()
|
||||
.item(row("mark.block.h1", Box::new(b::Heading1)))
|
||||
.item(row("mark.block.h2", Box::new(b::Heading2)))
|
||||
.item(row("mark.block.h3", Box::new(b::Heading3)))
|
||||
.item(row("mark.block.h4", Box::new(b::Heading4)))
|
||||
.item(row("mark.block.h5", Box::new(b::Heading5)))
|
||||
.item(row("mark.block.h6", Box::new(b::Heading6)))
|
||||
.separator()
|
||||
.item(row("mark.block.paragraph", Box::new(b::Paragraph)))
|
||||
}
|
||||
|
||||
fn table(window: &Window, cx: &App) -> Menu {
|
||||
let row = |key, action: Box<dyn Action>| run(said(key, cx), action, window);
|
||||
Menu::new()
|
||||
.item(row("mark.table.row_above", Box::new(tools::RowAbove)))
|
||||
.item(row("mark.table.row_below", Box::new(tools::RowBelow)))
|
||||
.item(row("mark.table.column_left", Box::new(tools::ColumnLeft)))
|
||||
.item(row("mark.table.column_right", Box::new(tools::ColumnRight)))
|
||||
.separator()
|
||||
.item(row("mark.table.move_row_up", Box::new(tools::MoveRowUp)))
|
||||
.item(row(
|
||||
"mark.table.move_row_down",
|
||||
Box::new(tools::MoveRowDown),
|
||||
))
|
||||
.item(row(
|
||||
"mark.table.move_column_left",
|
||||
Box::new(tools::MoveColumnLeft),
|
||||
))
|
||||
.item(row(
|
||||
"mark.table.move_column_right",
|
||||
Box::new(tools::MoveColumnRight),
|
||||
))
|
||||
.separator()
|
||||
.item(row("mark.table.delete_row", Box::new(tools::DeleteRow)))
|
||||
.item(row(
|
||||
"mark.table.delete_column",
|
||||
Box::new(tools::DeleteColumn),
|
||||
))
|
||||
.separator()
|
||||
.item(row("mark.table.tidy", Box::new(tools::TidyTable)))
|
||||
.separator()
|
||||
.item(row("mark.table.delete", Box::new(tools::DeleteTable)))
|
||||
}
|
||||
|
||||
fn insert(inline: bool, window: &Window, cx: &App) -> Menu {
|
||||
let row = |key, action: Box<dyn Action>| run(said(key, cx), action, window);
|
||||
let menu = match inline {
|
||||
true => Menu::new()
|
||||
.item(row("mark.insert.image", Box::new(b::InsertImage)))
|
||||
.separator(),
|
||||
false => Menu::new(),
|
||||
};
|
||||
menu.item(row("mark.block.footnote", Box::new(b::Footnote)))
|
||||
.item(row("mark.block.link_reference", Box::new(b::LinkReference)))
|
||||
.item(row("mark.block.rule", Box::new(b::Rule)))
|
||||
.item(row("mark.menu.table", Box::new(tools::InsertTable)))
|
||||
.item(row("mark.block.code", Box::new(b::CodeFences)))
|
||||
.item(row("mark.block.math", Box::new(b::MathBlock)))
|
||||
.item(row("mark.block.toc", Box::new(b::Toc)))
|
||||
.item(row("mark.block.front_matter", Box::new(b::FrontMatter)))
|
||||
.separator()
|
||||
.item(row("mark.insert.before", Box::new(b::ParagraphBefore)))
|
||||
.item(row("mark.insert.after", Box::new(b::ParagraphAfter)))
|
||||
}
|
||||
|
||||
/// A block kind's name, as Typora's menus say it.
|
||||
fn kind(block: Option<TargetBlock>, cx: &App) -> SharedString {
|
||||
use TargetBlock as K;
|
||||
let key = match block {
|
||||
None | Some(K::Paragraph) => "mark.block.paragraph",
|
||||
Some(K::Heading(level)) => {
|
||||
return said(&format!("mark.block.h{}", level.clamp(1, 6)), cx);
|
||||
}
|
||||
Some(K::Quote) => "mark.block.quote",
|
||||
Some(K::Alert) => "mark.kind.alert",
|
||||
Some(K::List) => "mark.kind.list",
|
||||
Some(K::Code) => "mark.block.code",
|
||||
Some(K::Math) => "mark.block.math",
|
||||
Some(K::Table) => "mark.menu.table",
|
||||
Some(K::Rule) => "mark.block.rule",
|
||||
Some(K::Html) => "mark.kind.html",
|
||||
Some(K::Footnote) => "mark.block.footnote",
|
||||
Some(K::Definition) => "mark.block.link_reference",
|
||||
Some(K::FrontMatter) => "mark.block.front_matter",
|
||||
Some(K::Toc) => "mark.block.toc",
|
||||
};
|
||||
said(key, cx)
|
||||
}
|
||||
@@ -76,6 +76,33 @@ pub(super) const EN: &[(&str, &str)] = &[
|
||||
"mark.refused.misread",
|
||||
"This would change how the text reads, so nothing changed",
|
||||
),
|
||||
("mark.edit.cut", "Cut"),
|
||||
("mark.edit.copy", "Copy"),
|
||||
("mark.edit.paste", "Paste"),
|
||||
("mark.edit.delete", "Delete Selected"),
|
||||
("mark.menu.copy_as", "Copy / Paste As"),
|
||||
("mark.menu.insert", "Insert"),
|
||||
("mark.copy.plain", "Copy as Plain Text"),
|
||||
("mark.copy.html", "Copy as HTML Code"),
|
||||
("mark.link.open", "Open Link"),
|
||||
("mark.link.copy", "Copy Link Address"),
|
||||
("mark.code.copy", "Copy Code Content"),
|
||||
("mark.image.location", "Open Image Location"),
|
||||
("mark.image.browser", "Open Image in Browser"),
|
||||
("mark.image.delete", "Delete Image"),
|
||||
(
|
||||
"mark.image.no_file",
|
||||
"This picture has no file here to show",
|
||||
),
|
||||
("mark.block.edit", "Edit"),
|
||||
("mark.block.delete", "Delete {block}"),
|
||||
("mark.insert.image", "Image"),
|
||||
("mark.insert.before", "Paragraph (before)"),
|
||||
("mark.insert.after", "Paragraph (after)"),
|
||||
("mark.kind.list", "List"),
|
||||
("mark.kind.alert", "Alert"),
|
||||
("mark.kind.html", "HTML Block"),
|
||||
("mark.refused.no_image", "Put the caret on a picture first"),
|
||||
];
|
||||
|
||||
pub(super) const ZH_CN: &[(&str, &str)] = &[
|
||||
@@ -136,4 +163,28 @@ pub(super) const ZH_CN: &[(&str, &str)] = &[
|
||||
("mark.refused.busy", "上一次编辑还在处理"),
|
||||
("mark.refused.changed", "编辑完成前文字已改变,请重试"),
|
||||
("mark.refused.misread", "这样会改变文字的读法,未作改动"),
|
||||
("mark.edit.cut", "剪切"),
|
||||
("mark.edit.copy", "复制"),
|
||||
("mark.edit.paste", "粘贴"),
|
||||
("mark.edit.delete", "删除所选范围"),
|
||||
("mark.menu.copy_as", "复制/粘贴为"),
|
||||
("mark.menu.insert", "插入"),
|
||||
("mark.copy.plain", "复制为纯文本"),
|
||||
("mark.copy.html", "复制为 HTML 代码"),
|
||||
("mark.link.open", "打开链接"),
|
||||
("mark.link.copy", "复制链接地址"),
|
||||
("mark.code.copy", "复制代码块内容"),
|
||||
("mark.image.location", "打开图片位置"),
|
||||
("mark.image.browser", "在浏览器中打开图片"),
|
||||
("mark.image.delete", "删除图片"),
|
||||
("mark.image.no_file", "这张图片在本机没有可显示的文件"),
|
||||
("mark.block.edit", "编辑"),
|
||||
("mark.block.delete", "删除 {block}"),
|
||||
("mark.insert.image", "图像"),
|
||||
("mark.insert.before", "段落(上方)"),
|
||||
("mark.insert.after", "段落(下方)"),
|
||||
("mark.kind.list", "列表"),
|
||||
("mark.kind.alert", "警告框"),
|
||||
("mark.kind.html", "HTML 内容"),
|
||||
("mark.refused.no_image", "请先把插入点放在图片上"),
|
||||
];
|
||||
+2
-1
@@ -20,7 +20,8 @@
|
||||
- 格式:Ctrl+B 加粗,Ctrl+I 斜体,Ctrl+U 下划线,Ctrl+Shift+` 代码,Alt+Shift+5 删除线,Ctrl+K 超链接,Ctrl+Shift+I 插入图片,Ctrl+\ 清除样式。
|
||||
- 表格在“段落 ▸ 表格”:Ctrl+T 插入,Ctrl+Enter 下方插入行,Ctrl+Shift+Backspace 删除行,Alt+方向键移动行列,“格式化表格源码”对齐各列。
|
||||
- 视图:Ctrl+/ 在源代码与可视之间切换,F8 专注,F9 打字机,Ctrl+Shift+= 放大,Ctrl+Shift+- 缩小,Ctrl+Shift+0 实际大小;可视、源码、预览在“视图”菜单里选。
|
||||
- 编辑:Ctrl+Shift+C 复制为 Markdown(无选区时复制全文),Ctrl+Shift+V 粘贴为纯文本。
|
||||
- 编辑:Ctrl+Shift+C 复制为 Markdown(无选区时复制全文),Ctrl+Shift+V 粘贴为纯文本;另有复制为纯文本、复制为 HTML 代码(图片保留原地址)、复制为富文本。
|
||||
- 右键菜单照 Typora,随所点之处变化:剪切、复制、粘贴、删除为一行图标;链接可打开、复制地址;图片可打开所在位置(网络图片在浏览器打开)、删除;代码块可复制其内容;公式与 HTML 块可编辑;加粗、斜体、代码、超链接与引用、列表各为一行图标;表格里为“表格 ▸”,别处为“段落 ▸”;“插入 ▸”;引用、列表、代码块等可整块删除。右键落在选区里时选区保留;正在编辑的块右键后仍开着。源码模式只有剪贴板与“复制/粘贴为”,预览只有复制。
|
||||
- 命令用不了时(如在代码里设标题、插入点不在表格里),提示写明原因,文字不动。macOS 上 Ctrl 为 Cmd。
|
||||
|
||||
## 恢复
|
||||
|
||||
@@ -36,7 +36,7 @@ fetch() { # name url rev [sparse paths...]
|
||||
echo "fetch $name $rev"
|
||||
}
|
||||
|
||||
fetch Ely-GPUI-Components https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components.git 6c2d28c56e9e3e3fe59272fe5da28efb0664ec3d
|
||||
fetch Ely-GPUI-Components https://git.zacharyzhang.com/ZacharyZhang-NY/Ely-GPUI-Components.git 1b5fb07cda3df9e96e17c2aceff187a70c67d28d
|
||||
fetch zed https://github.com/zed-industries/zed.git 1a28cff4b409169bac058bca40dfbfeb7621d19b
|
||||
fetch libreoffice-core https://github.com/LibreOffice/core.git 8221e31b3ac356a1623c672912a3d2b492f7e3d1 \
|
||||
include/LibreOfficeKit libreofficekit desktop/source/lib desktop/inc \
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@
|
||||
- [~] R4.8 组件库:表格行列上下左右移动、整理表格源码;代码块取代码内容;与已有的增删行列同一套拒绝。组件 bcee87c 至 6b033f3(已推送):`TableEdit` 加上下移行(表头与首行互换,超出表头列数的行不作表头,到边拒绝为 `TableRefusal::Edge`)、左右移列、整理;表格按显示宽度补齐(`unicode-width`,Tab 记 4、控制字符记 0,照 Typora 的 `wcswidth`),写回表格自身的换行;表格编辑并入后台执行器;右键代码块时 `DocumentTarget` 带出代码文字。审查三轮未过(`tasks/reviews/R4.8-r1..r3.md`):r1 两项(纯 CR 文本里整理表格把前文当作容器前缀、行内 Tab 宽度不合 Typora);r2 一项(End 后插入表格拆开 CRLF);r3 一项(r2 的修法让行辅助函数返回光标之前的位置,End 后的块命令崩溃)。r3 已修:编辑器只按 LF 分行,光标可落在 CR 与 LF 之间;执行器与插入表格在入口把选区移到 CR 前,行辅助函数改为断言不收这种位置;两项回归在 r3 的源码上失败(`.work/R4.8-fix3/red.md`);轮数用尽,未再审。遗留:编辑器自身的 CRLF 模型不变,End 仍落在 CR 之后;表情宽度按 `unicode-width` 记 2 列(Typora 记 1)
|
||||
- [x] R4.9 ElyMark:“段落”“格式”菜单与 Typora 同项同键(Ctrl+1–6、Ctrl+0、Ctrl+=/-、Ctrl+B/I/U、Ctrl+Shift+`、Alt+Shift+5、Ctrl+K、Ctrl+Shift+I、Ctrl+\、Ctrl+T、Ctrl+Shift+K/M/Q/[/]);源码模式 Ctrl+/;字号 Ctrl+Shift+=/-/0;专注 F8、打字机 F9;表格菜单加移动行列;复制为 Markdown Ctrl+Shift+C、粘贴为纯文本 Ctrl+Shift+V。ElyMark 5392062、f84f990、09fcb0b,组件 6d90351、24ffc45、6c2d28c(已推送),pin 6c2d28c:键与菜单项取自 Typora 字节码与其中文菜单;表格为“段落”子菜单,加删除表格;拒绝成提示;菜单借打开的块的焦点,块与选区留着;复制为 Markdown、粘贴为纯文本只作用于文档。R1 FAIL 六项、R2 FAIL 四项已修,R3 PASS
|
||||
- [ ] R4.10 ElyMark:右键菜单照 Typora 按目标变化:剪贴板行(剪切、复制、粘贴、删除)、复制/粘贴为 ▸(Markdown、HTML 代码、纯文本、粘贴为纯文本)、格式行、段落 ▸ 或表格 ▸ 或代码项、插入 ▸、链接(打开、复制地址)、图片(打开所在位置、删除图片)、删除块;预览只读时只留复制类
|
||||
- [ ] R4.11 验收:同一份样本在 ElyMark 与 Typora 的真窗口截图逐项对照;帮助、PRD、`agents.md` 随之;逐条核对表
|
||||
- [ ] R4.11 验收:真窗口逐项操作,每项功能可用(不求与 Typora 一一相同);帮助、PRD、`agents.md` 随之;逐条核对表
|
||||
|
||||
## R5 ElyDoc 照 Word 的右键与表格(用户 2026-10-13 报:右键没反应;表格不能加行列、不能调大小;三项方案经用户确认)
|
||||
|
||||
|
||||
Reference in new issue
Block a user