@treasure-ai/treasure-deck 2026.11.1 → 2026.11.3
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/dist/build.js +3 -1
- package/dist/build.js.map +1 -1
- package/dist/cli.js +64 -42
- package/dist/cli.js.map +1 -1
- package/dist/deckstyle.d.ts +16 -2
- package/dist/deckstyle.js +232 -44
- package/dist/deckstyle.js.map +1 -1
- package/dist/dev.d.ts +6 -0
- package/dist/dev.js +36 -1
- package/dist/dev.js.map +1 -1
- package/dist/host.d.ts +18 -0
- package/dist/host.js +28 -1
- package/dist/host.js.map +1 -1
- package/dist/import.d.ts +5 -1
- package/dist/import.js +9 -2
- package/dist/import.js.map +1 -1
- package/dist/parse.d.ts +6 -0
- package/dist/parse.js +15 -0
- package/dist/parse.js.map +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/render.js +7 -3
- package/dist/render.js.map +1 -1
- package/dist/slides.d.ts +8 -2
- package/dist/slides.js +8 -3
- package/dist/slides.js.map +1 -1
- package/dist/slidesexport.d.ts +38 -0
- package/dist/slidesexport.js +51 -0
- package/dist/slidesexport.js.map +1 -0
- package/dist/slideslayout.d.ts +1 -5
- package/dist/slideslayout.js +148 -37
- package/dist/slideslayout.js.map +1 -1
- package/dist/themecheck.d.ts +1 -1
- package/docs/commands.md +5 -2
- package/docs/editor.md +21 -3
- package/docs/syntax.md +4 -1
- package/docs/themes.md +1 -0
- package/package.json +1 -1
- package/runtime/base.css +12 -8
- package/runtime/edit-core.cjs +58 -0
- package/runtime/embed.js +365 -54
- package/skills/treasure-deck/SKILL.md +3 -3
- package/templates/specimen/specimen.md +2 -0
- package/themes/editorial/theme.css +1 -1
- package/themes/gold/theme.css +2 -2
- package/themes/treasure-ai/theme.css +2 -2
- package/themes/treasure-ai-2026/theme.css +4 -4
- package/themes/wvlet/theme.css +2 -2
package/runtime/embed.js
CHANGED
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
// blue panel. Slide outlines use the deck's own accent.
|
|
34
34
|
':root{--ed-bg:#2b2e36;--ed-bg-2:#363a43;--ed-input:#20242c;--ed-line:#3a3e47;--ed-line-2:#4a4f59;--ed-fg:#dce0e5;' +
|
|
35
35
|
'--ed-fg-2:#c0c6cd;--ed-muted:#8b95a1;--ed-accent:#7878ff;--ed-accent-text:#aab0ff;--ed-on-accent:#16181d;--ed-danger:#c2415a;' +
|
|
36
|
-
'--ed-shadow:rgba(0,0,0,.5);--ed-backdrop:#20242c;--ed-stub-line:rgba(170,176,255,.35);--ed-stub-bg:rgba(120,120,255,.06);--ed-thumb:rgba(170,176,255,.5)}' +
|
|
36
|
+
'--ed-shadow:rgba(0,0,0,.5);--ed-backdrop:#20242c;--ed-stub-line:rgba(170,176,255,.35);--ed-stub-bg:rgba(120,120,255,.06);--ed-thumb:rgba(170,176,255,.5);--ed-hover:rgba(255,255,255,.07);--ed-press:rgba(255,255,255,.12);--ed-on:rgba(120,120,255,.24);--ed-tray:#30333c;--ed-raised:#454a55}' +
|
|
37
37
|
'@media (prefers-color-scheme:light){:root{--ed-bg:#fff;--ed-bg-2:#f3f4fb;--ed-input:#f8f9fd;--ed-line:#e3e4f2;--ed-line-2:#cfd2ea;' +
|
|
38
38
|
'--ed-fg:#1c1d33;--ed-fg-2:#3a3c5a;--ed-muted:#61637e;--ed-accent:#3240a4;--ed-accent-text:#3240a4;--ed-on-accent:#fff;' +
|
|
39
|
-
'--ed-danger:#c2415a;--ed-shadow:rgba(30,36,110,.18);--ed-backdrop:#eceef8;--ed-stub-line:rgba(50,64,164,.35);--ed-stub-bg:rgba(50,64,164,.04);--ed-thumb:rgba(50,64,164,.4)}}' +
|
|
39
|
+
'--ed-danger:#c2415a;--ed-shadow:rgba(30,36,110,.18);--ed-backdrop:#eceef8;--ed-stub-line:rgba(50,64,164,.35);--ed-stub-bg:rgba(50,64,164,.04);--ed-thumb:rgba(50,64,164,.4);--ed-hover:rgba(28,29,51,.06);--ed-press:rgba(28,29,51,.11);--ed-on:#e1e5fb;--ed-tray:#f1f3fb;--ed-raised:#fff}}' +
|
|
40
40
|
// Top to bottom: the thumbnail strip, a strip for the preview badge, the current slide (fit to the box between
|
|
41
41
|
// them), and the editor. Out of edit mode, the slide alone.
|
|
42
42
|
':root{--thumbs-h:92px;--badge-h:30px;--editor-h:45vh}html,body{background:var(--ed-backdrop)}' +
|
|
@@ -104,6 +104,9 @@
|
|
|
104
104
|
|
|
105
105
|
'.deck-doc [data-doc-classes]::after{content:attr(data-doc-classes);display:inline-block;margin-left:8px;padding:0 6px;border-radius:999px;vertical-align:middle;' +
|
|
106
106
|
'border:1px solid var(--ed-line-2);color:var(--ed-accent-text);font:500 11px/16px ui-sans-serif,system-ui,sans-serif;-webkit-text-fill-color:var(--ed-accent-text)}' +
|
|
107
|
+
// A list's, table's, or quote's classes go under it, at its left edge (a table's as its caption).
|
|
108
|
+
'.deck-doc :is(ul,ol,blockquote)[data-doc-classes]::after{display:table;margin:2px 0 0 -1.5em}.deck-doc blockquote[data-doc-classes]::after{margin-left:0}' +
|
|
109
|
+
'.deck-doc table[data-doc-classes]::after{display:table-caption;caption-side:bottom;justify-self:start;width:max-content;margin:4px 0 0}' +
|
|
107
110
|
'.deck-doc [data-src]:not(.slide-body){cursor:text}.deck-doc .doc-empty{color:var(--ed-muted);font-style:italic}' +
|
|
108
111
|
// Text is typed where it is, like in a text editor: no box around the block being edited.
|
|
109
112
|
'.deck-doc .deck-editing,.deck-doc [contenteditable]{outline:none;caret-color:var(--ed-accent)}' +
|
|
@@ -155,16 +158,17 @@
|
|
|
155
158
|
'.ly-menu .ly-card:hover:not(:disabled){background:var(--ed-bg-2)}.ly-menu .ly-card.is-on{border-color:var(--ed-accent);color:var(--ed-accent-text)}' +
|
|
156
159
|
'.ly-menu .ly-card:disabled{opacity:.35;cursor:default}.ly-menu .ly-card svg{width:58px;height:33px}' +
|
|
157
160
|
'.ly-menu .ly-toggles{display:flex;gap:6px}.ly-menu .ly-toggles button{padding:3px 9px;border:1px solid var(--ed-line-2);border-radius:5px;background:var(--ed-bg-2);color:var(--ed-fg);font:inherit;cursor:pointer}' +
|
|
158
|
-
'.ly-menu .ly-toggles button.is-on{background:var(--ed-
|
|
159
|
-
'.deck-slide-bar .dsb-present{display:inline-flex}.deck-slide-bar .dsb-present button:first-child{border-radius:
|
|
160
|
-
'.deck-slide-bar .dsb-present button:last-child{border-radius:0
|
|
161
|
+
'.ly-menu .ly-toggles button.is-on{background:var(--ed-on);border-color:transparent;color:var(--ed-accent-text)}' +
|
|
162
|
+
'.deck-slide-bar .dsb-present{display:inline-flex}.deck-slide-bar .dsb-present button:first-child{border-radius:6px 0 0 6px}' +
|
|
163
|
+
'.deck-slide-bar .dsb-present button:last-child{border-radius:0 6px 6px 0;margin-left:-1px;width:22px;padding:0;justify-content:center}.pv-menu{position:fixed;z-index:1001}' +
|
|
161
164
|
'.pb-menu .pb-note{max-width:320px;padding:6px 10px;font-size:12px;color:var(--ed-muted)}' +
|
|
162
165
|
'.deck-index-panel{position:fixed;inset:0;z-index:1100;display:flex;flex-direction:column;background:var(--ed-bg)}.deck-index-panel[hidden]{display:none}' +
|
|
163
166
|
'.deck-index-panel .dip-head{display:flex;align-items:center;gap:8px;padding:6px 10px;border-bottom:1px solid var(--ed-line);font:12px/1.3 ui-sans-serif,system-ui,sans-serif;color:var(--ed-muted)}' +
|
|
164
167
|
'.deck-index-panel .dip-head span{flex:1}.deck-index-panel .dip-head button{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border:1px solid var(--ed-line-2);' +
|
|
165
168
|
'border-radius:5px;background:var(--ed-bg-2);color:var(--ed-fg);font:inherit;cursor:pointer}.deck-index-panel iframe{flex:1;width:100%;border:0}' +
|
|
166
|
-
|
|
167
|
-
'.deck-slide-bar .dsb-view
|
|
169
|
+
// Formatted | Markdown: a segmented control, the view shown raised.
|
|
170
|
+
'.deck-slide-bar .dsb-view{display:inline-flex;gap:2px;padding:2px;border-radius:8px;background:var(--ed-tray)}.deck-slide-bar .dsb-view button{height:24px;border-radius:6px}' +
|
|
171
|
+
'.deck-slide-bar .dsb-view button.is-on{background:var(--ed-raised);color:var(--ed-fg);box-shadow:0 1px 2px var(--ed-shadow)}' +
|
|
168
172
|
'.deck-src-popover{position:fixed;z-index:1000;display:flex;flex-direction:column;gap:6px;padding:8px;border-radius:8px;' +
|
|
169
173
|
'background:var(--ed-bg);border:1px solid var(--ed-line);box-shadow:0 8px 28px var(--ed-shadow);font:12px/1.4 ui-sans-serif,system-ui,sans-serif;color:var(--ed-muted)}' +
|
|
170
174
|
'.deck-src-popover textarea{font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--ed-fg);background:var(--ed-input);' +
|
|
@@ -182,20 +186,35 @@
|
|
|
182
186
|
'.deck-slide-bar .dsb-group{display:inline-flex;align-items:center;gap:6px}' +
|
|
183
187
|
'.deck-slide-bar .dsb-hint{white-space:normal;line-height:1.3}' +
|
|
184
188
|
'@container (max-width:760px){.deck-slide-bar .dsb-words,.deck-slide-bar .ly-label{display:none}.deck-slide-bar button:has(> .dsb-words){padding:3px 5px}}' +
|
|
185
|
-
|
|
186
|
-
'.deck-slide-bar
|
|
187
|
-
'.
|
|
189
|
+
// The second row (what is selected) sits in a tray, as a slide editor's formatting bar does.
|
|
190
|
+
'.deck-slide-bar .dsb-context{margin:0 -4px 6px;padding:0 6px;border-radius:10px;background:var(--ed-tray)}' +
|
|
191
|
+
'.dsb-context .dsb-hint,.dsb-context .dsb-label{color:var(--ed-muted)}.dsb-context .dsb-label{font-size:11px;font-weight:600;letter-spacing:.03em;margin-right:2px}' +
|
|
192
|
+
'.deck-slide-bar button.is-on{background:var(--ed-on);border-color:transparent;color:var(--ed-accent-text)}' +
|
|
193
|
+
'.deck-slide-bar .dsb-sep{width:1px;height:20px;margin:0 4px;background:var(--ed-line-2);flex:none}' +
|
|
188
194
|
'.deck-slide-bar .dsb-size{color:var(--ed-accent-text);font-variant-numeric:tabular-nums;margin-left:4px}' +
|
|
189
195
|
'.deck-slide-bar button{display:inline-flex;align-items:center;gap:4px}.deck-slide-bar button[hidden],.deck-slide-bar .dsb-size[hidden]{display:none}' +
|
|
190
196
|
'.deck-slide-bar button svg{width:16px;height:16px;flex:none}' +
|
|
191
|
-
'.deck-slide-bar :is(.dsb-row, .dsb-group) > button:has(> svg:only-child){padding:
|
|
197
|
+
'.deck-slide-bar :is(.dsb-row, .dsb-group) > button:has(> svg:only-child){width:28px;padding:0;justify-content:center}' +
|
|
192
198
|
'.deck-slide-bar button:disabled{opacity:.35;cursor:default}' +
|
|
193
199
|
'.deck-slide-bar .dsb-style-label{max-width:180px;overflow:hidden;text-overflow:ellipsis}' +
|
|
194
|
-
'.deck-slide-bar button.is-set{border-color:var(--ed-accent);color:var(--ed-accent-text)}' +
|
|
195
|
-
|
|
196
|
-
'
|
|
200
|
+
'.deck-slide-bar button.is-set{border-color:color-mix(in srgb,var(--ed-accent) 55%,transparent);background:var(--ed-on);color:var(--ed-accent-text)}' +
|
|
201
|
+
// The Style menu: a list, each class with what it does, and a check on those set.
|
|
202
|
+
'.dsb-menu{position:fixed;z-index:1001;display:flex;flex-direction:column;min-width:220px;padding:4px;border-radius:8px;' +
|
|
203
|
+
'background:var(--ed-bg);border:1px solid var(--ed-line-2);box-shadow:0 8px 24px var(--ed-shadow)}.dsb-menu[hidden]{display:none}' +
|
|
204
|
+
'.deck-slide-bar .dsb-menu button{justify-content:flex-start;gap:8px;height:auto;padding:5px 8px;color:var(--ed-fg)}' +
|
|
205
|
+
'.deck-slide-bar .dsb-menu button::before{content:"";flex:none;width:14px;color:var(--ed-accent-text);font-weight:700}' +
|
|
206
|
+
'.deck-slide-bar .dsb-menu button.is-on{background:transparent;color:var(--ed-fg)}.deck-slide-bar .dsb-menu button.is-on::before{content:"\\2713"}' +
|
|
207
|
+
'.deck-slide-bar .dsb-menu button.is-on:hover{background:var(--ed-hover)}' +
|
|
208
|
+
'.dsb-menu .dm-name{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px}.dsb-menu .dm-what{margin-left:auto;padding-left:16px;color:var(--ed-muted);font-weight:400}' +
|
|
197
209
|
'.deck-slide-bar[hidden]{display:none}.deck-slide-bar .dsb-num{font-weight:600;white-space:nowrap;margin-right:2px}.deck-slide-bar .dsb-gap{flex:1}' +
|
|
198
|
-
|
|
210
|
+
// Buttons as in a slide editor's toolbar: borderless, a tint on hover and press, the ones that are on tinted with the
|
|
211
|
+
// accent; a menu's button and a split button keep a hairline, so they read as one control.
|
|
212
|
+
'.deck-slide-bar select,.deck-slide-bar button{font:inherit;font-weight:500;color:var(--ed-fg-2);background:transparent;border:1px solid transparent;border-radius:6px;' +
|
|
213
|
+
'height:28px;box-sizing:border-box;padding:0 8px;cursor:pointer;white-space:nowrap;transition:background-color .12s,color .12s,border-color .12s}' +
|
|
214
|
+
'.deck-slide-bar button:hover:not(:disabled):not(.is-on):not(.is-confirm){background:var(--ed-hover);color:var(--ed-fg)}' +
|
|
215
|
+
'.deck-slide-bar button:active:not(:disabled):not(.is-confirm){background:var(--ed-press)}' +
|
|
216
|
+
'.deck-slide-bar button:focus-visible{outline:2px solid var(--ed-accent);outline-offset:1px}' +
|
|
217
|
+
'.deck-slide-bar :is(.dsb-layout,[data-style-menu],.dsb-present > button){border-color:var(--ed-line-2)}' +
|
|
199
218
|
'.deck-slide-bar button:disabled,.deck-slide-bar select:disabled{opacity:.4;cursor:default}' +
|
|
200
219
|
'.deck-slide-bar button.is-confirm{background:var(--ed-danger);border-color:var(--ed-danger);color:#fff}' +
|
|
201
220
|
// Hidden slides (shown here, not presented): dimmed in the strip, with Unhide in edit mode, and marked on the slide.
|
|
@@ -211,6 +230,7 @@
|
|
|
211
230
|
'background:var(--ed-bg-2);border:1px solid var(--ed-line-2);border-radius:4px;padding:0 5px;cursor:pointer}' +
|
|
212
231
|
'.deck-doc .doc-slide.is-hidden > .doc-sep span::after{content:" \\00b7 hidden"}.deck-slide-bar .dsb-hidden{color:var(--ed-muted);font-weight:500}' +
|
|
213
232
|
'.deck.is-stale .slide{opacity:.6;transition:opacity .2s}' +
|
|
233
|
+
'.deck .deck-table-picked{outline:2px solid var(--deck-accent,var(--ed-accent));outline-offset:3px}.deck-table-handle{cursor:ew-resize}.deck-table-handle[hidden]{display:none}' +
|
|
214
234
|
'.deck .deck-img-picked{outline:3px solid var(--deck-accent,var(--ed-accent));outline-offset:3px}.deck-stage .deck-img-picked:is(img,video){cursor:move;touch-action:none}' +
|
|
215
235
|
'.deck-img-handle{position:fixed;z-index:1001;width:14px;height:14px;border-radius:3px;background:var(--ed-accent);border:2px solid var(--ed-bg);cursor:nwse-resize;touch-action:none}' +
|
|
216
236
|
'.deck-img-guide{position:fixed;z-index:1000;border-left:2px dashed var(--ed-accent);pointer-events:none;font:11px/1 ui-sans-serif,system-ui,sans-serif;' +
|
|
@@ -1391,7 +1411,8 @@
|
|
|
1391
1411
|
previewMenu.innerHTML = '<button data-pv="browser">' + icon('external-link', '') + 'Open in the browser</button>' +
|
|
1392
1412
|
'<button data-pv="copy">' + icon('copy', '') + 'Copy link</button>' +
|
|
1393
1413
|
// A host page keeps the edits in its own buffer, so the file on disk (what /__pdf prints) may not have them yet.
|
|
1394
|
-
(host ? '' : '<button data-pv="pdf">' + icon('file-down', '') + '<span class="pv-words">Export PDF</span></button>'
|
|
1414
|
+
(host ? '' : '<button data-pv="pdf">' + icon('file-down', '') + '<span class="pv-words">Export PDF</span></button>' +
|
|
1415
|
+
'<button data-pv="slides">' + icon('presentation', '') + '<span class="pv-words">Export to Google Slides</span></button>');
|
|
1395
1416
|
document.body.appendChild(previewMenu);
|
|
1396
1417
|
function togglePreviewMenu(b) {
|
|
1397
1418
|
previewMenu.hidden = !previewMenu.hidden;
|
|
@@ -1407,6 +1428,7 @@
|
|
|
1407
1428
|
var pv = b.getAttribute('data-pv');
|
|
1408
1429
|
if (pv === 'browser') preview(current);
|
|
1409
1430
|
else if (pv === 'pdf') exportPdf();
|
|
1431
|
+
else if (pv === 'slides') exportSlides();
|
|
1410
1432
|
else copyLink(current);
|
|
1411
1433
|
});
|
|
1412
1434
|
document.addEventListener('mousedown', function (e) {
|
|
@@ -1443,6 +1465,43 @@
|
|
|
1443
1465
|
}, function (e) { done('Couldn\u2019t export the PDF: ' + e, 6000); });
|
|
1444
1466
|
}
|
|
1445
1467
|
|
|
1468
|
+
// Export to Google Slides: POST /__slides exports the deck as saved, as `deck slides` does, and opens the
|
|
1469
|
+
// presentation. The first export makes a new one, whose URL goes in the frontmatter (`slides:`, as an edit that can
|
|
1470
|
+
// be undone), so the next export updates it in place. It takes a minute or so; a second click meanwhile is ignored.
|
|
1471
|
+
var exportingSlides = false;
|
|
1472
|
+
function exportSlides() {
|
|
1473
|
+
if (exportingSlides) return;
|
|
1474
|
+
endEdits();
|
|
1475
|
+
if (md.timer) mdSave();
|
|
1476
|
+
exportingSlides = true;
|
|
1477
|
+
var item = previewMenu.querySelector('[data-pv="slides"]');
|
|
1478
|
+
item.disabled = true;
|
|
1479
|
+
item.querySelector('.pv-words').textContent = 'Exporting to Google Slides\u2026';
|
|
1480
|
+
toast('Exporting to Google Slides\u2026 (about a minute)', 0);
|
|
1481
|
+
var done = function (message, ms) {
|
|
1482
|
+
exportingSlides = false;
|
|
1483
|
+
item.disabled = false;
|
|
1484
|
+
item.querySelector('.pv-words').textContent = 'Export to Google Slides';
|
|
1485
|
+
if (message) toast(message, ms);
|
|
1486
|
+
};
|
|
1487
|
+
queue.then(function () {
|
|
1488
|
+
if (notSaved) return { ok: false, reason: 'cancelled' };
|
|
1489
|
+
return fetch('/__slides', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{}' }).then(function (r) { return r.json(); });
|
|
1490
|
+
}).then(function (r) {
|
|
1491
|
+
if (r && r.reason === 'cancelled') return done();
|
|
1492
|
+
if (!r || !r.ok) return done('Couldn\u2019t export to Google Slides: ' + ((r && r.reason) || 'unknown error'), 10000);
|
|
1493
|
+
// A host that exports (Treasure Work) may add a notice: which account, or why only the text came along.
|
|
1494
|
+
var note = r.message ? ' \u2014 ' + r.message : '', ms = r.message ? 10000 : 0;
|
|
1495
|
+
if (!r.created) return done('Updated the Google Slides presentation' + note, ms || 4000);
|
|
1496
|
+
// Quietly, so the toast says what was exported rather than "Saved".
|
|
1497
|
+
submit(function () {
|
|
1498
|
+
var f = mainFile(), lines = sourceLines(f), p = lines && core.setMeta(lines, 'slides', r.url);
|
|
1499
|
+
if (p) p.file = f;
|
|
1500
|
+
return p;
|
|
1501
|
+
}, function () { done('Exported to a new presentation; its link is now in the frontmatter (slides:)' + note, ms || 5000); }, true);
|
|
1502
|
+
}, function (e) { done('Couldn\u2019t export to Google Slides: ' + e, 10000); });
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1446
1505
|
// Publish (with a host process): POST /__publish waits while Treasure Work builds the deck, asks for the audience
|
|
1447
1506
|
// the first time, and deploys it to Apps Script, then answers with the page's URL. Republishing updates the same
|
|
1448
1507
|
// page. Treasure Work shows the result, so the ▾ menu stays closed; it opens the page or copies its link.
|
|
@@ -1542,7 +1601,7 @@
|
|
|
1542
1601
|
// to preset widths (25-100% of the column, with a guide) and otherwise writes canvas pixels rounded to 10; an
|
|
1543
1602
|
// image sized by h= alone resizes by h=, snapping to 50px steps. Dragging the image itself pins it where it is
|
|
1544
1603
|
// dropped (at=), and In flow takes it back out.
|
|
1545
|
-
var STYLE_CLASSES = ['lead', 'center', 'muted', 'small', 'subtitle', 'meta', 'callout', 'note', 'warn'];
|
|
1604
|
+
var STYLE_CLASSES = ['lead', 'center', 'right', 'muted', 'small', 'subtitle', 'meta', 'callout', 'note', 'warn'];
|
|
1546
1605
|
var ctx = bar.querySelector('.dsb-context');
|
|
1547
1606
|
function showContext(node) {
|
|
1548
1607
|
ctx.innerHTML = '';
|
|
@@ -1588,20 +1647,56 @@
|
|
|
1588
1647
|
var LIST_ITEM = core.LIST_ITEM;
|
|
1589
1648
|
var textRow = null;
|
|
1590
1649
|
|
|
1650
|
+
// What the Style menu styles for the block being edited, and with which classes. A heading or paragraph takes its
|
|
1651
|
+
// classes in its last line's trailing {…}; a list item, table cell, or a paragraph in a quote styles the whole
|
|
1652
|
+
// (outermost) list, table, or quote, on the {…} line after it. `reason` says why the menu is off, when it is.
|
|
1653
|
+
// What each class does, shown beside it in the Style menu.
|
|
1654
|
+
var CLASS_WHAT = { lead: 'Larger, the key point', center: 'Centered', right: 'Right-aligned', muted: 'Quieter color', small: 'Smaller, for sources',
|
|
1655
|
+
subtitle: 'Under a title', meta: 'Date or byline', callout: 'Boxed aside', note: 'Side-ruled note', warn: 'Warning box', steps: 'Numbered chevrons' };
|
|
1656
|
+
var STYLE_KINDS = {
|
|
1657
|
+
text: { label: 'Style', classes: STYLE_CLASSES },
|
|
1658
|
+
UL: { label: 'List style', classes: ['lead', 'small', 'muted', 'callout', 'note', 'warn'] },
|
|
1659
|
+
OL: { label: 'List style', classes: ['lead', 'small', 'muted', 'callout', 'note', 'warn', 'steps'] },
|
|
1660
|
+
BLOCKQUOTE: { label: 'Quote style', classes: ['lead', 'small', 'muted', 'center', 'right'] },
|
|
1661
|
+
TABLE: { label: 'Table style', classes: ['lead', 'small', 'muted'] },
|
|
1662
|
+
};
|
|
1591
1663
|
function styleTarget(block) {
|
|
1592
|
-
if (!core
|
|
1593
|
-
var
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
var
|
|
1598
|
-
var
|
|
1599
|
-
|
|
1664
|
+
if (!core) return null;
|
|
1665
|
+
var whole = null;
|
|
1666
|
+
for (var n = block.parentNode; n && n.nodeType === 1 && !n.classList.contains('doc-slide'); n = n.parentNode) {
|
|
1667
|
+
if (STYLE_KINDS[n.tagName]) whole = n;
|
|
1668
|
+
}
|
|
1669
|
+
var el = whole || block, kind = STYLE_KINDS[whole ? whole.tagName : 'text'];
|
|
1670
|
+
var t = { el: el, whole: !!whole, label: kind.label, classes: kind.classes, src: null, reason: '', apart: !!whole && whole.tagName !== 'BLOCKQUOTE' };
|
|
1671
|
+
if (!whole && !/^(H[1-6]|P)$/.test(block.tagName)) { t.reason = 'This block takes no classes'; return t; }
|
|
1672
|
+
var src = parseSrc(el.getAttribute('data-src')), lines = src && sourceLines(src.file);
|
|
1673
|
+
if (!src || !lines || src.end > lines.length) {
|
|
1674
|
+
t.reason = adding ? 'Type the block first, then pick its style' : 'Updating the preview: try again in a moment';
|
|
1675
|
+
return t;
|
|
1676
|
+
}
|
|
1677
|
+
var written = (whole ? core.afterClasses(lines, src.start, src.end, t.apart) : core.lineClasses(lines[src.end - 1]))
|
|
1678
|
+
.filter(function (c) { return kind.classes.indexOf(c) >= 0; }).sort().join(' ');
|
|
1679
|
+
var shown = kind.classes.filter(function (c) { return el.classList.contains(c); }).sort().join(' ');
|
|
1680
|
+
if (written !== shown) { t.reason = 'Its {…} belongs to an inline element: edit its Markdown to change classes'; return t; }
|
|
1681
|
+
t.src = src;
|
|
1682
|
+
return t;
|
|
1683
|
+
}
|
|
1684
|
+
// The lines of the edit in progress, if any, to keep a class's patch from racing its save.
|
|
1685
|
+
function editedSrc() {
|
|
1686
|
+
return editing ? editing.target.src : fmt ? fmt.target.src : popover ? popover.src : null;
|
|
1687
|
+
}
|
|
1688
|
+
// Before a patch to a list's, table's, or quote's {…} line: the edit in an item or cell carries on, unless its lines
|
|
1689
|
+
// take in the braces (the parser counts braces right under the block as its last item's or the table's), when it is
|
|
1690
|
+
// saved first.
|
|
1691
|
+
function endEditOverBraces(block) {
|
|
1692
|
+
var mine = editedSrc(), now = block && sourceLines(block.file);
|
|
1693
|
+
if (mine && now && mine.file === block.file && mine.end >= block.end && core.isBracesLine(now[mine.end - 1])) endEdits();
|
|
1600
1694
|
}
|
|
1601
1695
|
function hideTextRow() {
|
|
1602
1696
|
if (!textRow) return;
|
|
1603
1697
|
clearContext(textRow.box);
|
|
1604
1698
|
textRow.menu.remove();
|
|
1699
|
+
if (textRow.off) textRow.off();
|
|
1605
1700
|
textRow = null;
|
|
1606
1701
|
}
|
|
1607
1702
|
// The marks the text row shows as on: those the selection is in, read from the Markdown in the popover, and on the
|
|
@@ -1642,6 +1737,153 @@
|
|
|
1642
1737
|
function button(attrs, label, title, on) {
|
|
1643
1738
|
return '<button ' + attrs + (title ? ' title="' + title + '"' : '') + (on ? ' class="is-on"' : '') + '>' + label + '</button>';
|
|
1644
1739
|
}
|
|
1740
|
+
// Left, Center, and Right buttons, as `attr`="left" and so on.
|
|
1741
|
+
var ALIGNS = [['left', 'align-left', 'Left'], ['center', 'align-center', 'Center'], ['right', 'align-right', 'Right']];
|
|
1742
|
+
function alignButtons(attr, what) {
|
|
1743
|
+
return ALIGNS.map(function (a) { return button(attr + '="' + a[0] + '"', icon(a[1], a[2]), a[2] + ': ' + what); }).join('');
|
|
1744
|
+
}
|
|
1745
|
+
// A table's width, while text in it is edited: presets in the text row, and a handle on the right edge of the
|
|
1746
|
+
// slide's table that drags it wider or narrower, snapping to the image presets (25-100% of the column, with a
|
|
1747
|
+
// guide) and otherwise writing canvas px rounded to 10. Written as w= on the table's {…} line; Auto takes it out.
|
|
1748
|
+
// Returns what takes the handle away again.
|
|
1749
|
+
var TABLE_WIDTHS = [['', 'Auto'], ['50%', '50%'], ['75%', '75%'], ['100%', '100%']];
|
|
1750
|
+
function tableSize(box, st) {
|
|
1751
|
+
var src0 = parseSrc(st.el.getAttribute('data-src')), lines = sourceLines(src0.file);
|
|
1752
|
+
var w = core.attrValue(core.afterAttrs(lines, src0.start, src0.end, true), 'w');
|
|
1753
|
+
box.insertAdjacentHTML('beforeend', '<span class="dsb-sep"></span>' + alignButtons('data-talign', 'the table in its column') +
|
|
1754
|
+
'<span class="dsb-sep"></span><span class="dsb-label">Width</span>' + TABLE_WIDTHS.map(function (x) {
|
|
1755
|
+
return button('data-tw="' + x[0] + '"', x[1], x[0] ? 'The table ' + x[1] + ' of its column (w=' + x[0] + ')' : 'The table as wide as its content needs, or its column for a table with % columns (no w=)');
|
|
1756
|
+
}).join('') + '<span class="dsb-size" title="Width as written"></span>');
|
|
1757
|
+
var sizeEl = box.querySelector('.dsb-size');
|
|
1758
|
+
var show = function (v) {
|
|
1759
|
+
sizeEl.textContent = v && !TABLE_WIDTHS.some(function (x) { return x[0] === v; }) ? 'w=' + v : '';
|
|
1760
|
+
box.querySelectorAll('[data-tw]').forEach(function (b) { b.classList.toggle('is-on', b.getAttribute('data-tw') === (v || '')); });
|
|
1761
|
+
};
|
|
1762
|
+
show(typeof w === 'string' ? w : '');
|
|
1763
|
+
// Its place in the column: {center} or {right} on its {…} line, as on an image; Left takes them out.
|
|
1764
|
+
var showPlace = function () {
|
|
1765
|
+
var now = st.el.classList.contains('table-right') ? 'right' : st.el.classList.contains('table-center') ? 'center' : 'left';
|
|
1766
|
+
box.querySelectorAll('[data-talign]').forEach(function (b) { b.classList.toggle('is-on', b.getAttribute('data-talign') === now); });
|
|
1767
|
+
};
|
|
1768
|
+
showPlace();
|
|
1769
|
+
var save = function (v) {
|
|
1770
|
+
endEditOverBraces(parseSrc(st.el.getAttribute('data-src')));
|
|
1771
|
+
submit(function () {
|
|
1772
|
+
var src = parseSrc(st.el.getAttribute('data-src')), ls = src && sourceLines(src.file);
|
|
1773
|
+
var p = ls && core.setAfterAttrs(ls, src.start, src.end, { w: v || null }, null, true);
|
|
1774
|
+
if (p) p.file = src.file;
|
|
1775
|
+
return p;
|
|
1776
|
+
});
|
|
1777
|
+
};
|
|
1778
|
+
// The table on the slide (found again after the slide is rebuilt, from the text still being edited in it).
|
|
1779
|
+
var onSlide = function () {
|
|
1780
|
+
if (!st.el.isConnected) {
|
|
1781
|
+
var cur = editing ? editing.el : fmt ? fmt.el : popover ? popover.el : document.activeElement, again = cur && cur.isConnected && cur.closest('table');
|
|
1782
|
+
if (again) st.el = again;
|
|
1783
|
+
}
|
|
1784
|
+
var i = sectionOf(st.el);
|
|
1785
|
+
if (i < 0 || !slides[i] || !st.el.isConnected) return null;
|
|
1786
|
+
// (While text is edited the editor keeps its copy of the slide, whose table may end a line short of the rebuilt
|
|
1787
|
+
// one's, now with its {…} line: then by where it starts.)
|
|
1788
|
+
var mine = parseSrc(st.el.getAttribute('data-src'));
|
|
1789
|
+
return twin(st.el, docSection(i), slides[i].el) || Array.prototype.find.call(slides[i].el.querySelectorAll('table[data-src]'), function (x) {
|
|
1790
|
+
var o = parseSrc(x.getAttribute('data-src'));
|
|
1791
|
+
return mine && o && o.file === mine.file && o.start === mine.start;
|
|
1792
|
+
}) || null;
|
|
1793
|
+
};
|
|
1794
|
+
box.addEventListener('click', function (e) {
|
|
1795
|
+
var pb = e.target.closest && e.target.closest('button[data-talign]');
|
|
1796
|
+
if (pb) {
|
|
1797
|
+
var a = pb.getAttribute('data-talign'), flags = { center: a === 'center', right: a === 'right' };
|
|
1798
|
+
[st.el, onSlide()].forEach(function (x) { if (x) { x.classList.toggle('table-center', flags.center); x.classList.toggle('table-right', flags.right); } });
|
|
1799
|
+
showPlace();
|
|
1800
|
+
place();
|
|
1801
|
+
endEditOverBraces(parseSrc(st.el.getAttribute('data-src')));
|
|
1802
|
+
submit(function () {
|
|
1803
|
+
var src = parseSrc(st.el.getAttribute('data-src')), ls = src && sourceLines(src.file);
|
|
1804
|
+
var p = ls && core.setAfterAttrs(ls, src.start, src.end, flags, null, true);
|
|
1805
|
+
if (p) p.file = src.file;
|
|
1806
|
+
return p;
|
|
1807
|
+
});
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
var b = e.target.closest && e.target.closest('button[data-tw]');
|
|
1811
|
+
if (!b) return;
|
|
1812
|
+
var v = b.getAttribute('data-tw'), t = onSlide();
|
|
1813
|
+
// (Without w=, a table with a % column spans its column, as the build has it.)
|
|
1814
|
+
if (t) { t.style.width = v || (Array.prototype.some.call(t.querySelectorAll('th'), function (th) { return /%$/.test(th.style.width); }) ? '100%' : ''); place(); }
|
|
1815
|
+
show(v);
|
|
1816
|
+
save(v);
|
|
1817
|
+
});
|
|
1818
|
+
var handle = document.createElement('div'), guide = document.createElement('div');
|
|
1819
|
+
handle.className = 'deck-img-handle deck-table-handle';
|
|
1820
|
+
handle.title = 'Drag to resize the table';
|
|
1821
|
+
guide.className = 'deck-img-guide';
|
|
1822
|
+
guide.hidden = true;
|
|
1823
|
+
document.body.appendChild(handle);
|
|
1824
|
+
document.body.appendChild(guide);
|
|
1825
|
+
var shown = null;
|
|
1826
|
+
var place = function () {
|
|
1827
|
+
var t = onSlide();
|
|
1828
|
+
if (shown && shown !== t) shown.classList.remove('deck-table-picked');
|
|
1829
|
+
shown = t;
|
|
1830
|
+
handle.hidden = !t || !deck.classList.contains('is-edit');
|
|
1831
|
+
if (handle.hidden) return;
|
|
1832
|
+
t.classList.add('deck-table-picked');
|
|
1833
|
+
var r = t.getBoundingClientRect();
|
|
1834
|
+
handle.style.left = (r.right - 7) + 'px';
|
|
1835
|
+
handle.style.top = (r.top + r.height / 2 - 7) + 'px';
|
|
1836
|
+
};
|
|
1837
|
+
place();
|
|
1838
|
+
// (After a rebuild, once the editor below has its copy of the slide again.)
|
|
1839
|
+
var later = function () { setTimeout(place, 0); };
|
|
1840
|
+
window.addEventListener('resize', place);
|
|
1841
|
+
document.addEventListener('deck:slides-updated', later);
|
|
1842
|
+
handle.addEventListener('pointerdown', function (e) {
|
|
1843
|
+
var t = onSlide();
|
|
1844
|
+
if (!t) return;
|
|
1845
|
+
// (Not taking the focus from the text being edited.)
|
|
1846
|
+
e.preventDefault();
|
|
1847
|
+
try { handle.setPointerCapture(e.pointerId); } catch (err) { /* drag without capture */ }
|
|
1848
|
+
var k = t.offsetWidth / t.getBoundingClientRect().width, column = t.parentElement, cs = getComputedStyle(column);
|
|
1849
|
+
// A % width is a share of the column's content box.
|
|
1850
|
+
var padL = parseFloat(cs.paddingLeft) || 0, colW = column.clientWidth - padL - (parseFloat(cs.paddingRight) || 0);
|
|
1851
|
+
var w0 = t.offsetWidth, x0 = e.clientX, value = null;
|
|
1852
|
+
var move = function (ev) {
|
|
1853
|
+
var px = w0 + (ev.clientX - x0) * k, pct = px / colW * 100;
|
|
1854
|
+
var preset = PRESETS.find(function (x) { return Math.abs(pct - x) <= 2.5; }) || null;
|
|
1855
|
+
value = preset ? preset + '%' : String(Math.max(60, Math.round(px / 10) * 10));
|
|
1856
|
+
t.style.width = preset ? value : value + 'px';
|
|
1857
|
+
show(value);
|
|
1858
|
+
guide.hidden = !preset;
|
|
1859
|
+
if (preset) {
|
|
1860
|
+
var cr = column.getBoundingClientRect();
|
|
1861
|
+
guide.innerHTML = '<span>' + value + '</span>';
|
|
1862
|
+
guide.style.left = (cr.left + (padL + colW * preset / 100) / k) + 'px';
|
|
1863
|
+
guide.style.top = cr.top + 'px';
|
|
1864
|
+
guide.style.height = cr.height + 'px';
|
|
1865
|
+
}
|
|
1866
|
+
place();
|
|
1867
|
+
};
|
|
1868
|
+
var end = function () {
|
|
1869
|
+
handle.removeEventListener('pointermove', move);
|
|
1870
|
+
handle.removeEventListener('pointerup', up);
|
|
1871
|
+
handle.removeEventListener('pointercancel', end);
|
|
1872
|
+
guide.hidden = true;
|
|
1873
|
+
};
|
|
1874
|
+
var up = function () { end(); if (value !== null) save(value); };
|
|
1875
|
+
handle.addEventListener('pointermove', move);
|
|
1876
|
+
handle.addEventListener('pointerup', up);
|
|
1877
|
+
handle.addEventListener('pointercancel', end);
|
|
1878
|
+
});
|
|
1879
|
+
return function () {
|
|
1880
|
+
window.removeEventListener('resize', place);
|
|
1881
|
+
document.removeEventListener('deck:slides-updated', later);
|
|
1882
|
+
if (shown) shown.classList.remove('deck-table-picked');
|
|
1883
|
+
handle.remove();
|
|
1884
|
+
guide.remove();
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1645
1887
|
function showTextRow(block) {
|
|
1646
1888
|
hideTextRow();
|
|
1647
1889
|
if (!core) return;
|
|
@@ -1666,19 +1908,23 @@
|
|
|
1666
1908
|
var menu = document.createElement('div');
|
|
1667
1909
|
menu.className = 'dsb-menu';
|
|
1668
1910
|
menu.hidden = true;
|
|
1911
|
+
if (st && !st.reason && (!st.whole || st.el.tagName === 'BLOCKQUOTE')) box.innerHTML += '<span class="dsb-sep"></span>' + alignButtons('data-align', st.whole ? 'the quote' : 'the text');
|
|
1669
1912
|
if (st) {
|
|
1670
|
-
box.innerHTML += '<span class="dsb-sep"></span>' + button('data-style-menu' + (st.
|
|
1913
|
+
box.innerHTML += '<span class="dsb-sep"></span>' + button('data-style-menu' + (st.reason ? ' disabled' : ''),
|
|
1671
1914
|
'<span class="dsb-style-label"></span>' + icon('chevron-down', '▾'),
|
|
1672
|
-
st.
|
|
1673
|
-
menu.innerHTML =
|
|
1915
|
+
st.reason || (st.whole ? 'Classes for the whole ' + st.label.split(' ')[0].toLowerCase() : 'Classes for this block'));
|
|
1916
|
+
menu.innerHTML = st.classes.map(function (c) {
|
|
1917
|
+
return button('data-cls="' + c + '"', '<span class="dm-name">' + c + '</span><span class="dm-what">' + (CLASS_WHAT[c] || '') + '</span>', '', st.el.classList.contains(c));
|
|
1918
|
+
}).join('');
|
|
1674
1919
|
}
|
|
1920
|
+
var off = st && !st.reason && st.el.tagName === 'TABLE' ? tableSize(box, st) : null;
|
|
1675
1921
|
bar.appendChild(menu);
|
|
1676
|
-
// The button shows the
|
|
1922
|
+
// The button names what it styles and shows the classes set, so what is set is visible without opening the menu.
|
|
1677
1923
|
var showClasses = function () {
|
|
1678
1924
|
var label = box.querySelector('.dsb-style-label');
|
|
1679
1925
|
if (!label) return;
|
|
1680
|
-
var on =
|
|
1681
|
-
label.textContent = on.length ? on.join(', ') :
|
|
1926
|
+
var on = st.classes.filter(function (c) { return st.el.classList.contains(c); });
|
|
1927
|
+
label.textContent = on.length ? st.label + ': ' + on.join(', ') : st.label;
|
|
1682
1928
|
label.parentNode.classList.toggle('is-set', on.length > 0);
|
|
1683
1929
|
};
|
|
1684
1930
|
showClasses();
|
|
@@ -1697,36 +1943,76 @@
|
|
|
1697
1943
|
menu.style.top = (r.bottom + 6) + 'px';
|
|
1698
1944
|
}
|
|
1699
1945
|
});
|
|
1700
|
-
menu
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
//
|
|
1706
|
-
|
|
1707
|
-
var
|
|
1708
|
-
|
|
1946
|
+
// Sets classes on what the menu styles (`changes`: class → on or off), as one change.
|
|
1947
|
+
// The block's lines as they are when the patch is built: typing since the row opened may have moved them.
|
|
1948
|
+
var srcNow = function () { return parseSrc(st.el.getAttribute('data-src')); };
|
|
1949
|
+
var setClasses = function (changes) {
|
|
1950
|
+
var names = Object.keys(changes);
|
|
1951
|
+
// A block's line (or its lines, joined) with the classes changed, or null when that changes nothing.
|
|
1952
|
+
var onLine = function (line) {
|
|
1953
|
+
var next = line;
|
|
1954
|
+
names.forEach(function (c) { var p = core.setLineClass([next], 1, c, changes[c]); if (p) next = p.text; });
|
|
1955
|
+
return next === line ? null : next;
|
|
1956
|
+
};
|
|
1957
|
+
if (st.whole) {
|
|
1958
|
+
// The list's, table's, or quote's {…} line is after its lines, so the edit in an item or cell carries on.
|
|
1959
|
+
endEditOverBraces(srcNow());
|
|
1960
|
+
submit(function () {
|
|
1961
|
+
var src = srcNow(), lines = src && sourceLines(src.file);
|
|
1962
|
+
var p = lines && core.setAfterAttrs(lines, src.start, src.end, null, changes, st.apart);
|
|
1963
|
+
if (p) p.file = src.file;
|
|
1964
|
+
return p;
|
|
1965
|
+
});
|
|
1966
|
+
} else if (editing) {
|
|
1967
|
+
// The class goes with what is being edited, so the edit (and the selection) carries on; it is saved when the
|
|
1968
|
+
// edit ends. The menu stays open for another class.
|
|
1969
|
+
var t = editing.target, full = onLine(t.before + t.text + t.after);
|
|
1970
|
+
if (full !== null) { t.after = full.slice(t.before.length + t.text.length); liveInline(editing); }
|
|
1709
1971
|
} else if (fmt) {
|
|
1710
|
-
var pending =
|
|
1711
|
-
if (pending) { fmt.line = pending
|
|
1972
|
+
var pending = onLine(fmt.line);
|
|
1973
|
+
if (pending !== null) { fmt.line = pending; liveFormat(fmt); }
|
|
1712
1974
|
} else if (popover && popover.ta.value.indexOf('\n') < 0) {
|
|
1713
|
-
var typed =
|
|
1714
|
-
if (typed) { popover.ta.value = typed
|
|
1975
|
+
var typed = onLine(popover.ta.value);
|
|
1976
|
+
if (typed !== null) { popover.ta.value = typed; livePopover(popover); }
|
|
1715
1977
|
} else {
|
|
1716
|
-
// (A popover
|
|
1978
|
+
// (A popover of several lines: save it first, then the classes on the block's last line.)
|
|
1717
1979
|
closePopover(true);
|
|
1718
1980
|
submit(function () {
|
|
1719
|
-
var lines = sourceLines(src.file);
|
|
1720
|
-
var p =
|
|
1981
|
+
var src = srcNow(), lines = src && sourceLines(src.file), next = lines && onLine(lines[src.end - 1]);
|
|
1982
|
+
var p = next ? core.replaceLine(lines, src.end, next) : null;
|
|
1721
1983
|
if (p) p.file = src.file;
|
|
1722
1984
|
return p;
|
|
1723
1985
|
});
|
|
1724
1986
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1987
|
+
names.forEach(function (c) {
|
|
1988
|
+
st.el.classList.toggle(c, changes[c]);
|
|
1989
|
+
var mb = menu.querySelector('[data-cls="' + c + '"]');
|
|
1990
|
+
if (mb) mb.classList.toggle('is-on', changes[c]);
|
|
1991
|
+
});
|
|
1727
1992
|
showClasses();
|
|
1993
|
+
showAlign();
|
|
1994
|
+
};
|
|
1995
|
+
menu.addEventListener('click', function (e) {
|
|
1996
|
+
var b = e.target.closest && e.target.closest('button[data-cls]');
|
|
1997
|
+
if (!b) return;
|
|
1998
|
+
var changes = {};
|
|
1999
|
+
changes[b.getAttribute('data-cls')] = !b.classList.contains('is-on');
|
|
2000
|
+
setClasses(changes);
|
|
2001
|
+
});
|
|
2002
|
+
// Alignment, for a heading or paragraph, or a quote: Left takes .center and .right off, Center and Right set one.
|
|
2003
|
+
// (A table's place in its column is with its width, in tableSize; a list has none.)
|
|
2004
|
+
var showAlign = function () {
|
|
2005
|
+
var now = st.el.classList.contains('right') ? 'right' : st.el.classList.contains('center') ? 'center' : 'left';
|
|
2006
|
+
box.querySelectorAll('[data-align]').forEach(function (b) { b.classList.toggle('is-on', b.getAttribute('data-align') === now); });
|
|
2007
|
+
};
|
|
2008
|
+
showAlign();
|
|
2009
|
+
box.addEventListener('click', function (e) {
|
|
2010
|
+
var b = e.target.closest && e.target.closest('button[data-align]');
|
|
2011
|
+
if (!b || b.disabled) return;
|
|
2012
|
+
var a = b.getAttribute('data-align');
|
|
2013
|
+
setClasses({ center: a === 'center', right: a === 'right' });
|
|
1728
2014
|
});
|
|
1729
|
-
textRow = { box: box, menu: menu };
|
|
2015
|
+
textRow = { box: box, menu: menu, off: off };
|
|
1730
2016
|
updateTextRow();
|
|
1731
2017
|
showContext(box);
|
|
1732
2018
|
}
|
|
@@ -2414,10 +2700,10 @@
|
|
|
2414
2700
|
new MutationObserver(syncThumbAttrs).observe(deck, { attributes: true });
|
|
2415
2701
|
function bare(el) {
|
|
2416
2702
|
el.removeAttribute('id');
|
|
2417
|
-
[el].concat(Array.prototype.slice.call(el.querySelectorAll('[data-src], [data-src-old], .deck-doc-focus, .deck-img-picked'))).forEach(function (x) {
|
|
2703
|
+
[el].concat(Array.prototype.slice.call(el.querySelectorAll('[data-src], [data-src-old], .deck-doc-focus, .deck-img-picked, .deck-table-picked'))).forEach(function (x) {
|
|
2418
2704
|
x.removeAttribute('data-src');
|
|
2419
2705
|
x.removeAttribute('data-src-old');
|
|
2420
|
-
x.classList.remove('deck-doc-focus', 'deck-img-picked');
|
|
2706
|
+
x.classList.remove('deck-doc-focus', 'deck-img-picked', 'deck-table-picked');
|
|
2421
2707
|
});
|
|
2422
2708
|
return el;
|
|
2423
2709
|
}
|
|
@@ -2868,7 +3154,7 @@
|
|
|
2868
3154
|
// Classes show as chips, columns as dividers, notes after each slide's content, and a numbered rule before each
|
|
2869
3155
|
// slide. Scrolling it picks the slide being read, as in the Markdown view. It is drawn again on each rebuild, but not
|
|
2870
3156
|
// during an edit.
|
|
2871
|
-
var STYLE_CHIPS = ['lead', 'center', 'muted', 'small', 'subtitle', 'meta', 'callout', 'note', 'warn', 'hl', 'badge', 'del'];
|
|
3157
|
+
var STYLE_CHIPS = ['lead', 'center', 'right', 'muted', 'small', 'subtitle', 'meta', 'callout', 'note', 'warn', 'steps', 'hl', 'badge', 'del'];
|
|
2872
3158
|
var docSlide = -1, docSettle = 0;
|
|
2873
3159
|
// A slide's `=== col`, `=== row`, and `=== notes` lines (not those inside fenced code), in order.
|
|
2874
3160
|
var SEPARATOR = /^===\s+([A-Za-z]\w*)(?:\s+\d+(?::\d+)+)?\s*(?:\{.*\})?\s*$/;
|
|
@@ -3011,7 +3297,7 @@
|
|
|
3011
3297
|
Array.prototype.forEach.call(c.querySelectorAll('.deck-doc-focus'), function (x) { x.classList.remove('deck-doc-focus'); });
|
|
3012
3298
|
Array.prototype.forEach.call(c.querySelectorAll('[data-src]'), function (x) {
|
|
3013
3299
|
var on = STYLE_CHIPS.filter(function (k) { return x.classList.contains(k); });
|
|
3014
|
-
if (on.length &&
|
|
3300
|
+
if (on.length && x.tagName !== 'SPAN') x.setAttribute('data-doc-classes', on.join(' '));
|
|
3015
3301
|
});
|
|
3016
3302
|
// A list item with a list under it: its own text becomes a paragraph with its own lines (as in a loose list), so
|
|
3017
3303
|
// the caret can go into it like into any item, without the items under it.
|
|
@@ -4472,6 +4758,20 @@
|
|
|
4472
4758
|
// current slide in each theme (GET /__theme-preview). A setting the page is built with (theme, mode, accent)
|
|
4473
4759
|
// reloads it, and the panel opens again after; "Edit as Markdown" opens the frontmatter itself.
|
|
4474
4760
|
var SETTINGS_KEY = 'deck-embed-settings', themeList = null;
|
|
4761
|
+
// Text size (text_size:, a percentage of the theme's sizes; 100% is no key): the presets, and A-/A+ steps of 5% within
|
|
4762
|
+
// the range the build accepts.
|
|
4763
|
+
var TEXT_SIZES = [80, 90, 100, 110, 120], TEXT_MIN = 50, TEXT_MAX = 200;
|
|
4764
|
+
// The size as the file has it (the same forms parseTextSize in src/parse.ts accepts); 100 when unset or unreadable.
|
|
4765
|
+
function textSizeNow(meta) {
|
|
4766
|
+
var m = /^\s*(\d+(?:\.\d+)?)\s*%?\s*$/.exec((meta || metaNow()).text_size || '');
|
|
4767
|
+
return m ? Number(m[1]) : 100;
|
|
4768
|
+
}
|
|
4769
|
+
function setTextSize(n) {
|
|
4770
|
+
var raw = metaNow().text_size;
|
|
4771
|
+
n = Math.max(TEXT_MIN, Math.min(TEXT_MAX, Math.round(n)));
|
|
4772
|
+
// An unreadable value (a build error) shows as 100%, so picking 100% still takes it out.
|
|
4773
|
+
if (n !== textSizeNow() || (n === 100 && raw)) setting('text_size', n === 100 ? null : n + '%');
|
|
4774
|
+
}
|
|
4475
4775
|
var settingsEl = document.createElement('div');
|
|
4476
4776
|
settingsEl.className = 'deck-settings';
|
|
4477
4777
|
settingsEl.hidden = true;
|
|
@@ -4483,6 +4783,10 @@
|
|
|
4483
4783
|
'<button class="ds-btn" data-mode="light">Light</button><button class="ds-btn" data-mode="dark">Dark</button></span></div>' +
|
|
4484
4784
|
'<div class="ds-row"><label>Accent</label><input type="color" data-accent-pick title="Pick a color"><input type="text" data-meta="accent" placeholder="The theme\u2019s accent" spellcheck="false">' +
|
|
4485
4785
|
'<button class="ds-btn" data-ds="accent-reset" title="Use the theme\u2019s accent">Reset</button></div>' +
|
|
4786
|
+
'<div class="ds-row"><label>Text size</label><span class="ds-seg">' + TEXT_SIZES.map(function (n) {
|
|
4787
|
+
return '<button class="ds-btn" data-text-size="' + n + '"' + (n === 100 ? ' title="The theme\u2019s sizes"' : '') + '>' + n + '%</button>';
|
|
4788
|
+
}).join('') + '</span><span class="ds-seg"><button class="ds-btn" data-ds="text-down" title="Smaller text (5%)" aria-label="Smaller text">A\u2212</button>' +
|
|
4789
|
+
'<button class="ds-btn" data-ds="text-up" title="Larger text (5%)" aria-label="Larger text">A+</button></span><span class="ds-muted" data-text-now></span></div>' +
|
|
4486
4790
|
'<h3>Details</h3>' + [['title', 'Title', 'The first slide\u2019s title'], ['author', 'Author', ''], ['date', 'Date', ''], ['footer', 'Footer', 'Shown at the bottom of each slide']]
|
|
4487
4791
|
.map(function (f) { return '<div class="ds-row"><label>' + f[1] + '</label><input type="' + (f[0] === 'date' ? 'date' : 'text') + '" data-meta="' + f[0] + '" placeholder="' + f[2] + '"></div>'; }).join('') +
|
|
4488
4792
|
'<h3>Slides</h3><label class="ds-check"><input type="checkbox" data-flag="section_slides"> Show section divider slides</label>' +
|
|
@@ -4555,6 +4859,11 @@
|
|
|
4555
4859
|
});
|
|
4556
4860
|
var accent = meta.accent || '';
|
|
4557
4861
|
settingsEl.querySelector('[data-accent-pick]').value = /^#[0-9a-f]{6}$/i.test(accent) ? accent : /^#[0-9a-f]{3}$/i.test(accent) ? accent.replace(/[0-9a-f]/gi, '$&$&') : '#888888';
|
|
4862
|
+
var size = textSizeNow(meta);
|
|
4863
|
+
Array.prototype.forEach.call(settingsEl.querySelectorAll('[data-text-size]'), function (b) { b.classList.toggle('is-on', Number(b.getAttribute('data-text-size')) === size); });
|
|
4864
|
+
settingsEl.querySelector('[data-text-now]').textContent = TEXT_SIZES.indexOf(size) < 0 ? size + '%' : '';
|
|
4865
|
+
settingsEl.querySelector('[data-ds="text-down"]').disabled = size <= TEXT_MIN;
|
|
4866
|
+
settingsEl.querySelector('[data-ds="text-up"]').disabled = size >= TEXT_MAX;
|
|
4558
4867
|
settingsEl.querySelector('[data-flag="section_slides"]').checked = meta.section_slides === 'true';
|
|
4559
4868
|
settingsEl.querySelector('[data-flag="toc"]').checked = meta.toc === 'sidebar';
|
|
4560
4869
|
}
|
|
@@ -4574,6 +4883,8 @@
|
|
|
4574
4883
|
if (act === 'close') closeSettings();
|
|
4575
4884
|
else if (act === 'md') { var main = mainFile(); closeSettings(); setView('md', { file: main, start: 1 }); mdGoto(main, 1); }
|
|
4576
4885
|
else if (act === 'accent-reset') setting('accent', null);
|
|
4886
|
+
else if (act === 'text-down' || act === 'text-up') { var at = textSizeNow(meta); setTextSize(act === 'text-up' ? Math.floor(at / 5) * 5 + 5 : Math.ceil(at / 5) * 5 - 5); }
|
|
4887
|
+
else if (b.hasAttribute('data-text-size')) setTextSize(Number(b.getAttribute('data-text-size')));
|
|
4577
4888
|
else if (b.hasAttribute('data-theme')) { if ((meta.theme || 'default') !== b.getAttribute('data-theme')) setting('theme', core.yamlScalar(b.getAttribute('data-theme'))); }
|
|
4578
4889
|
else if (b.hasAttribute('data-mode')) { var m = b.getAttribute('data-mode'); if ((meta.mode || '') !== m) setting('mode', m || null); }
|
|
4579
4890
|
});
|