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.
Files changed (55) hide show
  1. package/README.md +220 -158
  2. package/package.json +15 -4
  3. package/src/index.js +16 -8
  4. package/src/kernel/model.js +397 -91
  5. package/src/kernel/parts.js +3 -3
  6. package/src/kernel/pptx.js +17 -12
  7. package/src/kernel/read.js +747 -157
  8. package/src/kernel/roundtrip.js +118 -18
  9. package/src/kernel/text.js +133 -28
  10. package/src/kernel/write.js +160 -49
  11. package/web/app/main.js +8 -8
  12. package/web/app/slides/arrange.js +101 -0
  13. package/web/app/slides/clipboard.js +93 -0
  14. package/web/app/slides/file.js +243 -0
  15. package/web/app/slides/find.js +199 -0
  16. package/web/app/slides/history.js +100 -0
  17. package/web/app/slides/keys.js +174 -0
  18. package/web/app/slides/menus.js +105 -0
  19. package/web/app/slides/objects.js +254 -0
  20. package/web/app/slides/render.js +183 -0
  21. package/web/app/slides/shared.js +85 -0
  22. package/web/app/slides/slides.js +103 -0
  23. package/web/app/slides/table.js +102 -0
  24. package/web/app/slides/text.js +418 -0
  25. package/web/app/slides/view.js +130 -0
  26. package/web/app/slides-app.js +285 -844
  27. package/web/app/ui/backstage.js +255 -0
  28. package/web/app/ui/canvas.js +762 -277
  29. package/web/app/ui/color-panel.js +58 -58
  30. package/web/app/ui/dialogs.js +120 -120
  31. package/web/app/ui/file-io.js +116 -89
  32. package/web/app/ui/format-pane.js +427 -0
  33. package/web/app/ui/icons.js +129 -0
  34. package/web/app/ui/menu.js +75 -105
  35. package/web/app/ui/notify.js +45 -45
  36. package/web/app/ui/page-view.js +221 -150
  37. package/web/app/ui/popup.js +80 -80
  38. package/web/app/ui/present.js +292 -100
  39. package/web/app/ui/ribbon.js +878 -0
  40. package/web/app/ui/slide-pane.js +189 -0
  41. package/web/app/ui/statusbar.js +93 -0
  42. package/web/app/ui/text-styles.js +84 -84
  43. package/web/app/ui/titlebar.js +208 -0
  44. package/web/app/ui/transition.js +30 -0
  45. package/web/index.html +23 -21
  46. package/web/serve.mjs +20 -67
  47. package/web/styles/office.css +642 -0
  48. package/web/styles/slides.css +210 -212
  49. package/web/styles/tokens.css +154 -155
  50. package/src/kernel/menus.js +0 -123
  51. package/src/kernel/util/escape.js +0 -21
  52. package/src/kernel/util/id.js +0 -13
  53. package/web/app/ui/inspector.js +0 -209
  54. package/web/app/ui/slides-bar.js +0 -63
  55. package/web/app/ui/toolbar.js +0 -200
@@ -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(SLIDE_W)}" cy="${pxToEmu(SLIDE_H)}"/>` +
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 = () =>
@@ -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 const SLIDE_W = 960;
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
- /** PresentationML prst → 编辑器 kind */
51
- export const PRST_TO_KIND = {
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
- /** 编辑器 kind → PresentationML prst */
57
- export const KIND_TO_PRST = {
58
- rect: 'rect', round: 'roundRect', ellipse: 'ellipse', triangle: 'triangle',
59
- diamond: 'diamond', arrow: 'rightArrow', star: 'star5', chevron: 'chevron',
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) */