@quirekit/pptx-editor 0.3.0 → 0.3.1
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.
- package/README.md +21 -0
- package/README.zh-CN.md +21 -0
- package/dist/ai.d.mts +24 -1
- package/dist/ai.mjs +51 -51
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +36 -32
- package/dist/open-aKqKXJ6B.mjs +2 -0
- package/dist/styles.css +29 -0
- package/dist/svg-raster-BWlVOKxM.mjs +11 -0
- package/dist/templates.d.mts +575 -0
- package/dist/templates.mjs +1 -0
- package/dist/{types-B8CWBpnf.d.mts → types-Brh5JARz.d.mts} +437 -674
- package/dist/types-DeGx0c3N.d.mts +687 -0
- package/package.json +33 -29
- package/dist/svg-raster-DL19F7ez.mjs +0 -11
package/README.md
CHANGED
|
@@ -32,6 +32,27 @@ new Editor({ panels: [ai.panel] }).mount("#app");
|
|
|
32
32
|
|
|
33
33
|
The assistant uses the `@quirekit/ai-*` packages, which are optional peer dependencies.
|
|
34
34
|
|
|
35
|
+
## Templates
|
|
36
|
+
|
|
37
|
+
Decks can be built on a school's or company's own template: an ordinary `.pptx` or `.potx`, read automatically. Users
|
|
38
|
+
upload theirs under Design → Template; a host or a template library adds its own source:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import type { PptxTemplateSource } from "@quirekit/pptx-editor/templates";
|
|
42
|
+
|
|
43
|
+
const school: PptxTemplateSource = {
|
|
44
|
+
id: "school",
|
|
45
|
+
name: "School templates",
|
|
46
|
+
list: async () => [{ id: "default", name: "School deck" }],
|
|
47
|
+
load: async id => ({ name: `${id}.pptx`, bytes: new Uint8Array(await (await fetch(`/templates/${id}.pptx`)).arrayBuffer()) })
|
|
48
|
+
};
|
|
49
|
+
new Editor({ templates: [school] }).mount("#app");
|
|
50
|
+
await session.applyTemplate({ source: "school", id: "default" });
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A file can carry a manifest that names its pages, slots, colours and rules. `describeTemplate` writes one to start from,
|
|
54
|
+
`readPresentationTemplate` checks it, and `presentationTemplateSchema` is its JSON Schema.
|
|
55
|
+
|
|
35
56
|
## License
|
|
36
57
|
|
|
37
58
|
See [LICENSE.md](./LICENSE.md).
|
package/README.zh-CN.md
CHANGED
|
@@ -30,6 +30,27 @@ new Editor({ panels: [ai.panel] }).mount("#app");
|
|
|
30
30
|
|
|
31
31
|
助手依赖 `@quirekit/ai-*` 各包,它们是可选的对等依赖。
|
|
32
32
|
|
|
33
|
+
## 模板
|
|
34
|
+
|
|
35
|
+
稿件可以使用学校或公司自己的模板:一个普通的 `.pptx` 或 `.potx`,编辑器自动识别其中的页面。用户在“设计 → 模板”中上传;
|
|
36
|
+
宿主或模板库传入自己的来源:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import type { PptxTemplateSource } from "@quirekit/pptx-editor/templates";
|
|
40
|
+
|
|
41
|
+
const school: PptxTemplateSource = {
|
|
42
|
+
id: "school",
|
|
43
|
+
name: "学校模板",
|
|
44
|
+
list: async () => [{ id: "default", name: "学校课件" }],
|
|
45
|
+
load: async id => ({ name: `${id}.pptx`, bytes: new Uint8Array(await (await fetch(`/templates/${id}.pptx`)).arrayBuffer()) })
|
|
46
|
+
};
|
|
47
|
+
new Editor({ templates: [school] }).mount("#app");
|
|
48
|
+
await session.applyTemplate({ source: "school", id: "default" });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
文件可以附带说明数据,写明页面、槽位、配色和使用规则。`describeTemplate` 生成一份初稿,`readPresentationTemplate` 校验,
|
|
52
|
+
`presentationTemplateSchema` 是它的 JSON Schema。
|
|
53
|
+
|
|
33
54
|
## 许可
|
|
34
55
|
|
|
35
56
|
见 [LICENSE.md](./LICENSE.md)。
|
package/dist/ai.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as PptxTemplateSource, a as PptxCommandRegistry, i as PptxCommandName, l as PptxLayoutChecker, n as PptxCommandAgentContext, o as PptxCommands, p as PptxTemplateFile, r as PptxCommandDescriptor, t as PptxChain, u as PptxLoadedTemplate } from "./types-Brh5JARz.mjs";
|
|
2
|
+
import { d as PptxEditorSession, o as PptxEditorPanel } from "./types-DeGx0c3N.mjs";
|
|
2
3
|
import { PresentationData, SlideData } from "@quirekit/office-kit-pptx";
|
|
3
4
|
import { QuireAiModelConnection, QuireAiProviderPlugin } from "@quirekit/ai-assistant";
|
|
4
5
|
import { QuireAiSlidesDocument, QuireAiSlidesSlideDesign } from "@quirekit/ai-runtime/slides";
|
|
@@ -165,6 +166,26 @@ interface PptxDocument {
|
|
|
165
166
|
subscribe(listener: (change: PptxDocumentChange) => void): () => void;
|
|
166
167
|
}
|
|
167
168
|
//#endregion
|
|
169
|
+
//#region src/template/library.d.ts
|
|
170
|
+
/** The templates one editor can use, and the one its deck uses. */
|
|
171
|
+
interface PptxTemplateLibrary {
|
|
172
|
+
/** Sources in the order they are offered. */
|
|
173
|
+
readonly sources: readonly PptxTemplateSource[];
|
|
174
|
+
/** @param presentation - Deck. @returns The template it uses, once loaded; undefined without one or while it cannot be had. */
|
|
175
|
+
current(presentation: PresentationData): PptxLoadedTemplate | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* Puts the deck on a template as one undo step.
|
|
178
|
+
* @param template - Template of a source, or a file.
|
|
179
|
+
* @returns Whether it was applied; false when the source no longer has it.
|
|
180
|
+
*/
|
|
181
|
+
apply(template: {
|
|
182
|
+
readonly source: string;
|
|
183
|
+
readonly id: string;
|
|
184
|
+
} | PptxTemplateFile): Promise<boolean>;
|
|
185
|
+
/** Stops following the deck. */
|
|
186
|
+
readonly destroy: () => void;
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
168
189
|
//#region src/session/session.d.ts
|
|
169
190
|
/** Session with the parts only first-party views and adapters use. */
|
|
170
191
|
interface PptxMountedSession extends PptxEditorSession {
|
|
@@ -172,6 +193,8 @@ interface PptxMountedSession extends PptxEditorSession {
|
|
|
172
193
|
readonly document: PptxDocument;
|
|
173
194
|
/** Installed command table, also read by AI adapters for its descriptions. */
|
|
174
195
|
readonly table: PptxCommandTable;
|
|
196
|
+
/** Templates the deck can use, and the one it uses. */
|
|
197
|
+
readonly templates: PptxTemplateLibrary;
|
|
175
198
|
/** Releases listeners and pending reads. */
|
|
176
199
|
destroy(): void;
|
|
177
200
|
}
|