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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// [文件] gbpptx·切换动画 —— 放映与画布预览共用同一套 CSS 动画口径
|
|
2
|
+
|
|
3
|
+
const SPEED_MS = { fast: 500, med: 800, slow: 1500 };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 对「刚进入的页容器」播放切换动画
|
|
7
|
+
* @param {HTMLElement} wrap 承载页面的容器
|
|
8
|
+
* @param {{type:string,dir:string,speed:string}} tr
|
|
9
|
+
*/
|
|
10
|
+
export function animateSlideFrame(wrap, tr) {
|
|
11
|
+
if (!wrap || !tr || tr.type === 'none') return;
|
|
12
|
+
const dur = SPEED_MS[tr.speed] || SPEED_MS.med;
|
|
13
|
+
const dir = tr.dir || 'l';
|
|
14
|
+
const tx = dir === 'l' ? '60px' : dir === 'r' ? '-60px' : '0';
|
|
15
|
+
const ty = dir === 'u' ? '60px' : dir === 'd' ? '-60px' : '0';
|
|
16
|
+
const easing = 'cubic-bezier(.2,.7,.2,1)';
|
|
17
|
+
if (tr.type === 'wipe') {
|
|
18
|
+
const from = dir === 'r' ? 'inset(0 0 0 100%)' : dir === 'u' ? 'inset(100% 0 0 0)' : dir === 'd' ? 'inset(0 0 100% 0)' : 'inset(0 100% 0 0)';
|
|
19
|
+
wrap.animate([{ clipPath: from }, { clipPath: 'inset(0 0 0 0)' }], { duration: dur, easing });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (tr.type === 'split') {
|
|
23
|
+
wrap.animate([{ clipPath: 'inset(0 50% 0 50%)' }, { clipPath: 'inset(0 0 0 0)' }], { duration: dur, easing });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let frames = [{ opacity: 0 }, { opacity: 1 }];
|
|
27
|
+
if (tr.type === 'push' || tr.type === 'cover') frames = [{ transform: `translate(${tx}, ${ty})` }, { transform: 'translate(0, 0)' }];
|
|
28
|
+
if (tr.type === 'zoom') frames = [{ opacity: 0, transform: 'scale(1.08)' }, { opacity: 1, transform: 'scale(1)' }];
|
|
29
|
+
wrap.animate(frames, { duration: dur, easing, fill: 'both' });
|
|
30
|
+
}
|
package/web/index.html
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>挂逼演示 gbpptx</title>
|
|
7
|
-
<link rel="stylesheet" href="/web/styles/tokens.css" />
|
|
8
|
-
<link rel="stylesheet" href="/web/styles/slides.css" />
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>挂逼演示 gbpptx</title>
|
|
7
|
+
<link rel="stylesheet" href="/web/styles/tokens.css" />
|
|
8
|
+
<link rel="stylesheet" href="/web/styles/slides.css" />
|
|
9
|
+
<link rel="stylesheet" href="/web/styles/office.css" />
|
|
10
|
+
<script type="importmap">
|
|
11
|
+
{
|
|
12
|
+
"imports": {
|
|
13
|
+
"gbooxml": "/vendor/gbooxml/index.js",
|
|
14
|
+
"guabiutils": "/vendor/guabiutils/index.js"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="app" class="gbp-root"></div>
|
|
21
|
+
<script type="module" src="/web/app/main.js"></script>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
package/web/serve.mjs
CHANGED
|
@@ -1,67 +1,20 @@
|
|
|
1
|
-
// [文件] gbpptx·serve ——
|
|
2
|
-
// 用法:node web/serve.mjs [端口] → http://localhost:5274/web/
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'.png': 'image/png',
|
|
22
|
-
'.webp': 'image/webp',
|
|
23
|
-
'.ico': 'image/x-icon',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function resolvePath(urlPath) {
|
|
27
|
-
const decoded = decodeURIComponent(urlPath.split('?')[0]);
|
|
28
|
-
if (decoded.startsWith('/vendor/gbooxml/')) {
|
|
29
|
-
const rest = decoded.slice('/vendor/gbooxml/'.length);
|
|
30
|
-
const target = normalize(join(OOXML_ROOT, rest));
|
|
31
|
-
return target.startsWith(OOXML_ROOT + sep) || target === OOXML_ROOT ? target : null;
|
|
32
|
-
}
|
|
33
|
-
const rest = decoded === '/' ? 'web/index.html' : decoded.replace(/^\/+/, '');
|
|
34
|
-
const target = normalize(join(ROOT, rest));
|
|
35
|
-
return target.startsWith(ROOT) ? target : null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const server = createServer(async (req, res) => {
|
|
39
|
-
let target = resolvePath(req.url || '/');
|
|
40
|
-
try {
|
|
41
|
-
if (!target) throw new Error('forbidden');
|
|
42
|
-
let info = await stat(target).catch(() => null);
|
|
43
|
-
if (info?.isDirectory()) {
|
|
44
|
-
target = join(target, 'index.html');
|
|
45
|
-
info = await stat(target).catch(() => null);
|
|
46
|
-
}
|
|
47
|
-
if (!info?.isFile()) {
|
|
48
|
-
res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
49
|
-
res.end('404 Not Found');
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const body = await readFile(target);
|
|
53
|
-
res.writeHead(200, {
|
|
54
|
-
'Content-Type': MIME[extname(target).toLowerCase()] || 'application/octet-stream',
|
|
55
|
-
'Cache-Control': 'no-store',
|
|
56
|
-
});
|
|
57
|
-
res.end(body);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
60
|
-
res.end(`500 ${err.message}`);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
server.listen(PORT, () => {
|
|
65
|
-
console.log(`gbpptx 运行中:http://localhost:${PORT}/web/`);
|
|
66
|
-
console.log(`gbOoxml 映射自:${OOXML_ROOT}`);
|
|
67
|
-
});
|
|
1
|
+
// [文件] gbpptx·serve —— 静态服务器(包根为 URL 空间根:/web/ 为应用,/vendor/* 映射到同仓源码包)
|
|
2
|
+
// 用法:node web/serve.mjs [端口] → http://localhost:5274/web/
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { startStaticServer } from 'guabiutils/dev-server';
|
|
5
|
+
|
|
6
|
+
const ooxmlSrc = fileURLToPath(new URL('../../gbooxml/src/', import.meta.url));
|
|
7
|
+
const utilsSrc = fileURLToPath(new URL('../../guabiutils/src/', import.meta.url));
|
|
8
|
+
|
|
9
|
+
const { origin } = await startStaticServer({
|
|
10
|
+
root: fileURLToPath(new URL('..', import.meta.url)),
|
|
11
|
+
index: 'web/index.html',
|
|
12
|
+
port: Number(process.argv[2] || process.env.GBPPTX_PORT || 5274),
|
|
13
|
+
mounts: [
|
|
14
|
+
{ prefix: '/vendor/gbooxml/', dir: ooxmlSrc },
|
|
15
|
+
{ prefix: '/vendor/guabiutils/', dir: utilsSrc },
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
console.log(`gbpptx 运行中:${origin}/web/`);
|
|
20
|
+
console.log(`gbooxml 映射自:${ooxmlSrc}`);
|