From 1dd0859bc43219bd7fd8c4718876fcd1afc38747 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Thu, 19 Nov 2026 11:49:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?docs(plugins):=20=E4=B8=8D=E5=86=99=20pan?= =?UTF-8?q?=20=E7=9A=84=E7=94=BB=E5=B8=83=E6=98=BE=E7=A4=BA=E6=95=B4?= =?UTF-8?q?=E4=B8=AA=20viewBox=EF=BC=8C=E8=A1=A5=E5=85=85=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=8C=BA=E5=9F=9F=E7=94=BB=E5=B8=83=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 画布原来只写“按视图宽度缩放、height 点高”,窗口变宽会裁掉场景下半部分。改为:不写 pan 时按宽度缩放但不超过 height、从左上角开始;写了 pan 时不变。schema 说明同步,domains/settings.md 补桌面端区域宽度,#105 移进更新记录时间线。 --- shared/plugins/contract/v1/README.md | 14 +++++++++++++- shared/plugins/contract/v1/plugin-ui.schema.json | 2 +- shared/plugins/reference/domains/settings.md | 2 ++ shared/plugins/reference/protocol-changelog.md | 8 +++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index f4a29e9c..bcf6c948 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -5241,12 +5241,24 @@ follows [source-backed settings](#source-backed-settings-editors). ``` A canvas draws its `nodes` in order, in `viewBox` coordinates -(`[x, y, width, height]`) scaled to the width of the view and `height` points +(`[x, y, width, height]`), in an area as wide as the view and `height` points tall (1–2000). `label` is the scene's accessible name. `pan` lets the user drag the empty area, and `zoom` is the `[minimum, maximum]` range around 1 (0.05–20); the host draws the zoom buttons. The scroll wheel scrolls the page; ⌘ or Ctrl with the wheel zooms, and so does a pinch on a host that reports one. +At zoom 1 the host scales the `viewBox` in one of two ways: + +- **Without `pan`**, the whole `viewBox` shows: it is scaled to the width of + the view, but no taller than `height`, and starts at the area's top-left + corner. A scene whose `viewBox` is as wide as the view is at its narrowest + and `height` tall therefore draws at one point a unit there, and keeps that + size, whole, in a wider view, with the area's trailing part left empty. In a + narrower view it shrinks to the width and leaves the area's bottom empty. +- **With `pan`**, the `viewBox`'s width fills the view and its top edge is at + the area's top; the user pans to the parts below the area. Zoomed out until + the `viewBox` is narrower than the area, it is centered across it. + | `type` | Fields | | --- | --- | | `rect` | `x`, `y`, `w`, `h`, `radius`, `fill`, `stroke`, `width`, `dash`, `shadow`, `opacity` | diff --git a/shared/plugins/contract/v1/plugin-ui.schema.json b/shared/plugins/contract/v1/plugin-ui.schema.json index ce1bd7e6..6da940a1 100644 --- a/shared/plugins/contract/v1/plugin-ui.schema.json +++ b/shared/plugins/contract/v1/plugin-ui.schema.json @@ -341,7 +341,7 @@ } }, "canvas": { - "description": "A vector scene the host draws natively in view-box coordinates, scaled to the view width. Pan, zoom, hover states and tooltips stay in the host; viewport sends viewport events after the user pans or zooms. Canvas text is not searchable; a settings region names its words in keywords.", + "description": "A vector scene the host draws natively in view-box coordinates, in an area as wide as the view and height points tall. Without pan, the whole view box shows at zoom 1, scaled to the view width but no taller than height, from the top-left corner; with pan, its width fills the view. Pan, zoom, hover states and tooltips stay in the host; viewport sends viewport events after the user pans or zooms. Canvas text is not searchable; a settings region names its words in keywords.", "type": "object", "additionalProperties": false, "required": ["type", "id", "label", "height", "viewBox", "nodes"], diff --git a/shared/plugins/reference/domains/settings.md b/shared/plugins/reference/domains/settings.md index 3b802b7a..f45d1b9c 100644 --- a/shared/plugins/reference/domains/settings.md +++ b/shared/plugins/reference/domains/settings.md @@ -86,6 +86,7 @@ - `keywords`:1–32 个,忽略大小写互不相同,每个 1–64 个字符、不换行、首尾没有空白。设置搜索除了页面标题和声明的行,也按这些词找到页面,并打开到这个插件的部分。 - `view`:`{function}`,插件后端的视图函数,画在页面标题和插件声明的行之间。视图可以放宿主控件、画布,也可以用绑定控件编辑本插件的设置(和声明的行改的是同一份草稿)、放本插件按钮和显示本插件工具解析结果的工具行,但不能放树。需要 `backend`、`ui` 0 和 `ui.contribute` 权限;页面打开时宿主启动后端。 - 只写关键词的区域不需要后端。区域本身不保存任何值。声明区域也算使用了 `settings`。 +- 区域里的画布通常不写 `pan`:这时宿主按[画布](../../contract/v1/README.md#plugin-views)的规则显示整个 `viewBox`,所以把 `viewBox` 的宽度设成区域最窄时的宽度、高度设成 `height`,场景在那里就是一个单位一个点,窗口变宽时大小不变、完整显示。桌面端窗口最小时,语言页的区域约 610 点宽,构建系统页和编译器页右侧详情里的区域约 340 点宽。 ### 两层保存与生效顺序 @@ -238,6 +239,7 @@ Content that declared rows cannot draw goes in `settingRegions` (at most 16, uni - `keywords`: 1–32, distinct ignoring case, each 1–64 characters without line breaks or surrounding spaces. Settings search finds the page by them in addition to the page title and the declared rows, and opens the page at this plugin's part. - `view`: `{function}`, a view function of the plugin's backend, drawn between the page header and the plugin's declared rows. The view may hold host controls and canvases, edit the plugin's own settings through bound controls (the same draft the declared rows edit), show the plugin's buttons and tool rows with how its tools resolve, but no tree. It needs `backend`, `ui` 0, and the `ui.contribute` permission; the host starts the backend when the page opens. - A region with keywords only needs no backend. A region stores no values. Declaring regions counts as using `settings`. +- A canvas in a region usually has no `pan`, so the host shows its whole `viewBox` (see [canvas](../../contract/v1/README.md#plugin-views)): give the `viewBox` the region's narrowest width and `height`, and the scene draws at one point a unit there and keeps that size, whole, as the window widens. In Lithe desktop's smallest window a region is about 610 points wide on a language page and about 340 in the detail pane of a build system or compiler page. ### Two layers and their order diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index a26d52c9..fa653222 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,7 +14,7 @@ ## 待合入 -- `ui` 0、`settings` 0 内的说明补充(API-13、API-19):契约 README 写明画布 `image` 节点怎样读取:路径留在插件包内、经过真实目录、指向普通 PNG 文件,单个文件最多 256 KiB、每边最多 1024 像素(预算表新增一行);宿主在场景第一次画到它时于窗口线程外读取,保留到视图关闭,读到之前或读取失败时场景不画它,失败只记一次日志。`image` 节点的字段表补上 `opacity`。文字是一行,基线在 `y`,`align` 把行首(默认)、中点或行尾放在 `x`;渐变 `angle` 与 CSS `linear-gradient` 一致(0 向上、90 向右、默认 180 向下),渐变线穿过形状中心;分组的 `x`、`y` 放置原点,`scale` 缩放内部,`children`、`w`、`h`、`radius` 都在分组自己的坐标里;捏合缩放只在宿主能上报捏合时可用。fixture `fixtures/ui/view-results.json` 的文字基线移到卡片中间。[能力与协议版本对照](capabilities-and-versions.md)删掉“插件视图尚未在桌面端绘制”的脚注,`domains/ui.md`、`domains/settings.md` 的桌面端一行改为已呈现插件视图、设置区域和包内翻译 `l10n/`([1lck/Lithe-IDEA#2181](https://github.com/1lck/Lithe-IDEA/issues/2181))。没有新增版本号、宿主方法、通知或 SDK 版本。实现见 [#105](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/105)。 +- `ui` 0 内的说明修正(API-13、API-19):契约 README 写明画布在缩放 1 时怎样放 `viewBox`。不写 `pan` 的画布显示整个 `viewBox`:按视图宽度缩放,但不超过 `height`,从区域左上角开始,所以 `viewBox` 和视图最窄时一样宽、和 `height` 一样高的场景在那里一个单位一个点,视图变宽时大小不变、完整显示,右边留空;视图更窄时按宽度缩小,下方留空。写了 `pan` 的画布不变:`viewBox` 的宽度占满视图、上边对齐区域顶部,缩小到比区域窄时水平居中。以前的说明只有“按视图宽度缩放、`height` 点高”,在更宽的窗口里会裁掉场景下半部分。`plugin-ui.schema.json` 的 canvas 说明同步;`domains/settings.md` 中英两段补充区域画布的设计宽度:桌面端窗口最小时语言页的区域约 610 点,构建系统页和编译器页右侧详情里约 340 点([1lck/Lithe-IDEA#2181](https://github.com/1lck/Lithe-IDEA/issues/2181))。没有新增版本号、宿主方法、通知或 SDK 版本。 ## 按协议查首次出现 @@ -144,6 +144,12 @@ ## 时间线(新的在上) +### 2026-11-19 + +| PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 | +| --- | --- | --- | --- | --- | +| [#105](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/105) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-13、API-19 | `ui` 0、`settings` 0 内的说明补充 | 契约 README 写明画布 `image` 节点怎样读取:路径留在插件包内、经过真实目录、指向普通 PNG 文件,单个文件最多 256 KiB、每边最多 1024 像素(预算表新增一行);宿主在场景第一次画到它时于窗口线程外读取,保留到视图关闭,读到之前或读取失败时场景不画它,失败只记一次日志。`image` 节点的字段表补上 `opacity`。文字是一行,基线在 `y`,`align` 把行首(默认)、中点或行尾放在 `x`;渐变 `angle` 与 CSS `linear-gradient` 一致(0 向上、90 向右、默认 180 向下),渐变线穿过形状中心;分组的 `x`、`y` 放置原点,`scale` 缩放内部,`children`、`w`、`h`、`radius` 都在分组自己的坐标里;捏合缩放只在宿主能上报捏合时可用。fixture `fixtures/ui/view-results.json` 的文字基线移到卡片中间。[能力与协议版本对照](capabilities-and-versions.md)删掉“插件视图尚未在桌面端绘制”的脚注,`domains/ui.md`、`domains/settings.md` 的桌面端一行改为已呈现插件视图、设置区域和包内翻译 `l10n/`([1lck/Lithe-IDEA#2181](https://github.com/1lck/Lithe-IDEA/issues/2181))。没有新增版本号、宿主方法、通知或 SDK 版本。 | + ### 2026-11-18 | PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 | From 9aab486aa87258197eaf04d40ce3404b2685d471 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Thu, 19 Nov 2026 11:49:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs(plugins):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E5=BE=85=E5=90=88=E5=85=A5=E6=9D=A1?= =?UTF-8?q?=E7=9B=AE=E9=93=BE=E6=8E=A5=20#107?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/plugins/reference/protocol-changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index fa653222..a21ca62a 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,7 +14,7 @@ ## 待合入 -- `ui` 0 内的说明修正(API-13、API-19):契约 README 写明画布在缩放 1 时怎样放 `viewBox`。不写 `pan` 的画布显示整个 `viewBox`:按视图宽度缩放,但不超过 `height`,从区域左上角开始,所以 `viewBox` 和视图最窄时一样宽、和 `height` 一样高的场景在那里一个单位一个点,视图变宽时大小不变、完整显示,右边留空;视图更窄时按宽度缩小,下方留空。写了 `pan` 的画布不变:`viewBox` 的宽度占满视图、上边对齐区域顶部,缩小到比区域窄时水平居中。以前的说明只有“按视图宽度缩放、`height` 点高”,在更宽的窗口里会裁掉场景下半部分。`plugin-ui.schema.json` 的 canvas 说明同步;`domains/settings.md` 中英两段补充区域画布的设计宽度:桌面端窗口最小时语言页的区域约 610 点,构建系统页和编译器页右侧详情里约 340 点([1lck/Lithe-IDEA#2181](https://github.com/1lck/Lithe-IDEA/issues/2181))。没有新增版本号、宿主方法、通知或 SDK 版本。 +- `ui` 0 内的说明修正(API-13、API-19):契约 README 写明画布在缩放 1 时怎样放 `viewBox`。不写 `pan` 的画布显示整个 `viewBox`:按视图宽度缩放,但不超过 `height`,从区域左上角开始,所以 `viewBox` 和视图最窄时一样宽、和 `height` 一样高的场景在那里一个单位一个点,视图变宽时大小不变、完整显示,右边留空;视图更窄时按宽度缩小,下方留空。写了 `pan` 的画布不变:`viewBox` 的宽度占满视图、上边对齐区域顶部,缩小到比区域窄时水平居中。以前的说明只有“按视图宽度缩放、`height` 点高”,在更宽的窗口里会裁掉场景下半部分。`plugin-ui.schema.json` 的 canvas 说明同步;`domains/settings.md` 中英两段补充区域画布的设计宽度:桌面端窗口最小时语言页的区域约 610 点,构建系统页和编译器页右侧详情里约 340 点([1lck/Lithe-IDEA#2181](https://github.com/1lck/Lithe-IDEA/issues/2181))。没有新增版本号、宿主方法、通知或 SDK 版本。实现见 [#107](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/107)。 ## 按协议查首次出现