Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
Code snippets with Morphing in slides.
Rahul Ravikumarb6a4b2faf6e9
diff --git a/slides/package-lock.json b/slides/package-lock.jsonindex b361ff66..22fddacf 100644--- a/slides/package-lock.json+++ b/slides/package-lock.json@@ -12,6 +12,7 @@"moveable": "^0.53.0","reveal.js": "^5.2.1","selecto": "^1.26.3",+ "shiki": "4.3.1","temml": "^0.13.3"},"devDependencies": {@@ -939,6 +940,106 @@"@daybrush/utils": "^1.4.0"}},+ "node_modules/@shikijs/core": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.3.1.tgz",+ "integrity": "sha512-ANMDxuaPsNMdDC1m4vfvhlDmJweMwkE5XitTwrq2rWHx5jM+dlm4MmHt2PP6t0uejfR77SuhrhJ0zEijIF/uhA==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/primitive": "4.3.1",+ "@shikijs/types": "4.3.1",+ "@shikijs/vscode-textmate": "^10.0.2",+ "@types/hast": "^3.0.4",+ "hast-util-to-html": "^9.0.5"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@shikijs/engine-javascript": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.3.1.tgz",+ "integrity": "sha512-JBItcnPuYq7jVJdZo/vMj94r+szT7XEjHFX+mvFDGSEIbVAXAGyHAHzhbWzpGOwYidCZrErJLLgn2PVeiokHnQ==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/types": "4.3.1",+ "@shikijs/vscode-textmate": "^10.0.2",+ "oniguruma-to-es": "^4.3.6"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@shikijs/engine-oniguruma": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.3.1.tgz",+ "integrity": "sha512-OXyNMzg0pews+msMj4cHeqT4xiYKKvbnn6VbdAXxfoFl3SSx4fJTc8FadECuc5/H9p3BzhNAoAUXKwAu9rWYhg==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/types": "4.3.1",+ "@shikijs/vscode-textmate": "^10.0.2"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@shikijs/langs": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.3.1.tgz",+ "integrity": "sha512-m0l9nsDqgBHvbZbk7A0/kXz/impK3uB/c6rAn6Gpg/uPtdZRQ+alsN/17MU5thb68XTj/4DxkZAotrM0GGSpDQ==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/types": "4.3.1"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@shikijs/primitive": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.3.1.tgz",+ "integrity": "sha512-CXQRQOYy1leqQ8ceTeJdmXv/bsUY++6QyLpXJ94LZAAYj5X2SKRdc5ipguv4NPyGVKItB2PPwUpRNe0Sjh5S1A==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/types": "4.3.1",+ "@shikijs/vscode-textmate": "^10.0.2",+ "@types/hast": "^3.0.4"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@shikijs/themes": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.3.1.tgz",+ "integrity": "sha512-dgpoJ4WqNi2yTmizQHBJ5zcX6j2lE6icN/0yt4l1kkf16jrY/pwPLoTb1ETsWMz0OBLf9ZNvwmxft+cH+N9qSA==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/types": "4.3.1"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@shikijs/types": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.3.1.tgz",+ "integrity": "sha512-CHFxE0jztBIZRHH6gxXE7DXUCFXjReEGxZ/j0rfSLGKZuwp2xBYycEP14875DSa9KLL/6700oxIq6oO6ef9K2g==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/vscode-textmate": "^10.0.2",+ "@types/hast": "^3.0.4"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@shikijs/vscode-textmate": {+ "version": "10.0.2",+ "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz",+ "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==",+ "license": "MIT"+ },"node_modules/@types/estree": {"version": "1.0.9","resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",@@ -946,6 +1047,24 @@"dev": true,"license": "MIT"},+ "node_modules/@types/hast": {+ "version": "3.0.5",+ "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz",+ "integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "*"+ }+ },+ "node_modules/@types/mdast": {+ "version": "4.0.4",+ "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",+ "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "*"+ }+ },"node_modules/@types/node": {"version": "24.13.3","resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.3.tgz",@@ -963,6 +1082,18 @@"dev": true,"license": "MIT"},+ "node_modules/@types/unist": {+ "version": "3.0.3",+ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",+ "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",+ "license": "MIT"+ },+ "node_modules/@ungap/structured-clone": {+ "version": "1.3.3",+ "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.3.tgz",+ "integrity": "sha512-60YRaenCQcVjYEKOcG824+DRGGIQ3VKErcBoAEDJZz5bKIs2ZG+X/H9Nk+Q6EVkwJk5QNApxbrc5QtBSwtrXAg==",+ "license": "ISC"+ },"node_modules/ansi-regex": {"version": "5.0.1","resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",@@ -1033,6 +1164,36 @@"node": ">=6"}},+ "node_modules/ccount": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",+ "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },+ "node_modules/character-entities-html4": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz",+ "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },+ "node_modules/character-entities-legacy": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz",+ "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/cliui": {"version": "6.0.0","resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",@@ -1065,6 +1226,16 @@"dev": true,"license": "MIT"},+ "node_modules/comma-separated-tokens": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",+ "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/croact": {"version": "1.0.4","resolved": "https://registry.npmjs.org/croact/-/croact-1.0.4.tgz",@@ -1140,6 +1311,28 @@"node": ">=0.10.0"}},+ "node_modules/dequal": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/devlop": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz",+ "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==",+ "license": "MIT",+ "dependencies": {+ "dequal": "^2.0.0"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/dijkstrajs": {"version": "1.0.3","resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",@@ -1292,6 +1485,52 @@"node": "6.* || 8.* || >= 10.*"}},+ "node_modules/hast-util-to-html": {+ "version": "9.0.5",+ "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz",+ "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==",+ "license": "MIT",+ "dependencies": {+ "@types/hast": "^3.0.0",+ "@types/unist": "^3.0.0",+ "ccount": "^2.0.0",+ "comma-separated-tokens": "^2.0.0",+ "hast-util-whitespace": "^3.0.0",+ "html-void-elements": "^3.0.0",+ "mdast-util-to-hast": "^13.0.0",+ "property-information": "^7.0.0",+ "space-separated-tokens": "^2.0.0",+ "stringify-entities": "^4.0.0",+ "zwitch": "^2.0.4"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/hast-util-whitespace": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz",+ "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==",+ "license": "MIT",+ "dependencies": {+ "@types/hast": "^3.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/html-void-elements": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz",+ "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/is-fullwidth-code-point": {"version": "3.0.0","resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",@@ -1343,6 +1582,116 @@"node": ">=8"}},+ "node_modules/mdast-util-to-hast": {+ "version": "13.2.1",+ "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz",+ "integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==",+ "license": "MIT",+ "dependencies": {+ "@types/hast": "^3.0.0",+ "@types/mdast": "^4.0.0",+ "@ungap/structured-clone": "^1.0.0",+ "devlop": "^1.0.0",+ "micromark-util-sanitize-uri": "^2.0.0",+ "trim-lines": "^3.0.0",+ "unist-util-position": "^5.0.0",+ "unist-util-visit": "^5.0.0",+ "vfile": "^6.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/micromark-util-character": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz",+ "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==",+ "funding": [+ {+ "type": "GitHub Sponsors",+ "url": "https://github.com/sponsors/unifiedjs"+ },+ {+ "type": "OpenCollective",+ "url": "https://opencollective.com/unified"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "micromark-util-symbol": "^2.0.0",+ "micromark-util-types": "^2.0.0"+ }+ },+ "node_modules/micromark-util-encode": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz",+ "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==",+ "funding": [+ {+ "type": "GitHub Sponsors",+ "url": "https://github.com/sponsors/unifiedjs"+ },+ {+ "type": "OpenCollective",+ "url": "https://opencollective.com/unified"+ }+ ],+ "license": "MIT"+ },+ "node_modules/micromark-util-sanitize-uri": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz",+ "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==",+ "funding": [+ {+ "type": "GitHub Sponsors",+ "url": "https://github.com/sponsors/unifiedjs"+ },+ {+ "type": "OpenCollective",+ "url": "https://opencollective.com/unified"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "micromark-util-character": "^2.0.0",+ "micromark-util-encode": "^2.0.0",+ "micromark-util-symbol": "^2.0.0"+ }+ },+ "node_modules/micromark-util-symbol": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz",+ "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==",+ "funding": [+ {+ "type": "GitHub Sponsors",+ "url": "https://github.com/sponsors/unifiedjs"+ },+ {+ "type": "OpenCollective",+ "url": "https://opencollective.com/unified"+ }+ ],+ "license": "MIT"+ },+ "node_modules/micromark-util-types": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz",+ "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==",+ "funding": [+ {+ "type": "GitHub Sponsors",+ "url": "https://github.com/sponsors/unifiedjs"+ },+ {+ "type": "OpenCollective",+ "url": "https://opencollective.com/unified"+ }+ ],+ "license": "MIT"+ },"node_modules/micromatch": {"version": "4.0.8","resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",@@ -1402,6 +1751,23 @@"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"}},+ "node_modules/oniguruma-parser": {+ "version": "0.12.2",+ "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.2.tgz",+ "integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==",+ "license": "MIT"+ },+ "node_modules/oniguruma-to-es": {+ "version": "4.3.6",+ "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.6.tgz",+ "integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==",+ "license": "MIT",+ "dependencies": {+ "oniguruma-parser": "^0.12.2",+ "regex": "^6.1.0",+ "regex-recursion": "^6.0.2"+ }+ },"node_modules/overlap-area": {"version": "1.1.0","resolved": "https://registry.npmjs.org/overlap-area/-/overlap-area-1.1.0.tgz",@@ -1519,6 +1885,16 @@"node": "^10 || ^12 || >=14"}},+ "node_modules/property-information": {+ "version": "7.2.0",+ "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz",+ "integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/qrcode": {"version": "1.5.4","resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",@@ -1577,6 +1953,30 @@"selecto": "~1.26.3"}},+ "node_modules/regex": {+ "version": "6.1.0",+ "resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz",+ "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==",+ "license": "MIT",+ "dependencies": {+ "regex-utilities": "^2.3.0"+ }+ },+ "node_modules/regex-recursion": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz",+ "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==",+ "license": "MIT",+ "dependencies": {+ "regex-utilities": "^2.3.0"+ }+ },+ "node_modules/regex-utilities": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz",+ "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==",+ "license": "MIT"+ },"node_modules/require-directory": {"version": "2.1.1","resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",@@ -1673,6 +2073,25 @@"dev": true,"license": "ISC"},+ "node_modules/shiki": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/shiki/-/shiki-4.3.1.tgz",+ "integrity": "sha512-oR+qDVi2OjX1tmDpyv+3KviX01KzO6Af+0NNnKnsp9491UEGz2YpxTuJboS/6VhYpTdqzmuJBuiTlrAWWJAssw==",+ "license": "MIT",+ "dependencies": {+ "@shikijs/core": "4.3.1",+ "@shikijs/engine-javascript": "4.3.1",+ "@shikijs/engine-oniguruma": "4.3.1",+ "@shikijs/langs": "4.3.1",+ "@shikijs/themes": "4.3.1",+ "@shikijs/types": "4.3.1",+ "@shikijs/vscode-textmate": "^10.0.2",+ "@types/hast": "^3.0.4"+ },+ "engines": {+ "node": ">=20"+ }+ },"node_modules/source-map-js": {"version": "1.2.1","resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",@@ -1683,6 +2102,16 @@"node": ">=0.10.0"}},+ "node_modules/space-separated-tokens": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",+ "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/string-width": {"version": "4.2.3","resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",@@ -1698,6 +2127,20 @@"node": ">=8"}},+ "node_modules/stringify-entities": {+ "version": "4.0.4",+ "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz",+ "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==",+ "license": "MIT",+ "dependencies": {+ "character-entities-html4": "^2.0.0",+ "character-entities-legacy": "^3.0.0"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/strip-ansi": {"version": "6.0.1","resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",@@ -1750,6 +2193,16 @@"node": ">=8.0"}},+ "node_modules/trim-lines": {+ "version": "3.0.1",+ "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",+ "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }+ },"node_modules/typescript": {"version": "5.8.3","resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",@@ -1771,6 +2224,102 @@"dev": true,"license": "MIT"},+ "node_modules/unist-util-is": {+ "version": "6.0.1",+ "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz",+ "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "^3.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/unist-util-position": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz",+ "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "^3.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/unist-util-stringify-position": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",+ "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "^3.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/unist-util-visit": {+ "version": "5.1.0",+ "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz",+ "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "^3.0.0",+ "unist-util-is": "^6.0.0",+ "unist-util-visit-parents": "^6.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/unist-util-visit-parents": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz",+ "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "^3.0.0",+ "unist-util-is": "^6.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/vfile": {+ "version": "6.0.3",+ "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz",+ "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "^3.0.0",+ "vfile-message": "^4.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },+ "node_modules/vfile-message": {+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz",+ "integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==",+ "license": "MIT",+ "dependencies": {+ "@types/unist": "^3.0.0",+ "unist-util-stringify-position": "^4.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/unified"+ }+ },"node_modules/vite": {"version": "7.3.6","resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz",@@ -1933,6 +2482,16 @@"engines": {"node": ">=6"}+ },+ "node_modules/zwitch": {+ "version": "2.0.4",+ "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",+ "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==",+ "license": "MIT",+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/wooorm"+ }}}}diff --git a/slides/package.json b/slides/package.jsonindex a512931e..09356e7b 100644--- a/slides/package.json+++ b/slides/package.json@@ -14,7 +14,8 @@"moveable": "^0.53.0","reveal.js": "^5.2.1","selecto": "^1.26.3",- "temml": "^0.13.3"+ "temml": "^0.13.3",+ "shiki": "4.3.1"},"devDependencies": {"@gfx/zopfli": "^1.0.15",diff --git a/slides/src/code.ts b/slides/src/code.tsnew file mode 100644index 00000000..fddb7a5a--- /dev/null+++ b/slides/src/code.ts@@ -0,0 +1,117 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors++import { ThemedToken } from 'shiki'+import { Element } from 'hast'+import { BentoDoc, CodeElement } from './model';+import { sanitizeHtml } from './render';+import { getOrCreateHighlighter, HeckelDiff, Insert, State, Token, Delete, Match } from './diff';++let diff: HeckelDiff | undefined = undefined++export type RenderCodeResult = {+ /** The HTML representation when the `CodeElement` has a `grammar` and a `theme` defined. */+ html?: string,+}++/**+ * This returns the HTML representation of the `CodeElement` when the corresponding `grammar` and `theme` is defined.+ * Otherwise, it returns undefined.+ */+export function renderCode(el: CodeElement, doc: BentoDoc) {+ const mid = el.morphId+ let sanitized: string | undefined = undefined+ if (el.grammarAssetId && el.themeAssetId && el.grammarName && el.themeName) {+ const slideIdx = slideIndex(el, doc)+ const diff = getOrCreateDiff(doc)+ const map = diff.computeDiffs(mid)+ const states: State[] = map.get(slideIdx) ?? []+ const highlighter = getOrCreateHighlighter(doc, el.grammarAssetId, el.themeAssetId)+ const html = highlighter.codeToHtml(el.content, {+ // Bad typings here+ lang: el.grammarName as any,+ theme: el.themeName as any,+ includeExplanation: 'scopeName',+ mergeSameStyleTokens: false,+ transformers: [+ {+ // @ts-expect-error : We don't really need col, and lineElement+ span(hast: Element, line: number, col: number, lineElement: Element, token: ThemedToken) {+ // 0-indexed line number+ const lineNumber = line - 1+ // There should always be a matching state, but if we do intermediate renders then we+ // should still gracefully recover.+ const state = findMatchingState(states, lineNumber, token)+ if (state) {+ const id = morphId(state)+ hast.properties['data-flip-id'] = id+ } else {+ console.warn('Inconsistent States:', states, 'Line Number:', lineNumber, 'Token:', token)+ }+ },+ }+ ]+ })+ // sanitizeHtml(...) strips away all the skiki background styles.+ // That part, is great given the background no longer interferes with rendering.+ sanitized = sanitizeHtml(html)+ }+ return {+ html: sanitized+ }+}++function getOrCreateDiff(doc: BentoDoc): HeckelDiff {+ if (!diff) {+ diff = new HeckelDiff(doc)+ }+ return diff+}++/** Computes the slide index for the `CodeElement` being rendered. */+function slideIndex(el: CodeElement, doc: BentoDoc): number {+ const slides = doc.slides+ for (let i = 0; i < slides.length; i += 1) {+ const slide = slides[i]+ const filtered = slide.elements.filter(element => element === el)+ if (filtered && filtered.length > 0) return i+ }+ // Should never really happen+ return -1+}++function findMatchingState(states: State[], lineNumber: number, themedToken: ThemedToken): State | undefined {+ const token = Token.fromThemed(lineNumber, themedToken)+ const state = states.find((state) => {+ const kind = state.kind+ if (kind === 'empty') {+ return false+ } else if (kind === 'insert') {+ const insert = state as Insert+ return insert.token.key() === token.key() && insert.token.lineNumber === token.lineNumber && insert.token.offset === token.offset+ } else if (kind === 'delete') {+ const del = state as Delete+ return del.token.key() === token.key() && del.token.lineNumber === token.lineNumber && del.token.offset === token.offset+ } else if (kind === 'match') {+ const match = state as Match+ return match.current.key() === token.key() && match.current.lineNumber === token.lineNumber && match.current.offset === token.offset+ }+ return false+ })+ return state+}++function morphId(state: State): string {+ let id = ''+ if (state.kind === 'insert') {+ const insert = state as Insert+ id = insert.token.morphId()+ } else if (state.kind === 'delete') {+ const del = state as Delete+ id = del.token.morphId()+ } else if (state.kind === 'match') {+ const match = state as Match+ id = match.current.morphId()+ }+ return id+}diff --git a/slides/src/diff.ts b/slides/src/diff.tsnew file mode 100644index 00000000..f1e1c478--- /dev/null+++ b/slides/src/diff.ts@@ -0,0 +1,368 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors++// https://shiki.style/guide/best-performance#fine-grained-bundle+// When importing Shiki dependencies, be _very careful_ to not import things from the bundled namespaces.+// Otherwise the runtime costs are huge.+import { ThemedToken, createHighlighterCoreSync, HighlighterCore } from "shiki/core"+import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'+import { BentoDoc, Slide } from "./model"++// Preamble++const highlighters: Map<string, HighlighterCore> = new Map()++const engine = createJavaScriptRegexEngine()++/** Also used to render the actual code snippets. */+export function getOrCreateHighlighter(doc: BentoDoc, grammarId: string, themeId: string): HighlighterCore {+ const key = `${themeId}/${grammarId}`+ let highlighter = highlighters.get(key)+ if (!!highlighter) return highlighter+ const assets = doc.assets ?? {}+ const grammar = JSON.parse(assets[grammarId])+ const theme = JSON.parse(assets[themeId])+ highlighter = createHighlighterCoreSync({+ langs: [grammar],+ themes: [theme],+ engine: engine+ })+ // Highlighters are expensive to create. Keep them around and call dispose() when done.+ highlighters.set(key, highlighter)+ return highlighter+}++// The stable token that we can diff between slides.++export class Token {++ /* The morph id. */+ _id: string | undefined++ constructor(+ public readonly content: string,+ public readonly scopes: Array<string>,+ public readonly lineNumber: number,+ public readonly offset: number,+ ) {+ this._id = undefined+ }++ morphId(): string {+ return this._id!+ }++ setMorphId(id: string) {+ this._id = id+ }++ depth(): number {+ return this.scopes.length+ }++ key(): string {+ const json = {+ content: this.content,+ scopes: this.scopes,+ depth: this.depth()+ }+ return JSON.stringify(json)+ }++ static fromThemed(lineNumber: number, token: ThemedToken): Token {+ const content = token.content+ const explanations = token.explanation+ const offset = token.offset+ const scopes = new Set<string>()+ if (explanations) {+ for (const explanation of explanations) {+ for (const scope of explanation.scopes) {+ scopes.add(scope.scopeName)+ }+ }+ }+ return new Token(content, [...scopes], lineNumber, offset)+ }+}++// Diff states++/** Initial diff state. */+export const Empty = { kind: 'empty' }++/** Match */++export type Match = {+ kind: 'match',+ previousIdx: number,+ previous: Token,+ current: Token,+ currentIdx: number,+}++/** Insert */++export type Insert = {+ kind: 'insert',+ token: Token,+ index: number,+}++/** Delete */++export type Delete = {+ kind: 'delete',+ token: Token,+ index: number,+}++/** Discriminated Union of all diff states. */++export type State = typeof Empty | Match | Insert | Delete++/** Diff algorithm. */++export class HeckelDiff {++ /** A counter for morph ids. */+ static count: number = 0++ constructor(private readonly doc: BentoDoc) {++ }++ /**+ * @returns a `Map` of `states` grouped by `slideIdx` for a given morph id (`mid`).+ */+ public computeDiffs(mid: string | undefined): Map<number, State[]> {+ // Output+ let states: Map<number, State[]> = new Map<number, State[]>()+ const slides = this.doc.slides+ // Parse the slides only once+ // Parsed is a 2-D array. First indexed by the slideIndex, then flattened tokens.+ const parsed: Array<Token[]> = []+ for (const slide of slides) {+ const tokens = HeckelDiff.parse(this.doc, slide, mid)+ parsed.push(tokens)+ }+ // For all the tokens in the first code slide, assign them stable ids.+ const firstIdx = HeckelDiff.zipIndex(0, parsed)+ let tokens: Token[] = []+ if (firstIdx) {+ // Reset counts before recomputing stable ids+ HeckelDiff.count = 0+ tokens = parsed[firstIdx]+ for (const token of tokens) {+ token.setMorphId(HeckelDiff.generateMorphId())+ }+ states.set(firstIdx, HeckelDiff.tokensAsState(tokens))+ }+ // Find slide pairs to diff.+ const zipped = HeckelDiff.zip(parsed)+ if (zipped.length > 0) {+ for (const entry of zipped) {+ // Flatten to 1-D to make the diffing easier+ const previous = parsed[entry[0]]+ const current = parsed[entry[1]]+ const [_, statesC] = HeckelDiff.computeDiff(previous, current)+ states.set(entry[1], statesC)+ }+ }+ return states+ }++ static generateMorphId(): string {+ this.count += 1+ return `m-code-token-${this.count}`+ }++ private static parse(doc: BentoDoc, slide: Slide, mid: string|undefined): Token[] {+ const tokens: Token[] = []+ for (const el of slide.elements) {+ if (el.type === 'code' && el.grammarAssetId && el.themeAssetId && el.morphId === mid) {+ const highlighter = getOrCreateHighlighter(doc, el.grammarAssetId, el.themeAssetId)+ // We need to be able to parse the tokens in the *exact* same way in which we would when+ // calling codeToHtml() in the render step. So rather than call `codeToTokens()` or a similar+ // API here, we instead accumulate tokens using a transformer.+ let allTokens: ThemedToken[][] = []+ highlighter.codeToHtml(el.content, {+ lang: el.grammarName as any,+ theme: el.themeName as any,+ includeExplanation: 'scopeName',+ mergeSameStyleTokens: false,+ transformers: [+ {+ tokens(tokens: ThemedToken[][]) {+ allTokens = tokens+ },+ }+ ]+ })+ for (let i = 0; i < allTokens.length; i += 1) {+ const lineThemedTokens = allTokens[i]+ for (const themedToken of lineThemedTokens) {+ tokens.push(Token.fromThemed(i, themedToken))+ }+ }+ }+ }+ return tokens+ }++ private static computeDiff(previous: Token[], current: Token[]): [Array<State>, Array<State>] {+ const anchMapP = HeckelDiff.anchors(previous)+ const anchMapC = HeckelDiff.anchors(current)+ // Symbol Tables+ const statesP: Array<State> = Array(previous.length).fill(Empty)+ const statesC: Array<State> = Array(current.length).fill(Empty)+ // Phase 1: Find unique anchors such that frequency = 1 in both lists.+ // That is a match.+ for (let i = 0; i < current.length; i += 1) {+ const token = current[i]+ if (anchMapP.has(token.key()) && anchMapC.has(token.key())) {+ const anchP = anchMapP.get(token.key())!+ const anchC = anchMapC.get(token.key())!+ const match: Match = {+ kind: 'match',+ previousIdx: anchP.index,+ previous: previous[anchP.index],+ currentIdx: anchC.index,+ current: current[anchC.index]+ }+ // Propagate morph id+ current[anchC.index].setMorphId(previous[anchP.index].morphId())+ statesP[anchP.index] = match+ statesC[anchC.index] = match+ }+ }+ // Phase 2: We found unique anchors.+ // Move forward and find the ones that are matching adjacent to the ones that already matched.+ for (let i = 0; i < statesC.length - 1; i += 1) {+ const state = statesC[i]+ const nextState = statesC[i + 1]+ if (state.kind === 'match' && nextState.kind === 'empty') {+ const matchState = state as Match+ const nextToken: Token | undefined = current[i + 1]+ const nextPreviousToken: Token | undefined = previous[matchState.previousIdx + 1]+ if (nextToken && nextPreviousToken && nextToken.key() == nextPreviousToken.key()) {+ const match: Match = {+ kind: 'match',+ previousIdx: matchState.previousIdx + 1,+ previous: nextPreviousToken,+ current: nextToken,+ currentIdx: i + 1+ }+ // Propagate morph id+ nextToken.setMorphId(nextPreviousToken.morphId())+ statesP[match.previousIdx] = match+ statesC[match.currentIdx] = match+ }+ }+ }+ // Phase 3: Same as Phase 2 but backwards.+ for (let i = statesC.length - 1; i >= 1; i -= 1) {+ const state = statesC[i]+ const priorState = statesC[i - 1]+ if (state.kind === 'match' && priorState.kind === 'empty') {+ const matchState = state as Match+ const priorToken = current[i - 1]+ const priorPreviousToken = previous[matchState.previousIdx - 1]+ if (priorToken && priorPreviousToken && priorToken.key() == priorPreviousToken.key()) {+ const match: Match = {+ kind: 'match',+ previousIdx: matchState.previousIdx - 1,+ previous: priorPreviousToken,+ current: priorToken,+ currentIdx: i - 1+ }+ // Propagate morph id+ priorToken.setMorphId(priorPreviousToken.morphId())+ statesP[match.previousIdx] = match+ statesC[match.currentIdx] = match+ }+ }+ }+ // Phase 4: Final pass.+ // Anything that did not match in:+ // - statesP = Delete+ // - statesC = Insert+ for (let i = 0; i < statesP.length; i += 1) {+ if (statesP[i].kind === 'empty') {+ const del: Delete = {+ kind: 'delete',+ index: i,+ token: previous[i]+ }+ statesP[i] = del+ }+ }+ for (let i = 0; i < statesC.length; i += 1) {+ if (statesC[i].kind === 'empty') {+ const insert: Insert = {+ kind: 'insert',+ index: i,+ token: current[i]+ }+ // For inserts generate a new morph id+ current[i].setMorphId(HeckelDiff.generateMorphId())+ statesC[i] = insert+ }+ }+ return [statesP, statesC]+ }++ private static anchors(tokens: Token[]): Map<string, { frequency: number, index: number }> {+ const map = new Map<string, { frequency: number, index: number }>()+ for (let i = 0; i < tokens.length; i += 1) {+ const token = tokens[i]+ const key = token.key()+ const count = map.get(key) ?? 0+ if (count == 0) {+ map.set(key, { frequency: count + 1, index: i })+ } else {+ map.delete(key)+ }+ }+ return map+ }++ private static zip(parsed: Array<Token[]>): Array<number[]> {+ const pairs: Array<number[]> = []+ let index = 0+ let previousIdx = HeckelDiff.zipIndex(index, parsed)+ if (!previousIdx) return pairs+ let i = previousIdx + 1+ while (i < parsed.length) {+ let currentIdx = HeckelDiff.zipIndex(i, parsed)+ if (!currentIdx) break+ else {+ pairs.push([previousIdx, currentIdx])+ previousIdx = currentIdx+ i = currentIdx + 1+ }+ }+ return pairs+ }++ private static zipIndex(start: number, parsed: Array<Token[]>): number | undefined {+ for (let i = start; i < parsed.length; i += 1) {+ const lineTokens = parsed[i]+ if (lineTokens && lineTokens.length > 0) return i+ }+ return undefined+ }++ private static tokensAsState(tokens: Token[]): State[] {+ const inserts: State[] = []+ for (let i = 0; i < tokens.length; i += 1) {+ const token = tokens[i]+ const insert: Insert = {+ kind: 'insert',+ index: i,+ token: token+ }+ inserts.push(insert)+ }+ return inserts+ }+}diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.tsindex a5a1c4b0..6f6d65c5 100644--- a/slides/src/editor/canvas.ts+++ b/slides/src/editor/canvas.ts@@ -253,7 +253,16 @@ export class SlideCanvas {}, true)this.stage.addEventListener('dblclick', (ev) => {- const textEl = (ev.target as HTMLElement).closest<HTMLElement>('.bento-el-text')+ // Look for TextElement, and then CodeElement+ const selectors = [+ '.bento-el-text',+ '.bento-el-code'+ ]+ var textEl: HTMLElement | null = null+ for (const selector of selectors) {+ textEl = (ev.target as HTMLElement).closest<HTMLElement>(selector)+ if (textEl) break+ }if (textEl) { this.startTextEdit(textEl); return }const td = (ev.target as HTMLElement).closest<HTMLElement>('.bento-el-table td[data-c]')if (td) this.editCellFromTd(td)@@ -1066,6 +1075,10 @@ export class SlideCanvas {// survive verbatim, which is the entire purpose of showing the raw html.inner.innerHTML = sanitizeHtml(model.html)this.editingShowedRaw = true+ } else if (model?.type === 'code' && typeof model.content === 'string') {+ // When editing code, we always treat the content as raw text to preserve formatting.+ inner.innerText = model.content+ this.editingShowedRaw = true}this.editing = nodethis.editingSlideId = this.store.slide.id@@ -1130,6 +1143,8 @@ export class SlideCanvas {node.classList.remove('bento-editing')if (!inner || !id) returninner.contentEditable = 'false'+ // For code, we care about the raw innerText+ const text = inner.innerText// drop the zero-width caret spacers autoformat leaves behindconst html = sanitizeHtml(inner.innerHTML.replace(/\u200B/g, '').replace(/\\([*_~`-])/g, '$1'))const grownH = Math.max(parseFloat(node.style.height) || 0, inner.scrollHeight)@@ -1141,6 +1156,11 @@ export class SlideCanvas {el.html = htmlif (grownH > el.h) el.h = Math.ceil(grownH)})+ } else if (el && el.type === 'code' && (el.content !== text || grownH > el.h)) {+ this.store.commit(() => {+ el.content = text+ if (grownH > el.h) el.h = Math.ceil(grownH)+ })} else if (this.editingShowedRaw) {// Nothing changed, so there is no commit to re-render off the back of —// but startTextEdit replaced the rendered formula (or {{page}} field)diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.tsindex 8646453b..58876e4a 100644--- a/slides/src/editor/editor.ts+++ b/slides/src/editor/editor.ts@@ -7,7 +7,7 @@ import type { Store } from '../store'import {FORMAT_VERSION,MEDIA_EMBED_BUDGET,- applyChartPalette, applyLayout, builtinLayouts, defaultChart, defaultImage, defaultMedia, defaultShape, defaultTable, defaultText,+ applyChartPalette, applyLayout, builtinLayouts, defaultChart, defaultCode, defaultImage, defaultMedia, defaultShape, defaultTable, defaultText,instantiateLayout, isLightBg, layoutElementIds, newDocId, parseDoc, readableInk, syncLinkedChart, uid,paginates, inLinearFlow,type ChartElement, type ShapeKind, type Slide, type SlideElement, type TableElement } from '../model'@@ -273,6 +273,8 @@ export class Editor {t('Add a table — edit cells inline; turn it into a live chart from the panel')),btn(ICONS.chart, t('Chart'), () => this.canvas.insert(defaultChart(applyChartPalette(CHART_PRESETS.bar(), this.store.doc.theme))),t('Add a chart — edit it visually or link it to a table so it updates live')),+ btn(ICONS.code, t('Code'), () => this.canvas.insert(defaultCode({ color: readableInk(this.store.slide.background) }), true),+ t('Add a code snippet')),)const commentB = btn(ICONS.comment, t('Comment'), () => this.canvas.toggleCommentMode(),t('Comment (C) — click an element or a spot on the slide'))diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.tsindex 539fa423..b5a9badc 100644--- a/slides/src/editor/panels.ts+++ b/slides/src/editor/panels.ts@@ -5,7 +5,7 @@// into a single undo checkpoint.import type { Store } from '../store'-import { MEDIA_EMBED_BUDGET, applyChartPalette, defaultChart, internAsset, morphKey, tableStyleFor, uid, type ChartElement, type LineEnding, type MediaElement, type ShapeElement, type Slide, type SlideElement, type TableElement, type TextElement, type TransitionKind } from '../model'+import { MEDIA_EMBED_BUDGET, applyChartPalette, defaultChart, internAsset, morphKey, tableStyleFor, uid, type ChartElement, type LineEnding, type MediaElement, type ShapeElement, type Slide, type SlideElement, type TableElement, type TextElement, type TransitionKind, type CodeElement } from '../model'import { resolveAsset } from '../render'import { measureElement } from '../measure'import { isMacOS } from '../screens'@@ -435,7 +435,7 @@ export class PropsPanel {}private buildElementPanel(el: SlideElement) {- this.section(t({ text: 'Text', shape: 'Shape', image: 'Image', svg: 'Diagram', chart: 'Chart', table: 'Table', media: el.type === 'media' && el.kind === 'audio' ? 'Audio' : 'Video' }[el.type]))+ this.section(t({ text: 'Text', shape: 'Shape', image: 'Image', svg: 'Diagram', chart: 'Chart', table: 'Table', code: 'Code', media: el.type === 'media' && el.kind === 'audio' ? 'Audio' : 'Video' }[el.type]))this.opsRow([el])// Lead with the element's OWN controls — the reason it was selected —@@ -446,6 +446,7 @@ export class PropsPanel {if (el.type === 'chart') this.buildChartProps(el)if (el.type === 'table') this.buildTableProps(el)if (el.type === 'media') this.buildMediaProps(el)+ if (el.type === 'code') this.buildCodeProps(el)this.section(t('Position & size'))const geo = document.createElement('div')@@ -1102,6 +1103,62 @@ export class PropsPanel {input.click()}+ private embedGrammar(el: CodeElement) {+ const input = document.createElement('input')+ input.type = 'file'+ input.accept = '.json'+ input.addEventListener('change', () => {+ const file = input.files?.[0]+ if (!file) return+ const reader = new FileReader()+ reader.onload = () => {+ const contents = JSON.parse(String(reader.result))+ const name = contents['name']+ const assetId = `grammar:${name}`+ this.store.commit(() => {+ const doc = this.store.doc+ doc.assets = { ...(doc.assets ?? {}), [assetId]: JSON.stringify(contents) }+ this.mutate(el.id, (e) => {+ const el = e as CodeElement+ el.grammarName = name+ el.grammarAssetId = assetId+ }, true)+ })+ this.toast(`"Grammar ${name}" embedded into this file`)+ }+ reader.readAsText(file)+ })+ input.click()+ }++ private embedTheme(el: CodeElement) {+ const input = document.createElement('input')+ input.type = 'file'+ input.accept = '.json'+ input.addEventListener('change', () => {+ const file = input.files?.[0]+ if (!file) return+ const reader = new FileReader()+ reader.onload = () => {+ const contents = JSON.parse(String(reader.result))+ const name = contents['name']+ const assetId = `theme:${name}`+ this.store.commit(() => {+ const doc = this.store.doc+ doc.assets = { ...(doc.assets ?? {}), [assetId]: JSON.stringify(contents) }+ this.mutate(el.id, (e) => {+ const el = e as CodeElement+ el.themeAssetId = assetId+ el.themeName = name+ }, true)+ })+ this.toast(`"Theme ${name}" embedded into this file`)+ }+ reader.readAsText(file)+ })+ input.click()+ }+private buildShapeProps(el: ShapeElement) {this.section(t('Fill & stroke'))const grad = el.fillGradient@@ -1740,6 +1797,123 @@ export class PropsPanel {}}+ private buildCodeProps(el: CodeElement) {+ this.section(t('Source Code'))+ const status = document.createElement('p')+ status.className = 'ed-hint'+ this.host.appendChild(status)+ // Font Size+ // Shown in POINTS (the unit office users know); the model stores slide-space+ // px. 1pt = 4/3 px at the slide's 96dpi space, so 32px = 24pt exactly.+ this.row('Size (pt)', this.number(Math.round(el.fontSize * 0.75 * 10) / 10, 1, (v, fin) =>+ this.mutate(el.id, (e) => {+ (e as CodeElement).fontSize = Math.round(Math.max(v, 3) * (4 / 3) * 100) / 100+ }, fin)))+ // Alignment+ this.row('Align', this.select(['left', 'center', 'right'], el.align, (v) =>+ this.mutate(el.id, (e) => { (e as CodeElement).align = v as CodeElement['align'] }, true)))+ // V-Alignment+ this.row('V-align', this.select(['top', 'middle', 'bottom'], el.valign, (v) =>+ this.mutate(el.id, (e) => { (e as CodeElement).valign = v as CodeElement['valign'] }, true)))+ // Line height+ this.row('Line height', this.number(el.lineHeight, 0.05, (v, fin) =>+ this.mutate(el.id, (e) => { (e as CodeElement).lineHeight = Math.max(v, 0.5) }, fin)))+ const assets = this.store.doc.assets ?? {}+ const grammar = el.grammarAssetId ? assets[el.grammarAssetId] : ''+ const theme = el.themeAssetId ? assets[el.themeAssetId] : ''+ if (!grammar) status.textContent = t('Pick a TextMate Language')+ else if (!theme) status.textContent = t('Pick a TextMate Theme')+ else status.textContent = t('Ready')+ // Pickers+ this.grammarSelect(el)+ this.themeSelect(el)+ // Grammar+ const embedGrammar = document.createElement('button')+ embedGrammar.className = 'ed-btn ed-btn-block'+ embedGrammar.textContent = t('+ Add TextMate Grammar')+ embedGrammar.title = t('Bundle a TextMate Grammar and use it here')+ embedGrammar.addEventListener('click', () => this.embedGrammar(el))+ this.host.appendChild(embedGrammar)+ // Theme+ const embedTheme = document.createElement('button')+ embedTheme.className = 'ed-btn ed-btn-block'+ embedTheme.textContent = t('+ Add TextMate Theme')+ embedTheme.title = t('Bundle a TextMate Theme and use it here')+ embedTheme.addEventListener('click', () => this.embedTheme(el))+ this.host.appendChild(embedTheme)+ this.host.appendChild(status)+ }++ private grammarSelect(el: CodeElement) {+ const assets = this.store.doc.assets ?? {}+ const keys = Object.keys(assets)+ const grammars = keys.filter(k => k.startsWith('grammar:'))+ if (grammars && grammars.length > 0) {+ const sel = document.createElement('select')+ const add = (label: string, value: string, selected: boolean) => {+ const o = document.createElement('option')+ o.value = value+ o.textContent = label+ o.selected = selected+ sel.appendChild(o)+ return o+ }+ // Placeholder+ add('<select grammar>', '', !el.grammarAssetId)+ for (const grammar of grammars) {+ let matched = false+ if (el.grammarAssetId === grammar) matched = true+ const name = grammar.replace('grammar:', '')+ add(name, grammar, matched)+ }+ sel.addEventListener('change', () => {+ this.mutate(el.id, (e) => {+ // value is the actual grammar assetId+ const value = sel.value+ const el = e as CodeElement+ el.grammarName = value.replace('grammar:', '')+ el.grammarAssetId = value+ }, true)+ })+ this.row('Grammar', sel)+ }+ }++ private themeSelect(el: CodeElement) {+ const assets = this.store.doc.assets ?? {}+ const keys = Object.keys(assets)+ const themes = keys.filter(k => k.startsWith('theme:'))+ if (themes && themes.length > 0) {+ const sel = document.createElement('select')+ const add = (label: string, value: string, selected: boolean) => {+ const o = document.createElement('option')+ o.value = value+ o.textContent = label+ o.selected = selected+ sel.appendChild(o)+ return o+ }+ // Placeholder+ add('<select theme>', '', !el.themeAssetId)+ for (const theme of themes) {+ let matched = false+ if (el.themeAssetId === theme) matched = true+ const name = theme.replace('theme:', '')+ add(name, theme, matched)+ }+ sel.addEventListener('change', () => {+ this.mutate(el.id, (e) => {+ // value is the actual theme assetId+ const value = sel.value+ const el = e as CodeElement+ el.themeName = value.replace('theme:', '')+ el.themeAssetId = value+ }, true)+ })+ this.row('Theme', sel)+ }+ }+// --- element ops --------------------------------------------------------------private opsRow(els: SlideElement[]) {diff --git a/slides/src/model.ts b/slides/src/model.tsindex ca811168..f0f7f4f5 100644--- a/slides/src/model.ts+++ b/slides/src/model.ts@@ -141,6 +141,28 @@ export interface TextElement extends ElementBase {placeholder?: string}+export interface CodeElement extends ElementBase {+ type: 'code'+ /** Subset of properties of TextElement. */+ fontSize: number+ fontFamily: string+ align: 'left' | 'center' | 'right'+ valign: 'top' | 'middle' | 'bottom'+ lineHeight: number+ /** Determines the color of the code snippet prior to a themeId getting picked. */+ color: string+ /** The raw code snippets. */+ content: string+ /** The asset id of the grammar to use. */+ grammarAssetId?: string+ /** The name of the grammar */+ grammarName?: string+ /** The asset id of the theme to use. */+ themeAssetId?: string+ /** The name of the theme. */+ themeName?: string+}+export type ShapeKind = 'rect' | 'ellipse' | 'triangle' | 'arrow' | 'line' | 'path'/** Linear gradient fill. Colors are any CSS color, including rgba(). */@@ -300,7 +322,7 @@ export interface MediaElement extends ElementBase {}export type SlideElement =- | TextElement | ShapeElement | ImageElement | SvgElement | ChartElement | TableElement | MediaElement+ | TextElement | ShapeElement | ImageElement | SvgElement | ChartElement | TableElement | MediaElement | CodeElement/*** A review comment thread. Editor-only metadata: never rendered while@@ -521,6 +543,9 @@ export const uid = (prefix = 'el') =>export const FONT_STACK ="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"+export const MONOSPACE_FONT_STACK =+ "ui-monospace, 'SFMono-Regular', 'Berkeley Mono', 'Menlo', 'Consolas', monospace"+/*** An element's effective morph key: the `morphId` override when set, else its* own `id`. THE single definition — render.ts stamps it into `data-flip-id`,@@ -688,6 +713,23 @@ export function defaultChart(option: Record<string, unknown>, partial: Partial<C}}+export function defaultCode(partial: Partial<CodeElement> = {}): CodeElement {+ return {+ id: uid('code'),+ type: 'code',+ x: 235, y: 95, w: 800, h: 520,+ rotation: 0, opacity: 1,+ fontSize: 32,+ fontFamily: MONOSPACE_FONT_STACK,+ color: '#1E2A3A',+ align: 'left',+ valign: 'middle',+ lineHeight: 1.25,+ content: 'Double-click to edit',+ ...partial,+ }+}+const DEFAULT_TABLE_STYLE: TableStyle = {headerBg: '#1E2A3A',headerColor: '#FFFFFF',diff --git a/slides/src/render.ts b/slides/src/render.tsindex 426c8671..ad434f9e 100644--- a/slides/src/render.ts+++ b/slides/src/render.ts@@ -8,6 +8,7 @@ import type { BentoDoc, ShapeElement, Slide, SlideElement, SvgElement, TableElemimport { morphKey, paginates } from './model'import { chartSnapshotSvg } from './charts'import temml from 'temml'+import { renderCode } from './code'const SVG_NS = 'http://www.w3.org/2000/svg'@@ -428,7 +429,7 @@ function tagSymbols(mathml: string): string {if (!txt) continueconst n = seen.get(txt) ?? 0seen.set(txt, n + 1)- ;(leaf as HTMLElement).dataset.sym = `${txt}#${n}`+ ; (leaf as HTMLElement).dataset.sym = `${txt}#${n}`}return tpl.innerHTML}@@ -1154,6 +1155,29 @@ export function renderElement(el: SlideElement, doc: BentoDoc, opts: RenderOpts}break}+ case 'code': {+ node.style.display = 'flex'+ node.style.flexDirection = 'column'+ node.style.justifyContent = VALIGN[el.valign]+ const inner = document.createElement('pre')+ inner.className = 'bento-text-inner'+ inner.dir = 'auto'+ inner.style.fontSize = `${el.fontSize}px`+ inner.style.fontFamily = el.fontFamily || doc.theme.fontFamily+ inner.style.textAlign = el.align+ inner.style.lineHeight = String(el.lineHeight)+ inner.style.width = '100%'+ inner.style.color = el.color+ const result = renderCode(el, doc)+ if (result.html) {+ inner.innerHTML = result.html+ } else {+ // Fallback to unformatted text+ inner.innerText = el.content+ }+ node.appendChild(inner)+ break+ }}// Every element type funnels through here, so this is the one place that// sees author markup after it has been built into DOM.diff --git a/slides/src/styles.css b/slides/src/styles.cssindex c79b3fcd..17b5177c 100644--- a/slides/src/styles.css+++ b/slides/src/styles.css@@ -477,11 +477,19 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is.bento-slide { position: relative; overflow: hidden; }.bento-el { position: absolute; contain: layout style; }-.bento-el-text .bento-text-inner {++.bento-el-text,+.bento-el-code+ .bento-text-inner {overflow-wrap: break-word;outline: none;cursor: default;}++.bento-el-code span {+ display: inline-flex;+}+/* A hidden slide is still an ordinary, editable slide — it is just out of theshow. Dimmed rather than greyed out, and the number struck through, so thesidebar reads as "this one will be skipped" without looking broken. */@@ -1087,7 +1095,7 @@ a.ed-btn { text-decoration: none; } /* the update block's "What's new" link is/* inline code spans inside text elements — editor, present and print alike */.bento-el-text code {- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;+ font-family: ui-monospace, SFMono-Regular, Berkeley Mono, Menlo, Consolas, monospace;font-size: 0.9em;background: rgb(127 127 127 / 0.16);padding: 0 0.28em;