跳到主要内容

Sample 合同 · AUP 跨设备 · ARC 2.0.0-beta.28

`editor` primitive

editor 可在 document 上渲染为本地 textarea;不要承诺可写 IDE 或 AFS 回写。

editor 是 AUP 跨设备 primitive,不是 Web Device 的 layout 组件,也不是 Web-only widget。它属于 AUP_PRIMITIVES 中的 18 个名称之一,并出现在每个 target 的 DeviceCaps.primitives map 中(取值为 native、webview、partial 或 unsupported)。

合同

字段值
Primitive 名称editor
层级AUP 跨设备 primitive(AUP_PRIMITIVES)
公共状态experimental
Document 能力native(renderer 存在;公开 sample 仅本地)
共享 degradation chaineditor → input → text(unsupported 时)
作者入口AUP tree / DSL · 通用 Markdown ::editor{…}
Document renderer / 备注renderer/primitives/editor.ts(textarea;仅当 AUP props 中布尔 true 时 readOnly)
Showcase 证据使用 editor 节点的组合页

何时使用

在实现了 editor 的 target 上需要代码或长文编辑面时。

何时不要使用

不要从 docs 页承诺协作编辑、LSP、多人编辑或回写。

Sample 合同

字段值
目的诚实的 document-target editor 控件(仅本地 textarea)
边界无 LSP、无多人、无 AFS 写入、无 IDE 产品承诺
作者入口::editor{…} 通用指令
表面Web Device document
公共状态experimental
Fallback / 失败unsupported 时:chain 到 input → text;空 value → 空 textarea
验证下方路由 · arc --version = 2.0.0-beta.28

Document sample(本地 textarea)

document 注册了 editor renderer。下方 sample 是未绑定控件:输入只改变浏览器 textarea。Markdown 属性是字符串——不要假定 MD 的 readOnly=true 会像 AUP JSON 那样设置布尔 true。需要严格只读 props 时优先 AUP JSON/DSL。

源码:

markdown
::editor{id="docs-prim-editor" language="json" label="Example snippet" value="{ \"ok\": true }"}

渲染:

::editor{id="docs-prim-editor" language="json" label="Example snippet" value="{ "ok": true }"}

AUP JSON 形状(需要布尔 readOnly 时):

json
{
  "id": "snippet",
  "type": "editor",
  "props": {
    "label": "Example",
    "language": "json",
    "readOnly": true,
    "value": "{ \"ok\": true }\n"
  }
}

失败与限制

情形预期结果
在 document sample 中输入仅本地浏览器状态;无文档/AFS 写入
期望 LSP / 多人超出合同
unsupported target经 editor → input → text 降级
MD readOnly="true" 字符串不保证等于 AUP 布尔 true

验证证据

项值
基线2026-08-09 · arc --version → 2.0.0-beta.28
能力行docs/aup/capability-matrix.md(内部,不对外路由)· editor
实现renderer/primitives/editor.ts;caps device-caps.ts;chain degradation.ts
公开路由/en/docs/aup/primitives/editor/ · /zh/docs/aup/primitives/editor/
本地运行arc service start --blocklet blocklets/arcblock --port 4900 · 打开路由;输入保持本地
接受标准textarea 带种子值渲染;无网络写入;experimental 状态可见

证据锚点

项值
注册表packages/aup/src/aup-types.ts · AUP_PRIMITIVES
Document capsproviders/runtime/web-device/src/device-caps.ts · DEVICE_CAPS_DOCUMENT
Degradationpackages/aup/src/degradation.ts · DEGRADATION_CHAINS
内部矩阵docs/aup/capability-matrix.md(内部,不对外路由)
Taxonomy hubPrimitive 类型分类与证据
Sample 合同规则Live 示例:范围与合同

相关页面