@xiongtao.xt/tau-plugins 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/client/{chunk-D4PV3N7Q.js → chunk-PZ6FG7OR.js} +124 -18
  3. package/docs/README.md +2 -2
  4. package/docs/api-support.md +14 -11
  5. package/docs/editor.md +2 -2
  6. package/docs/getting-started.md +5 -5
  7. package/docs/plugin-basics.md +8 -9
  8. package/docs/portability.md +75 -39
  9. package/docs/release.md +1 -1
  10. package/docs/ui.md +1 -1
  11. package/package.json +1 -1
  12. package/portable.js +7 -1
  13. package/publish-artifacts.js +63 -3
  14. package/types/packages/editor/src/core/api/index.d.ts +3 -1
  15. package/types/packages/editor/src/core/components/EditorContextMenu/types.d.ts +35 -0
  16. package/types/packages/editor/src/core/components/ExtensionLayers/index.d.ts +17 -0
  17. package/types/packages/editor/src/core/hooks/useDragHandlerMenu.d.ts +39 -0
  18. package/types/packages/editor/src/core/kit/EditorKit.d.ts +39 -0
  19. package/types/packages/editor/src/core/kit/ExtensionAssembly.d.ts +81 -0
  20. package/types/packages/editor/src/core/kit/context.d.ts +21 -0
  21. package/types/packages/editor/src/core/menu/resolveMenu.d.ts +19 -0
  22. package/types/packages/editor/src/core/utils/nodeOperations.d.ts +2 -2
  23. package/types/packages/plugins/src/capabilities.d.ts +3 -3
  24. package/types/packages/plugins/src/environment.d.ts +7 -10
  25. package/types/packages/plugins/src/index.d.ts +0 -2
  26. package/types/packages/plugins/src/portable.d.ts +33 -1
  27. package/types/packages/plugins/src/publish-artifacts.d.ts +8 -3
  28. package/types/packages/plugins/src/render-artifact.d.ts +2 -1
  29. package/types/packages/plugins/src/rendering.d.ts +78 -0
  30. package/types/packages/themes/src/themes/paper.theme.d.ts +1 -1
  31. package/types/packages/ui/src/primitives/Tabs.d.ts +3 -1
package/portable.js CHANGED
@@ -1,20 +1,26 @@
1
1
  import {
2
+ PLUGIN_BASE_REQUIREMENTS,
2
3
  PORTABLE_PLATFORMS,
3
4
  PORTABLE_SHARED_MODULES,
4
5
  assertPortableElementDeclarations,
5
6
  assertPortablePluginCompatibility,
7
+ buildPortablePluginManifest,
6
8
  getPortableElementSupport,
9
+ isPluginCapability,
7
10
  readPortablePluginManifest,
8
11
  validatePortableDistributionManifest,
9
12
  validatePortablePluginManifest
10
- } from "./client/chunk-D4PV3N7Q.js";
13
+ } from "./client/chunk-PZ6FG7OR.js";
11
14
  import "./client/chunk-FZTR4KOY.js";
12
15
  export {
16
+ PLUGIN_BASE_REQUIREMENTS,
13
17
  PORTABLE_PLATFORMS,
14
18
  PORTABLE_SHARED_MODULES,
15
19
  assertPortableElementDeclarations,
16
20
  assertPortablePluginCompatibility,
21
+ buildPortablePluginManifest,
17
22
  getPortableElementSupport,
23
+ isPluginCapability,
18
24
  readPortablePluginManifest,
19
25
  validatePortableDistributionManifest,
20
26
  validatePortablePluginManifest
@@ -1,4 +1,9 @@
1
- import "./client/chunk-D4PV3N7Q.js";
1
+ import {
2
+ PORTABLE_SHARED_MODULES,
3
+ assertPortableElementDeclarations,
4
+ getPortableElementSupport,
5
+ readPortablePluginManifest
6
+ } from "./client/chunk-PZ6FG7OR.js";
2
7
  import {
3
8
  PLUGIN_SHARED_MODULES,
4
9
  validatePluginManifest
@@ -63,10 +68,65 @@ function assertPluginEditorExtension(extension) {
63
68
 
64
69
  // packages/plugins/src/rendering.ts
65
70
  var PLUGIN_RENDER_VERSION = 1;
71
+ function readPublishedPluginManifest(value) {
72
+ return value?.formatVersion === 3 ? readPortablePluginManifest(value) : validatePluginManifest(value);
73
+ }
74
+ function evaluatePublishedPluginPackage(artifact, modules) {
75
+ const manifest = readPublishedPluginManifest(artifact.manifest);
76
+ if (manifest.formatVersion !== 3)
77
+ return evaluatePluginPackage({ ...artifact, manifest }, modules);
78
+ if (!manifest.editor || !manifest.targets.desktop) throw new Error("\u535A\u5BA2\u6E32\u67D3\u9700\u8981\u684C\u9762\u7F16\u8F91\u5668\u8D21\u732E");
79
+ const definition = evaluateModule(manifest, artifact.code, modules, PORTABLE_SHARED_MODULES);
80
+ assertPortableElementDeclarations(manifest, getPluginNodeTypes(definition));
81
+ return adaptPortablePluginDefinition(definition, manifest, "desktop").definition;
82
+ }
66
83
  function evaluatePluginPackage(artifact, modules) {
67
84
  const manifest = validatePluginManifest(artifact.manifest);
68
85
  return evaluateModule(manifest, artifact.code, modules, PLUGIN_SHARED_MODULES);
69
86
  }
87
+ function adaptPortablePluginDefinition(definition, manifest, platform) {
88
+ const support = Object.freeze(
89
+ Object.fromEntries(
90
+ getPluginNodeTypes(definition).map((type) => [
91
+ type,
92
+ getPortableElementSupport(manifest, platform, type)
93
+ ])
94
+ )
95
+ );
96
+ const extensions = definition.editorExtensions?.flatMap((extension) => {
97
+ const elements = extension.elements?.filter((element) => support[element.type] !== "none").map(
98
+ (element) => support[element.type] === "edit" ? element : { ...element, behaviors: void 0 }
99
+ );
100
+ if (!elements?.length) return [];
101
+ const types = new Set(elements.map((element) => element.type));
102
+ const editable = elements.every((element) => support[element.type] === "edit");
103
+ return [
104
+ {
105
+ ...extension,
106
+ elements,
107
+ styleSources: extension.styleSources?.filter((source) => types.has(source.type)),
108
+ htmlSerializers: extension.htmlSerializers?.filter(
109
+ (serializer) => types.has(serializer.type)
110
+ ),
111
+ ...editable ? {} : {
112
+ blockPanel: void 0,
113
+ commands: void 0,
114
+ hotkeys: void 0,
115
+ menu: void 0,
116
+ behaviorsFor: void 0
117
+ }
118
+ }
119
+ ];
120
+ });
121
+ return {
122
+ support,
123
+ definition: {
124
+ ...definition,
125
+ editorExtensions: extensions?.length ? extensions : void 0,
126
+ editorCodecs: definition.editorCodecs?.filter((codec) => support[codec.type] !== "none")
127
+ }
128
+ };
129
+ }
70
130
  function evaluateModule(manifest, code, modules, allowed) {
71
131
  const module = { exports: {} };
72
132
  new Function(
@@ -163,7 +223,7 @@ function assertRenderTypes(definition, expected) {
163
223
  // packages/plugins/src/publish-artifacts.ts
164
224
  var PLUGIN_RENDER_VERSION2 = PLUGIN_RENDER_VERSION;
165
225
  function evaluatePluginPackage2(artifact, modules) {
166
- return evaluatePluginPackage(artifact, modules);
226
+ return evaluatePublishedPluginPackage(artifact, modules);
167
227
  }
168
228
  function assertRenderTypes2(definition, types) {
169
229
  assertRenderTypes(definition, types);
@@ -173,5 +233,5 @@ export {
173
233
  PLUGIN_SHARED_MODULES,
174
234
  assertRenderTypes2 as assertRenderTypes,
175
235
  evaluatePluginPackage2 as evaluatePluginPackage,
176
- validatePluginManifest
236
+ readPublishedPluginManifest as validatePluginManifest
177
237
  };
@@ -35,13 +35,15 @@ export { default as InlineChromiumBugfix } from "../components/InlineChromiumBug
35
35
  export { default as useIsLastElement } from "../hooks/useIsLastElement";
36
36
  export { registerBlockNavigation, hasBlockNavigation, unregisterBlockNavigation, focusPreviousBlock, focusNextBlock, type BlockNavigationHandler, } from "../utils/blockNavigation";
37
37
  export { isCollapsed, getCurrentTextNode } from "../utils/editor";
38
- export { deleteVoidBlock } from "../utils/nodeOperations";
38
+ export { copyNodeToClipboard, deleteVoidBlock } from "../utils/nodeOperations";
39
39
  export { getSelectionSnapshot, isSelectionSnapshotUnchanged } from "../utils/selectionSnapshot";
40
40
  export { createParagraph, isParagraphElement, type ParagraphElement } from "../model/paragraph";
41
41
  export { insertParagraphAndFocus } from "../utils/editor";
42
42
  export { isAtParagraphStart, isParagraphAndEmpty } from "../utils/editor";
43
43
  export { isNodeEmpty } from "../kit/elementEmpty";
44
44
  export { createBlockConversionMenu } from "../menu/conversion";
45
+ export { resolveElementMenu } from "../hooks/useDragHandlerMenu";
46
+ export type { ContextMenuItem } from "../components/EditorContextMenu/types";
45
47
  export { getCommandElementPath } from "../utils/commandTarget";
46
48
  export { captureEditorSubmission, captureElementSubmission, captureInsertionSubmission, type Submission, type SubmissionOutcome, type SubmissionDiscardReason, } from "./submission";
47
49
  export { default as AddParagraph, type AddParagraphRef } from "../components/AddParagraph/index";
@@ -0,0 +1,35 @@
1
+ import { ReactNode } from "react";
2
+ import { Editor, Path, Element } from "slate";
3
+ export interface ContextMenuItem {
4
+ key: string;
5
+ label: string;
6
+ icon?: ReactNode;
7
+ danger?: boolean;
8
+ disabled?: boolean;
9
+ children?: ContextMenuItem[];
10
+ onSelect?: () => void;
11
+ /** 该条目上方画一条组分隔线(由菜单聚合器在组边界标记) */
12
+ separator?: boolean;
13
+ /** 贡献该条目的扩展 id(MenuContributionSource.owner);合并子项的父项取首个来源 */
14
+ owner?: string;
15
+ }
16
+ export interface EditorContextMenuProps {
17
+ readonly?: boolean;
18
+ visible: boolean;
19
+ position: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ items: ContextMenuItem[];
24
+ onClose: () => void;
25
+ }
26
+ export interface BuildMenuParams<T extends Element> {
27
+ element: T;
28
+ editor: Editor;
29
+ path: Path;
30
+ }
31
+ export interface UseDragHandlerMenuOptions<T extends Element> {
32
+ element: T;
33
+ editor: Editor;
34
+ buildMenuItems: (params: BuildMenuParams<T>) => ContextMenuItem[];
35
+ }
@@ -0,0 +1,17 @@
1
+ import { type ComponentType } from "react";
2
+ import type { ExtensionLayerProps } from "../../api/extension";
3
+ export interface RegisteredLayer {
4
+ readonly owner: string;
5
+ readonly component: ComponentType<ExtensionLayerProps>;
6
+ }
7
+ interface Props {
8
+ layer: RegisteredLayer;
9
+ readOnly: boolean;
10
+ report: (owner: string, error: unknown) => void;
11
+ }
12
+ export default function ExtensionLayers({ layers, report, readOnly, }: {
13
+ layers: readonly RegisteredLayer[];
14
+ report: Props["report"];
15
+ readOnly: boolean;
16
+ }): import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,39 @@
1
+ import { Editor, Element, Path } from "slate";
2
+ import { ContextMenuItem } from "../components/EditorContextMenu/types";
3
+ import { useInheritedKit } from "../kit/context";
4
+ type Kit = ReturnType<typeof useInheritedKit>;
5
+ /** 按 kit 聚合的扩展菜单声明对目标元素求值(手柄菜单与媒体属性条「更多」共用) */
6
+ export declare function resolveElementMenu<T extends Element>(kit: Kit, editor: Editor, element: T, extraItems?: (params: {
7
+ element: T;
8
+ editor: Editor;
9
+ path: Path;
10
+ }) => ContextMenuItem[]): ContextMenuItem[];
11
+ export interface UseDragHandlerMenuOptions<T extends Element> {
12
+ element: T;
13
+ editor: Editor;
14
+ /** 过渡:宿主/组件补充的旧形态条目(extraMenuItemsBuilder),打开菜单时求值、追加在末尾 */
15
+ extraItems?: (params: {
16
+ element: T;
17
+ editor: Editor;
18
+ path: Path;
19
+ }) => ContextMenuItem[];
20
+ }
21
+ /**
22
+ * 手柄点击菜单:数据来自 kit 聚合的扩展菜单声明(01 §5.4),
23
+ * 打开时对目标元素求值一次(when / disabled / 动态标题都是那一刻的快照)。
24
+ */
25
+ export declare function useDragHandlerMenu<T extends Element>(options: UseDragHandlerMenuOptions<T>): {
26
+ menuProps: {
27
+ visible: boolean;
28
+ position: {
29
+ x: number;
30
+ y: number;
31
+ };
32
+ items: ContextMenuItem[];
33
+ onClose: () => void;
34
+ };
35
+ dragHandlerProps: {
36
+ onClick: (e: React.MouseEvent) => void;
37
+ };
38
+ };
39
+ export {};
@@ -0,0 +1,39 @@
1
+ import { type AnyExtension } from "../api/legacy";
2
+ import type { EditorExtension } from "../api/extension";
3
+ import type { ServiceRegistration, ServiceRegistry } from "../services/registry";
4
+ import type { ThemeService } from "../theme/ThemeService";
5
+ import { ExtensionAssembly } from "./ExtensionAssembly";
6
+ /**
7
+ * EditorKit:宿主显式声明「这个编辑器由什么组成」(docs/editor-refactor ER-004)。
8
+ *
9
+ * 一个 kit 创建一次、可给多个编辑器复用:扩展的插件、快捷键、工具条条目与 type 分发表
10
+ * 在 kit 上预计算并缓存。需要个别差异时用 `kit.extend()` 派生,不做隐式合并。
11
+ */
12
+ export interface EditorKit {
13
+ readonly registry: ServiceRegistry;
14
+ readonly extensions: readonly EditorExtension[];
15
+ /** 本 kit 能渲染的元素类型;跨端覆盖测试(CONTENT_ELEMENT_TYPES)按它断言 */
16
+ readonly elementTypes: readonly string[];
17
+ /** 内部用:扩展的预计算结果(插件、快捷键、工具条、type 分发表) */
18
+ readonly assembly: ExtensionAssembly;
19
+ /** 派生:追加扩展或覆盖服务;同 type 扩展需显式 override */
20
+ extend(options: EditorKitExtendOptions): EditorKit;
21
+ }
22
+ export interface EditorKitOptions {
23
+ /** 元素与功能扩展;同元素类型重复会报错,除非 `override: true` */
24
+ extensions?: readonly AnyExtension[];
25
+ /** 平台能力与 UI 插槽 */
26
+ services?: ServiceRegistration[];
27
+ /** 主题服务;等价于注册 IThemeService,缺省时编辑器读 DOM */
28
+ theme?: ThemeService;
29
+ /** 允许后来的扩展按 type 覆盖先前的功能扩展;核心段落不可替换。 */
30
+ override?: boolean;
31
+ }
32
+ export interface EditorKitExtendOptions {
33
+ extensions?: readonly AnyExtension[];
34
+ services?: ServiceRegistration[];
35
+ theme?: ThemeService;
36
+ override?: boolean;
37
+ }
38
+ /** 核心只提供基础段落,产品功能由调用方显式选择。 */
39
+ export declare function createEditorKit(options?: EditorKitOptions): EditorKit;
@@ -0,0 +1,81 @@
1
+ import { type ReactElement } from "react";
2
+ import type { ContentResourceDeclarations } from "../../../../db-schema/content-resources";
3
+ import type { Editor } from "slate";
4
+ import type { RenderElementProps } from "slate-react";
5
+ import type { EditorExtension, ElementBehaviors } from "../api/extension";
6
+ import { CommandRegistry, type EditorHotkey } from "../api/command";
7
+ import { type ElementDragSpec } from "../api/drag";
8
+ import type { ElementIngestSpec } from "../api/ingest";
9
+ import type { MenuContributionSource } from "../menu/resolveMenu";
10
+ import { type AnyExtension } from "../api/legacy";
11
+ import type { Plugin } from "../utils/plugin";
12
+ import type { IBlockPanelListItem, IConfigItem } from "../types";
13
+ import type { RegisteredCopy } from "../api/copy";
14
+ import type { RegisteredDecoration, RegisteredMark } from "../api/marks";
15
+ import type { RegisteredInputRule } from "../api/inputRules";
16
+ import type { RegisteredLayer } from "../components/ExtensionLayers/index";
17
+ /** 一个扩展贡献的插件:内核按扩展逐组应用,出错隔离到组(extensionGuard.ts) */
18
+ export interface ExtensionPluginGroup {
19
+ /** 扩展 id,熔断与上报按它计 */
20
+ readonly type: string;
21
+ readonly plugins: readonly Plugin[];
22
+ }
23
+ /** 某元素类型上的一组声明式行为及其来源扩展,由内核的行为分发器调用(extensionGuard.ts) */
24
+ export interface ElementBehaviorEntry {
25
+ readonly extension: string;
26
+ readonly behaviors: ElementBehaviors;
27
+ }
28
+ /** 一个扩展的内容注入声明;owner 用于隔离熔断与日志 */
29
+ export interface IngestSource {
30
+ readonly owner: string;
31
+ readonly files?: ElementIngestSpec["files"];
32
+ readonly text?: ElementIngestSpec["text"];
33
+ }
34
+ /**
35
+ * 扩展的预计算结果:插件链、快捷键、悬浮工具条条目与 type → 渲染的分发表。
36
+ *
37
+ * 一个 kit 一份(取代原先每个编辑器一个 PluginOptimizer):同一个 kit 的多个编辑器共享,
38
+ * 不必每次挂载都重新收集。扩展集合由 kit 在创建时定好,所以这里只算一次,无需缓存淘汰。
39
+ */
40
+ /** v2 热键声明及其来源扩展;执行经命令注册表,熔断按命令的 owner */
41
+ export interface CommandHotkeyEntry {
42
+ readonly hotkey: EditorHotkey;
43
+ readonly owner: string;
44
+ }
45
+ export declare class ExtensionAssembly {
46
+ readonly extensions: readonly EditorExtension[];
47
+ readonly plugins: readonly Plugin[];
48
+ readonly pluginGroups: readonly ExtensionPluginGroup[];
49
+ /** v2 命令热键(绑命令 id) */
50
+ readonly commandHotkeys: readonly CommandHotkeyEntry[];
51
+ readonly commands: CommandRegistry;
52
+ readonly hoveringBarElements: readonly IConfigItem[];
53
+ /** 手柄/右键菜单的贡献来源(按扩展顺序);求值在打开菜单时进行 */
54
+ readonly menuSources: readonly MenuContributionSource[];
55
+ /** 元素类型 → 拖拽声明;未收录的类型没有拖拽 chrome(BlockDragHost 查询) */
56
+ readonly dragSpecs: ReadonlyMap<string, ElementDragSpec>;
57
+ /** 内容注入声明(drop/paste 认领管线);相同 accept 重复声明在构造时抛错 */
58
+ readonly ingestSources: readonly IngestSource[];
59
+ /** 本装配能渲染的元素类型(按扩展顺序) */
60
+ readonly elementTypes: readonly string[];
61
+ /** 元素类型 → 资源字段声明 */
62
+ readonly resources: ContentResourceDeclarations;
63
+ /** 元素类型 → 行为列表:该类型自己的在前,其他扩展经 behaviorsFor 挂上来的按扩展顺序在后 */
64
+ readonly behaviors: ReadonlyMap<string, readonly ElementBehaviorEntry[]>;
65
+ readonly copyPolicies: ReadonlyMap<string, RegisteredCopy>;
66
+ readonly marks: readonly RegisteredMark[];
67
+ readonly decorations: readonly RegisteredDecoration[];
68
+ readonly inputRules: readonly RegisteredInputRule[];
69
+ readonly layers: readonly RegisteredLayer[];
70
+ private readonly renderers;
71
+ private readonly owners;
72
+ constructor(extensions: readonly AnyExtension[]);
73
+ /** 先把一个扩展的全部贡献收齐,中途抛错则整个扩展都不装,不留半截 */
74
+ private collect;
75
+ hasElement(type: string): boolean;
76
+ render(props: RenderElementProps): ReactElement | undefined;
77
+ /** 元素类型归哪个扩展(上报与熔断按扩展 id) */
78
+ getElementOwner(type: string): EditorExtension | undefined;
79
+ /** 块菜单条目:每次打开菜单求值;单个扩展出错只丢它自己的条目 */
80
+ getBlockPanelItems(editor: Editor): IBlockPanelListItem[];
81
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react";
2
+ import type { AnyExtension } from "../api/legacy";
3
+ import type { EditorKit } from "./EditorKit";
4
+ /** 内核用:把本编辑器的 kit 传给子树(含嵌套编辑器与扩展组件) */
5
+ export declare function EditorKitScope({ kit, children }: {
6
+ kit: EditorKit;
7
+ children: ReactNode;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ /** 继承外层编辑器的 kit;没有外层则为 null */
10
+ export declare function useInheritedKit(): EditorKit | null;
11
+ /**
12
+ * 解析本编辑器最终使用的 kit:显式传入 > 继承外层。
13
+ * 需要 per-instance 扩展时在此派生,同一组输入返回同一个 kit 实例(否则编辑器会重建)。
14
+ */
15
+ export declare function useResolvedKit(explicit: EditorKit | undefined): EditorKit;
16
+ /**
17
+ * 在 kit 基础上叠加单个编辑器的扩展;无扩展时返回原 kit。
18
+ * per-instance 扩展按 type 覆盖 kit 的同名实现(沿用迁移前的 later-wins 语义),
19
+ * 相同扩展实例返回同一个派生 kit(kit.extend 内部按实例集合缓存),编辑器不会因此重建。
20
+ */
21
+ export declare function useKitWithExtensions(kit: EditorKit, extensions: readonly AnyExtension[] | undefined): EditorKit;
@@ -0,0 +1,19 @@
1
+ import type { EditorMenuContext, EditorMenuContribution } from "../api/menu";
2
+ import type { ContextMenuItem } from "../components/EditorContextMenu/types";
3
+ /**
4
+ * 把各扩展贡献的菜单声明求值成渲染件条目(01 §5.4)。
5
+ * when 决定条目是否出现;disabled 决定灰显;执行统一走 `editor.commands.execute`
6
+ * (与热键共享命令的 enablement 与熔断)。求值错误只丢出错的条目,不波及其他扩展。
7
+ * 顶层条目按 id 去重,后声明的覆盖先声明的——扩展可以覆盖内核默认条目。
8
+ */
9
+ /** 一个扩展贡献的菜单来源;owner 用于日志,并写入条目的 owner 字段供宿主区分来源 */
10
+ export interface MenuContributionSource {
11
+ readonly owner: string;
12
+ readonly menu: EditorMenuContribution;
13
+ /**
14
+ * 贡献者注册的元素类型:条目默认只出现在这些类型上(特有菜单不进别的块的菜单)。
15
+ * 不注册元素的扩展(内核默认菜单、preview 菜单)为全局条目,靠自身 when 限定范围。
16
+ */
17
+ readonly types?: readonly string[];
18
+ }
19
+ export declare function resolveBlockMenuItems(sources: readonly MenuContributionSource[], ctx: EditorMenuContext, extras?: readonly ContextMenuItem[]): ContextMenuItem[];
@@ -2,9 +2,9 @@ import { Editor, Node, Path } from "slate";
2
2
  import type { EditorFeedback } from "../services/notifier";
3
3
  /**
4
4
  * 复制节点到剪贴板
5
- * 支持两种格式:JSON 和纯文本
5
+ * 支持两种格式:JSON 和纯文本;传入数组时按数组顺序作为一个 fragment,纯文本以换行连接
6
6
  */
7
- export declare function copyNodeToClipboard(_editor: Editor, element: Node, message?: EditorFeedback, options?: {
7
+ export declare function copyNodeToClipboard(_editor: Editor, element: Node | Node[], message?: EditorFeedback, options?: {
8
8
  allowPlainTextFallback?: boolean;
9
9
  signal?: AbortSignal;
10
10
  }): Promise<boolean>;
@@ -1,7 +1,7 @@
1
- /** 能力版本表示接口可用性,不代表业务数据授权。 */
2
- export declare const PLUGIN_CAPABILITIES: readonly ["commands.v1", "storage.v1", "pages.v1", "navigation.v1", "settings.v1", "ui.dialog.v1", "editor.elements.v1", "editor.codecs.v1", "editor.source.v1"];
1
+ /** 功能名只表示是否可用;接口升级由 SDK 和最低客户端版本管理。 */
2
+ export declare const PLUGIN_CAPABILITIES: readonly ["commands", "storage", "pages", "navigation", "settings", "dialogs", "editor", "editorCodecs", "sourceEditor", "runtimeStyles", "media"];
3
3
  export type PluginCapability = (typeof PLUGIN_CAPABILITIES)[number];
4
- /** 消费者保留未来版本的能力名,但不把它们声明为本宿主已实现。 */
4
+ /** 保留分发清单原值,未知可选功能可读取但不能当作已实现功能。 */
5
5
  export declare function readPluginCapabilityNames(value: unknown): readonly string[];
6
6
  export declare function isPluginCapability(value: unknown): value is PluginCapability;
7
7
  export declare function readPluginCapabilities(value: unknown): readonly PluginCapability[];
@@ -1,14 +1,11 @@
1
1
  import { type ReactNode } from "react";
2
- import { type PluginCapability } from "./capabilities";
3
2
  export interface PluginEnvironment {
4
- readonly platform: "desktop" | "android" | "ios" | "web" | "unknown";
5
- readonly layout: "compact" | "wide" | "unknown";
3
+ readonly platform: "desktop" | "android" | "ios" | "web";
4
+ /** WebView 报告的可用指针精度,不代表当前输入设备或悬停能力。 */
6
5
  readonly input: Readonly<{
7
- touch: boolean;
6
+ coarsePointer: boolean;
8
7
  finePointer: boolean;
9
8
  }>;
10
- /** 可用能力,不代表数据授权或代码隔离。 */
11
- readonly capabilities: readonly PluginCapability[];
12
9
  }
13
10
  export interface PluginEnvironmentSource {
14
11
  getSnapshot(): PluginEnvironment;
@@ -17,14 +14,14 @@ export interface PluginEnvironmentSource {
17
14
  export declare function createPluginEnvironmentStore(initial: PluginEnvironment): Readonly<{
18
15
  getSnapshot: () => PluginEnvironment;
19
16
  subscribe: (listener: () => void) => () => void;
20
- update(patch: Partial<Pick<PluginEnvironment, "layout" | "input">>): void;
17
+ update(patch: Partial<Pick<PluginEnvironment, "input">>): void;
21
18
  }>;
22
- /** 由宿主显式选择平台;媒体查询只描述布局和输入,不用于猜测操作系统。 */
23
- export declare function createBrowserPluginEnvironment(platform: PluginEnvironment["platform"], capabilities: readonly PluginCapability[], viewport: Window): {
19
+ /** 平台由宿主提供,输入信息来自媒体查询。 */
20
+ export declare function createBrowserPluginEnvironment(platform: PluginEnvironment["platform"], viewport: Window): {
24
21
  connect(): () => void;
25
22
  getSnapshot: () => PluginEnvironment;
26
23
  subscribe: (listener: () => void) => () => void;
27
- update: (patch: Partial<Pick<PluginEnvironment, "layout" | "input">>) => void;
24
+ update: (patch: Partial<Pick<PluginEnvironment, "input">>) => void;
28
25
  };
29
26
  export declare function PluginEnvironmentProvider(props: {
30
27
  children: ReactNode;
@@ -1,8 +1,6 @@
1
1
  import type { PluginDefinition } from "./contract";
2
2
  export { usePluginEnvironment } from "./environment";
3
3
  export type { PluginEnvironment } from "./environment";
4
- export { PLUGIN_CAPABILITIES, isPluginCapability } from "./capabilities";
5
- export type { PluginCapability } from "./capabilities";
6
4
  export type { PluginNavigation, PluginNavigationEntry } from "./navigation";
7
5
  export type { PluginBackendClient, BackendStatus, BackendState } from "./backend";
8
6
  export type * from "./upload";
@@ -1,6 +1,8 @@
1
1
  import { type PluginManifest } from "./package";
2
2
  import { type PluginCapability } from "./capabilities";
3
3
  import type { PluginEnvironment } from "./environment";
4
+ export { isPluginCapability } from "./capabilities";
5
+ export type { PluginCapability } from "./capabilities";
4
6
  export declare const PORTABLE_PLATFORMS: readonly ["desktop", "android", "ios"];
5
7
  export type PortablePlatform = (typeof PORTABLE_PLATFORMS)[number];
6
8
  export type PluginElementSupport = "none" | "render" | "edit";
@@ -11,15 +13,45 @@ export interface PortablePluginTarget<Capability extends string = PluginCapabili
11
13
  readonly optional: readonly Capability[];
12
14
  readonly elements?: Readonly<Record<string, PluginElementSupport>>;
13
15
  }
14
- export interface PortablePluginManifest<Capability extends string = PluginCapability> extends Omit<PluginManifest, "formatVersion" | "platform" | "backend" | "whiteboard" | "skills" | "minAppVersion"> {
16
+ export interface PortablePluginManifest<Capability extends string = PluginCapability> extends Omit<PluginManifest, "formatVersion" | "platform" | "backend" | "whiteboard" | "minAppVersion"> {
15
17
  readonly formatVersion: 3;
16
18
  readonly platform: "portable";
17
19
  readonly profile: "web-v1";
20
+ readonly description?: string;
18
21
  readonly targets: Readonly<Partial<Record<PortablePlatform, PortablePluginTarget<Capability>>>>;
19
22
  }
20
23
  export type ReadablePortablePluginManifest = PortablePluginManifest<string>;
24
+ export declare const PLUGIN_BASE_REQUIREMENTS: readonly ["commands", "storage", "pages", "navigation", "settings", "dialogs"];
25
+ export type PluginRequirement = "sourceEditor" | "runtimeStyles" | "media";
26
+ export type OptionalPluginRequirement = "runtimeStyles";
27
+ export interface PluginAuthorTarget {
28
+ readonly minAppVersion: string;
29
+ readonly requires?: readonly PluginRequirement[];
30
+ readonly optional?: readonly OptionalPluginRequirement[];
31
+ readonly editor?: {
32
+ readonly elements: Readonly<Record<string, PluginElementSupport>>;
33
+ };
34
+ }
35
+ export interface PluginAuthorManifest extends Pick<PluginManifest, "id" | "name" | "version" | "categories" | "keywords" | "permissions"> {
36
+ readonly description?: string;
37
+ readonly requires?: readonly PluginRequirement[];
38
+ readonly optional?: readonly OptionalPluginRequirement[];
39
+ readonly editor?: {
40
+ readonly elements: Readonly<Record<string, PluginElementSupport>>;
41
+ };
42
+ readonly targets: Readonly<Partial<Record<PortablePlatform, PluginAuthorTarget>>>;
43
+ }
44
+ export interface PluginBuildOutput {
45
+ readonly main: string;
46
+ readonly styles?: string;
47
+ readonly integrity: Readonly<Record<string, string>>;
48
+ readonly skills?: readonly string[];
49
+ }
50
+ /** 作者只声明额外需求;发行字段由构建工具提供,平台覆盖按整组替换。 */
51
+ export declare function buildPortablePluginManifest(value: unknown, output: PluginBuildOutput): PortablePluginManifest;
21
52
  export interface PortablePluginHost {
22
53
  readonly environment: PluginEnvironment;
54
+ readonly capabilities: readonly PluginCapability[];
23
55
  readonly appVersion: string;
24
56
  readonly profiles: readonly string[];
25
57
  }
@@ -1,5 +1,6 @@
1
- export { validatePluginManifest, PLUGIN_SHARED_MODULES } from "./package";
2
- import type { DevelopmentPluginPackage } from "./package";
1
+ export { PLUGIN_SHARED_MODULES } from "./package";
2
+ export { readPublishedPluginManifest as validatePluginManifest } from "./rendering";
3
+ import type { PublishedPluginRender } from "./render-artifact";
3
4
  export declare const PLUGIN_RENDER_VERSION: 1;
4
5
  export type { PublishedPluginRender } from "./render-artifact";
5
6
  /** 协议层只检查贡献归属,具体扩展类型由模板选用的渲染器解释。 */
@@ -10,5 +11,9 @@ export interface EvaluatedPluginDefinition {
10
11
  apiVersion: 1;
11
12
  editorExtensions?: readonly unknown[];
12
13
  }
13
- export declare function evaluatePluginPackage(artifact: DevelopmentPluginPackage, modules: Readonly<Record<string, unknown>>): EvaluatedPluginDefinition;
14
+ export declare function evaluatePluginPackage(artifact: {
15
+ manifest: PublishedPluginRender["manifest"];
16
+ code: string;
17
+ css?: string;
18
+ }, modules: Readonly<Record<string, unknown>>): EvaluatedPluginDefinition;
14
19
  export declare function assertRenderTypes(definition: EvaluatedPluginDefinition, types: string[]): void;
@@ -1,8 +1,9 @@
1
1
  import type { PluginManifest } from "./package";
2
+ import type { ReadablePortablePluginManifest } from "./portable";
2
3
  /** 发布内容只携带插件产物元数据,不依赖编辑器或 UI 类型。 */
3
4
  export interface PublishedPluginRender {
4
5
  runtimeVersion: 1;
5
- manifest: PluginManifest;
6
+ manifest: PluginManifest | ReadablePortablePluginManifest;
6
7
  entry: string;
7
8
  styles?: string;
8
9
  nodeTypes: string[];
@@ -0,0 +1,78 @@
1
+ import type { PluginDefinition } from "./contract";
2
+ import type { PluginEditorExtension } from "./editor";
3
+ import type { MarkdownCodec } from "../../markdown/src/index";
4
+ import { type PortablePlatform, type ReadablePortablePluginManifest, type PortablePluginHost } from "./portable";
5
+ import { type DevelopmentPluginPackage, type PluginManifest } from "./package";
6
+ export type { PublishedPluginRender } from "./render-artifact";
7
+ export declare function assertUniqueEditorCodecs(codecs: readonly MarkdownCodec[]): void;
8
+ export declare const PLUGIN_RENDER_VERSION = 1;
9
+ /** 发布站只读取静态贡献;清单保持原格式,不启动应用插件生命周期。 */
10
+ export declare function readPublishedPluginManifest(value: unknown): PluginManifest | ReadablePortablePluginManifest;
11
+ export declare function evaluatePublishedPluginPackage(artifact: {
12
+ manifest: PluginManifest | ReadablePortablePluginManifest;
13
+ code: string;
14
+ css?: string;
15
+ }, modules: Readonly<Record<string, unknown>>): PluginDefinition;
16
+ export interface PluginRenderSelection {
17
+ id: string;
18
+ version: string;
19
+ mainHash: string;
20
+ stylesHash?: string;
21
+ nodeTypes: string[];
22
+ styleSources?: PluginEditorExtension["styleSources"];
23
+ }
24
+ export interface PluginRenderContext {
25
+ builtinTypes: string[];
26
+ plugins: PluginRenderSelection[];
27
+ }
28
+ /** 只求值定义,不调用 create/activate;两端使用相同的 CJS 与共享模块约定。 */
29
+ export declare function evaluatePluginPackage(artifact: DevelopmentPluginPackage, modules: Readonly<Record<string, unknown>>): PluginDefinition;
30
+ /** 只供显式接入跨端协议的宿主;执行前必须先由包读取器验证文件完整性。 */
31
+ export declare function evaluatePortablePluginPackage(artifact: {
32
+ manifest: ReadablePortablePluginManifest;
33
+ code: string;
34
+ css?: string;
35
+ }, modules: Readonly<Record<string, unknown>>, host: PortablePluginHost): PluginDefinition;
36
+ /** 各宿主共用支持等级投影;原始数据与节点身份不改写。 */
37
+ export declare function adaptPortablePluginDefinition(definition: PluginDefinition, manifest: ReadablePortablePluginManifest, platform: PortablePlatform): {
38
+ support: Readonly<{
39
+ [k: string]: import("./portable").PluginElementSupport;
40
+ }>;
41
+ definition: {
42
+ editorExtensions: {
43
+ blockPanel?: readonly import("../../editor/api").IBlockPanelListItem[] | ((editor: import("slate").Editor) => readonly import("../../editor/api").IBlockPanelListItem[]);
44
+ commands?: readonly import("../../editor/api").EditorCommand[];
45
+ hotkeys?: readonly import("../../editor/api").EditorHotkey[];
46
+ menu?: import("../../editor/api").EditorMenuContribution;
47
+ behaviorsFor?: Readonly<Record<string, import("../../editor/api").ElementBehaviors>>;
48
+ elements: import("../../editor/api").ElementSpec<import("../../editor/api").ParagraphElement>[];
49
+ styleSources: {
50
+ type: string;
51
+ field: string;
52
+ language: "html" | "tsx";
53
+ }[] | undefined;
54
+ htmlSerializers: {
55
+ type: string;
56
+ toHtml(element: Record<string, unknown>): string;
57
+ }[] | undefined;
58
+ id: string;
59
+ apiVersion: typeof import("../../editor/api").EXTENSION_API_VERSION;
60
+ plugins?: never;
61
+ }[] | undefined;
62
+ editorCodecs: MarkdownCodec[] | undefined;
63
+ id: string;
64
+ name: string;
65
+ version: string;
66
+ apiVersion: 1;
67
+ whiteboardExtensions?: readonly import("../../whiteboard/src/author").WhiteboardExtension[];
68
+ ai?: {
69
+ readonly features: readonly import("./ai").PluginAIFeature[];
70
+ };
71
+ create(): import("./contract").PluginInstance;
72
+ };
73
+ };
74
+ type DefinitionManifest = Pick<PluginManifest, "id" | "name" | "version" | "apiVersion" | "editor" | "whiteboard">;
75
+ export declare function validatePluginDefinition(manifest: DefinitionManifest, definition: PluginDefinition | undefined): PluginDefinition;
76
+ export declare function getPluginNodeTypes(definition: PluginDefinition): string[];
77
+ export declare function getPluginWhiteboardTypes(definition: PluginDefinition): string[];
78
+ export declare function assertRenderTypes(definition: PluginDefinition, expected: readonly string[]): void;
@@ -2,7 +2,7 @@
2
2
  * 主题「暖纸」—— 首个主题族,一张暖纸的晨与夜。
3
3
  *
4
4
  * 浅色(晨):取值来自样板间 direction-a-soft.html 的实测调优结果;奶油纸底 + 可可墨 +
5
- * 陶土橙 accent(与移动端「杏子 Bento」同基因)。融合骨架要求:不提供侧栏专用底色,
5
+ * 陶土橙 accent。融合骨架要求:不提供侧栏专用底色,
6
6
  * 侧栏透明融于 bg-page(见 03 指南 · 壳层铁律)。
7
7
  *
8
8
  * 深色(夜):同一张暖纸在烛光下——深可可纸底 + 奶油墨 + 陶土橙提亮。层级与浅色对称翻转: