gbpptx 0.1.1 → 0.3.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.
- package/README.md +220 -158
- package/package.json +15 -4
- package/src/index.js +16 -8
- package/src/kernel/model.js +397 -91
- package/src/kernel/parts.js +3 -3
- package/src/kernel/pptx.js +17 -12
- package/src/kernel/read.js +747 -157
- package/src/kernel/roundtrip.js +118 -18
- package/src/kernel/text.js +133 -28
- package/src/kernel/write.js +160 -49
- package/web/app/main.js +8 -8
- package/web/app/slides/arrange.js +101 -0
- package/web/app/slides/clipboard.js +93 -0
- package/web/app/slides/file.js +243 -0
- package/web/app/slides/find.js +199 -0
- package/web/app/slides/history.js +100 -0
- package/web/app/slides/keys.js +174 -0
- package/web/app/slides/menus.js +105 -0
- package/web/app/slides/objects.js +254 -0
- package/web/app/slides/render.js +183 -0
- package/web/app/slides/shared.js +85 -0
- package/web/app/slides/slides.js +103 -0
- package/web/app/slides/table.js +102 -0
- package/web/app/slides/text.js +418 -0
- package/web/app/slides/view.js +130 -0
- package/web/app/slides-app.js +285 -844
- package/web/app/ui/backstage.js +255 -0
- package/web/app/ui/canvas.js +762 -277
- package/web/app/ui/color-panel.js +58 -58
- package/web/app/ui/dialogs.js +120 -120
- package/web/app/ui/file-io.js +116 -89
- package/web/app/ui/format-pane.js +427 -0
- package/web/app/ui/icons.js +129 -0
- package/web/app/ui/menu.js +75 -105
- package/web/app/ui/notify.js +45 -45
- package/web/app/ui/page-view.js +221 -150
- package/web/app/ui/popup.js +80 -80
- package/web/app/ui/present.js +292 -100
- package/web/app/ui/ribbon.js +878 -0
- package/web/app/ui/slide-pane.js +189 -0
- package/web/app/ui/statusbar.js +93 -0
- package/web/app/ui/text-styles.js +84 -84
- package/web/app/ui/titlebar.js +208 -0
- package/web/app/ui/transition.js +30 -0
- package/web/index.html +23 -21
- package/web/serve.mjs +20 -67
- package/web/styles/office.css +642 -0
- package/web/styles/slides.css +210 -212
- package/web/styles/tokens.css +154 -155
- package/src/kernel/menus.js +0 -123
- package/src/kernel/util/escape.js +0 -21
- package/src/kernel/util/id.js +0 -13
- package/web/app/ui/inspector.js +0 -209
- package/web/app/ui/slides-bar.js +0 -63
- package/web/app/ui/toolbar.js +0 -200
package/src/kernel/parts.js
CHANGED
|
@@ -91,16 +91,16 @@ const FMT_SCHEME = '<a:fmtScheme name="Guabi"><a:fillStyleLst>' +
|
|
|
91
91
|
'</a:bgFillStyleLst></a:fmtScheme>';
|
|
92
92
|
|
|
93
93
|
/** 演示文稿主部件(页 id 从 256 起、母版 id 固定 2^31——PowerPoint 的隐含要求) */
|
|
94
|
-
export const presentationPart = (slideIDs) =>
|
|
94
|
+
export const presentationPart = (slideIDs, size = { w: SLIDE_W, h: SLIDE_H }) =>
|
|
95
95
|
XML_HEAD + `<p:presentation ${NS_DECL}>` +
|
|
96
96
|
'<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>' +
|
|
97
97
|
`<p:sldIdLst>${slideIDs}</p:sldIdLst>` +
|
|
98
|
-
`<p:sldSz cx="${pxToEmu(
|
|
98
|
+
`<p:sldSz cx="${pxToEmu(size.w)}" cy="${pxToEmu(size.h)}"/>` +
|
|
99
99
|
'<p:notesSz cx="6858000" cy="9144000"/>' +
|
|
100
100
|
'</p:presentation>';
|
|
101
101
|
|
|
102
102
|
/** 页条目(id 从 256 起,rId 指向该页的关系) */
|
|
103
|
-
export const slideID = (n, rid) => `<p:sldId id="${255 + n}" r:id="${rid}"/>`;
|
|
103
|
+
export const slideID = (n, rid, hidden = false) => `<p:sldId id="${255 + n}" r:id="${rid}"${hidden ? ' show="0"' : ''}/>`;
|
|
104
104
|
|
|
105
105
|
/** 母版:空图形树 + 一个空白版式 */
|
|
106
106
|
export const slideMasterPart = () =>
|
package/src/kernel/pptx.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// [文件] gbpptx·转换引擎常量 —— 模型⇄PresentationML 的主题表、字号/几何换算与图形预设映射(移植 Go pptx.go)
|
|
2
2
|
|
|
3
|
-
import { THEMES, THEME_KEYS, themeOf } from './model.js';
|
|
3
|
+
import { SHAPE_KINDS, SLIDE_H, SLIDE_W, THEMES, THEME_KEYS, themeOf } from './model.js';
|
|
4
4
|
|
|
5
5
|
/** 幻灯片逻辑坐标(16:9),与前端画布、放映、打印同一坐标系 */
|
|
6
|
-
export
|
|
7
|
-
export const SLIDE_H = 540;
|
|
6
|
+
export { SLIDE_W, SLIDE_H };
|
|
8
7
|
|
|
9
8
|
/** 主题表(大写裸十六进制形式):由 model.js 的 THEMES 派生,禁另立第二份色值(改一处必漏一处) */
|
|
10
9
|
const toHex = (css) => String(css).replace('#', '').toUpperCase();
|
|
@@ -47,16 +46,22 @@ export const themeLabel = (key) => themeOf(key).label;
|
|
|
47
46
|
|
|
48
47
|
/* ---------- 图形预设映射 ---------- */
|
|
49
48
|
|
|
50
|
-
/**
|
|
51
|
-
export const
|
|
52
|
-
rect: 'rect', roundRect: 'round', ellipse: 'ellipse', triangle: 'triangle',
|
|
53
|
-
diamond: 'diamond', rightArrow: 'arrow', star5: 'star', chevron: 'chevron',
|
|
54
|
-
};
|
|
49
|
+
/** 编辑器 kind → PresentationML prst(唯一来源:model.js 的形状库) */
|
|
50
|
+
export const KIND_TO_PRST = Object.fromEntries(SHAPE_KINDS.map((k) => [k.kind, k.prst]));
|
|
55
51
|
|
|
56
|
-
/**
|
|
57
|
-
export const
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
/** PresentationML prst → 编辑器 kind;不认识的预设按最接近的可编辑形状收口 */
|
|
53
|
+
export const PRST_TO_KIND = {
|
|
54
|
+
...Object.fromEntries(SHAPE_KINDS.map((k) => [k.prst, k.kind])),
|
|
55
|
+
flowChartProcess: 'rect',
|
|
56
|
+
flowChartAlternateProcess: 'round',
|
|
57
|
+
flowChartDecision: 'diamond',
|
|
58
|
+
flowChartTerminator: 'round',
|
|
59
|
+
flowChartDocument: 'rect',
|
|
60
|
+
flowChartPredefinedProcess: 'rect',
|
|
61
|
+
flowChartConnector: 'ellipse',
|
|
62
|
+
wedgeRectCallout: 'rect',
|
|
63
|
+
wedgeRoundRectCallout: 'round',
|
|
64
|
+
wedgeEllipseCallout: 'ellipse',
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
/** 是否像 pptx(OPC 包一律是 zip;旧版 .ppt 是 OLE 复合文档,魔数 D0CF) */
|