@codename/deck 0.1.1 → 0.1.2
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 +2 -2
- package/dist/deck.bundle.mjs +49 -49
- package/dist/deck.bundle.mjs.map +3 -3
- package/dist/deck.css +1 -1
- package/dist/deck.js +12 -12
- package/dist/deck.js.map +2 -2
- package/dist/deck.mjs +4 -4
- package/dist/deck.mjs.map +2 -2
- package/dist/types/version.d.ts +1 -1
- package/docs/format.md +1 -1
- package/docs/host.md +2 -2
- package/package.json +1 -1
- package/src/blocks.js +1 -1
- package/src/deck.css +1 -1
- package/src/pptx.js +4 -1
- package/src/version.js +1 -1
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.2";
|
package/docs/format.md
CHANGED
|
@@ -43,7 +43,7 @@ Slidev's form, as `@slidev/parser` splits it, and the parts a deck for knowledge
|
|
|
43
43
|
- **Code** in fences, with lines marked as Slidev marks them: ` ```ts {2,4-5} `.
|
|
44
44
|
- **Charts:** ` ```echarts ` holding an ECharts option as JSON, data only.
|
|
45
45
|
- **Diagrams:** ` ```mermaid ` holding Mermaid's language.
|
|
46
|
-
- **Markdown** as CommonMark and GFM have it: headings, lists, task lists, tables, quotes, emphasis, links, pictures.
|
|
46
|
+
- **Markdown** as CommonMark and GFM have it: headings, lists, task lists, tables, quotes, emphasis, links, pictures. A picture alone on its line fills what its slot leaves, whole, whatever its own size.
|
|
47
47
|
|
|
48
48
|
### Added by deck
|
|
49
49
|
|
package/docs/host.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Drawing decks in a host
|
|
2
2
|
|
|
3
|
-
A host is a page that draws decks itself
|
|
3
|
+
A host is a page that draws decks itself. deck builds every element with the DOM's own calls, sets custom properties through the CSSOM rather than style attributes, and needs no Trusted Types policy, so it runs under a policy with `style-src 'self'` and `trusted-types 'none'`. Load `@codename/deck` (with your own `marked` through an import map) or `@codename/deck/bundle`, and `@codename/deck/css` as a stylesheet.
|
|
4
4
|
|
|
5
5
|
## createDeck(element, options)
|
|
6
6
|
|
|
@@ -40,7 +40,7 @@ Every block that can be changed by hand carries `data-edit="from-to"`, the offse
|
|
|
40
40
|
const { blob, report } = await toPptx(view, { PptxGenJS, JSZip })
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
PptxGenJS 4 (its bundle carries JSZip) is the host's to load, on demand. The file is made from the deck as drawn: a slide layout per deck layout, named by its label in the deck's language, with a placeholder for its title and each slot; lists as lists with their levels; tables; bars, lines, areas, pies, rings, points and radars as native charts with their numbers, other charts and diagrams as pictures; notes; transitions; the kit's colours as the theme. `report` counts slides, charts, tables, pictures and placeholders.
|
|
43
|
+
PptxGenJS 4 (its bundle carries JSZip) is the host's to load, on demand. The file is made from the deck as drawn: a slide layout per deck layout, named by its label in the deck's language, with a placeholder for its title and each slot; lists as lists with their levels; tables; bars, lines, areas, pies, rings, points and radars as native charts with their numbers, other charts and diagrams as pictures, and pictures, alone on their line or beside the words, as pictures; notes; transitions; the kit's colours as the theme. `report` counts slides, charts, tables, pictures and placeholders.
|
|
44
44
|
|
|
45
45
|
## Files
|
|
46
46
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codename/deck",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Slide decks as one web page: Markdown in Slidev's form inside a .deck.html file any browser presents, a renderer that runs anywhere, kits of layouts and looks, and an editable PowerPoint out",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/blocks.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// from `base` (a CDN by default) the first time a slide needs it, never before. A chart is data,
|
|
3
3
|
// read with JSON.parse; it takes the deck's colours and type, light or dark, and is drawn as SVG.
|
|
4
4
|
// A diagram is drawn by Pele from Mermaid's language as SVG, then shown as a picture, so nothing it
|
|
5
|
-
// makes runs or joins the page; its words are its picture's text for whoever can't see it. A host
|
|
5
|
+
// makes runs or joins the page; its words are its picture's text for whoever can't see it. A host gives
|
|
6
6
|
// its own drawers instead.
|
|
7
7
|
|
|
8
8
|
/** @typedef {{ base: string, root: HTMLElement, versions?: { echarts?: string, pele?: string } }} Where */
|
package/src/deck.css
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
.deck-slide pre.has-marks .deck-line:not(.is-marked) { opacity: 0.45; }
|
|
34
34
|
.deck-slide blockquote { border-inline-start: 0.25em solid var(--deck-fill); padding-inline-start: 0.9em; margin-inline: 0; font-style: italic; }
|
|
35
35
|
.deck-slide img { max-inline-size: 100%; max-block-size: 100%; object-fit: contain; }
|
|
36
|
-
.deck-slide .deck-picture { flex: 1; min-block-size: 0; display: grid; place-items: center; }
|
|
36
|
+
.deck-slide .deck-picture { flex: 1; min-block-size: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; }
|
|
37
37
|
.deck-slide .deck-picture img { block-size: 100%; }
|
|
38
38
|
.deck-table { overflow: hidden; }
|
|
39
39
|
.deck-slide table { border-collapse: collapse; inline-size: 100%; font-size: 0.85em; }
|
package/src/pptx.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
import { labelOf } from './kit.js'
|
|
12
12
|
|
|
13
13
|
const W = 13.333, H = 7.5
|
|
14
|
-
|
|
14
|
+
// Words: a paragraph that is a picture alone on its line is the picture.
|
|
15
|
+
const TEXT = 'h1, h2, h3, h4, h5, h6, .deck-h, p:not(.deck-picture), ul, ol, blockquote'
|
|
15
16
|
|
|
16
17
|
/** @param {string} value rgb(…) or #… @returns {string} six hex digits */
|
|
17
18
|
function hexOf(value) {
|
|
@@ -121,6 +122,8 @@ export async function toPptx(view, { PptxGenJS, JSZip }) {
|
|
|
121
122
|
} else {
|
|
122
123
|
const img = block.querySelector('img')
|
|
123
124
|
if (img) {
|
|
125
|
+
// A slide's pictures are read as they come near the screen: one not read yet is read now, so that it has its size.
|
|
126
|
+
if (!img.complete) { img.loading = 'eager'; await img.decode().catch(() => {}) }
|
|
124
127
|
const data = await pictureOf(img.src, img.clientWidth * 2, img.clientHeight * 2)
|
|
125
128
|
if (data) { slide.addImage({ data, ...place(img), altText: img.alt }); report.pictures++ }
|
|
126
129
|
}
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// deck's version, which a linked file names in its renderer's address. Kept equal to package.json's by a test.
|
|
2
|
-
export const VERSION = '0.1.
|
|
2
|
+
export const VERSION = '0.1.2'
|