|
1 | | -// https://lib.presenta.cc v0.1.6 - BSD-3-Clause License - Copyright 2020 Fabio Franchino |
| 1 | +// https://lib.presenta.cc v0.1.7 - BSD-3-Clause License - Copyright 2020 Fabio Franchino |
2 | 2 | (function (global, factory) { |
3 | 3 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
4 | 4 | typeof define === 'function' && define.amd ? define(factory) : |
5 | 5 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Presenta = factory()); |
6 | 6 | }(this, (function () { 'use strict'; |
7 | 7 |
|
8 | | - var version = "0.1.6"; |
| 8 | + var version = "0.1.7"; |
9 | 9 |
|
10 | 10 | function styleInject(css, ref) { |
11 | 11 | if ( ref === void 0 ) ref = {}; |
|
759 | 759 | }); |
760 | 760 | }; |
761 | 761 |
|
| 762 | + const parser = new DOMParser(); |
| 763 | + |
| 764 | + const inferHTML = (ob, base) => { |
| 765 | + const dom = parser.parseFromString(ob.text, 'text/html').body; |
| 766 | + const images = dom.querySelectorAll('img'); |
| 767 | + const imagesArr = Array.from(images); |
| 768 | + imagesArr.forEach(img => { |
| 769 | + const src = img.getAttribute('src'); |
| 770 | + var r = new RegExp('^(?:[a-z]+:)?//', 'i'); |
| 771 | + |
| 772 | + if (!r.test(src)) { |
| 773 | + img.src = base + src; |
| 774 | + } |
| 775 | + }); |
| 776 | + ob.text = dom.innerHTML; |
| 777 | + }; |
| 778 | + |
| 779 | + const infer = (ob, field, base) => { |
| 780 | + const val = ob[field]; |
| 781 | + |
| 782 | + if (val && base) { |
| 783 | + var r = new RegExp('^(?:[a-z]+:)?//', 'i'); |
| 784 | + |
| 785 | + if (!r.test(val)) { |
| 786 | + ob[field] = base + val; |
| 787 | + } |
| 788 | + } |
| 789 | + }; |
| 790 | + |
| 791 | + const baseurls = []; |
| 792 | + |
| 793 | + const baseurl = function (rootElement, router, ctrlConfig, projectConfig) {}; |
| 794 | + |
| 795 | + const inferBlock = (block, base) => { |
| 796 | + const blk = baseurls.find(d => d.type === block.type); |
| 797 | + |
| 798 | + if (blk) { |
| 799 | + if (blk.html) { |
| 800 | + inferHTML(block, base); |
| 801 | + } else { |
| 802 | + infer(block, blk.field, base); |
| 803 | + } |
| 804 | + } |
| 805 | + }; |
| 806 | + |
| 807 | + baseurl.run = (config, pconf) => { |
| 808 | + return new Promise((resolve, reject) => { |
| 809 | + const base = pconf; |
| 810 | + config.scenes.forEach(scene => { |
| 811 | + scene.blocks.forEach(block => { |
| 812 | + const blks = block.type === 'group' ? block.blocks : [block]; |
| 813 | + blks.forEach(block => { |
| 814 | + inferBlock(block, base); |
| 815 | + }); |
| 816 | + }); |
| 817 | + }); |
| 818 | + resolve(); |
| 819 | + }); |
| 820 | + }; |
| 821 | + |
| 822 | + const addBaseurl = ob => { |
| 823 | + baseurls.push(ob); |
| 824 | + }; |
| 825 | + |
| 826 | + utils.io.addBaseurl = addBaseurl; |
| 827 | + |
762 | 828 | const controllers = { |
763 | 829 | autoplay, |
764 | 830 | keyboard, |
|
777 | 843 | limitswitch, |
778 | 844 | sync, |
779 | 845 | sender, |
780 | | - cache |
| 846 | + cache, |
| 847 | + baseurl |
781 | 848 | }; |
782 | 849 |
|
783 | 850 | const add = (type, module, override) => { |
|
999 | 1066 | var css_248z$B = ".textVar__title{--textPadding:3rem;--textAlign:center;--textListAlign:center;--textFlexAlign:center;--textFlexJustify:center;--textSize:2.5rem}.textVar__text{--textAlign:left;--textListAlign:left;--textFlexJustify:flex-start;--textSize:1rem}.textVar__section,.textVar__text{--textPadding:2rem;--textFlexAlign:flex-start}.textVar__section{--textAlign:right;--textListAlign:right;--textFlexJustify:flex-end;--textSize:2rem}.textVar__mention{--textAlign:left;--textListAlign:left;--textFlexJustify:flex-start;--textSize:1.5rem}.textVar__mention,.textVar__suggest{--textPadding:2rem;--textFlexAlign:flex-end}.textVar__suggest{--textAlign:center;--textListAlign:center;--textFlexJustify:center;--textSize:0.8rem}.textStyle__a{--textboxpadding:0;--textboxbackcolor:var(--colorFore);--textboxradius:0;--textboxborder:0;--textboxshadow:0 0 0 var(--colorAccent);--textboxcolor:var(--colorBack)}"; |
1000 | 1067 | styleInject(css_248z$B); |
1001 | 1068 |
|
1002 | | - var css_248z$C = ":root{--textPadding:0;--textAlign:center;--textListAlign:left;--textFlexAlign:center;--textFlexJustify:center;--textSize:1rem}.style_text__3T1cl{color:var(--colorFore)}.style_inner__11UJC,.style_text__3T1cl{width:100%;height:100%;position:relative}.style_pretext__cLjqD{display:flex;width:100%;height:100%;align-items:var(--textFlexAlign);justify-content:var(--textFlexJustify)}.style_textbox__1Vb-V{padding:var(--textboxpadding);text-align:var(--textAlign);font-size:var(--textSize);color:var(--textboxcolor);--backmark:var(--colorAccent);--foremark:var(--colorBack);--textaccentcolor:var(--colorAccent);font-family:var(--fontText)}.style_itext__jz90o{border:var(--textboxborder) solid var(--colorAccent);padding:var(--textPadding);border-radius:var(--textboxradius);box-shadow:var(--textboxshadow);background-color:var(--textboxbackcolor)}.style_itext__jz90o img{object-fit:contain;height:4em;vertical-align:middle}.style_itext__jz90o mark{background-color:var(--backmark);color:var(--foremark);padding:.5rem;display:inline-block}.style_itext__jz90o high{color:var(--textaccentcolor)}.style_itext__jz90o bord{border:8px solid var(--backmark);padding:0 .5rem}.style_itext__jz90o a{color:var(--textaccentcolor);text-decoration:underline}.style_itext__jz90o blockquote{font-size:2em;font-weight:400;font-style:italic}.style_itext__jz90o blockquote,.style_itext__jz90o h1,.style_itext__jz90o h2,.style_itext__jz90o h3,.style_itext__jz90o h4,.style_itext__jz90o h5,.style_itext__jz90o h6,.style_itext__jz90o p,.style_itext__jz90o ul{margin:0}.style_itext__jz90o h1 b,.style_itext__jz90o h1 strong,.style_itext__jz90o h2 b,.style_itext__jz90o h2 strong,.style_itext__jz90o h3 b,.style_itext__jz90o h3 strong,.style_itext__jz90o h4 b,.style_itext__jz90o h4 strong,.style_itext__jz90o h5 b,.style_itext__jz90o h5 strong,.style_itext__jz90o h6 b,.style_itext__jz90o h6 strong{color:var(--textaccentcolor)}.style_itext__jz90o ol,.style_itext__jz90o ul{font-size:1.5em;line-height:1.1em;text-align:var(--textListAlign);margin:0;list-style-type:none;counter-reset:li;padding:.5rem 0}.style_itext__jz90o li{list-style-position:inside;margin-bottom:2px;padding:.25em .25em .25em .8em}.style_itext__jz90o ul li:before{content:\"\\2013\";display:inline-block;width:.8em;margin-left:-.8em}.style_itext__jz90o ol li:before{counter-increment:li;content:\".\" counter(li);display:inline-block;width:1.1em;margin-left:-1.3em;margin-right:.2em;text-align:right;direction:rtl}.style_itext__jz90o li p{display:inline}.style_itext__jz90o code,.style_itext__jz90o pre{text-align:left;margin:0}.style_itext__jz90o h1,.style_itext__jz90o h2,.style_itext__jz90o h3,.style_itext__jz90o h4,.style_itext__jz90o h5,.style_itext__jz90o h6{font-family:var(--fontHeading);padding:.5rem 0}.style_itext__jz90o h1{font-size:2em}.style_itext__jz90o h2{font-size:1.5em}.style_itext__jz90o h3{font-size:1.17em}.style_itext__jz90o h4{font-size:1em}.style_itext__jz90o h5{font-size:.83em}.style_itext__jz90o h6{font-size:.67em}.style_itext__jz90o p{padding:.5rem 0}.style_itext__jz90o hr{border:1px solid var(--colorFore);margin:.5rem 0}.style_itext__jz90o h1:first-child,.style_itext__jz90o h1:last-child,.style_itext__jz90o h2:first-child,.style_itext__jz90o h2:last-child,.style_itext__jz90o h3:first-child,.style_itext__jz90o h3:last-child{padding:0}.style_itext__jz90o table{width:100%}.style_itext__jz90o tr{padding:0}.style_itext__jz90o td,.style_itext__jz90o th{padding:.5rem;border-bottom:1px solid var(--colorFore)}.style_itext__jz90o small{font-size:.6em}"; |
| 1069 | + var css_248z$C = ":root{--textPadding:0;--textAlign:center;--textListAlign:left;--textFlexAlign:center;--textFlexJustify:center;--textSize:1rem;--textWidth:auto}.style_text__3T1cl{color:var(--colorFore)}.style_inner__11UJC,.style_text__3T1cl{width:100%;height:100%;position:relative}.style_pretext__cLjqD{display:flex;width:100%;height:100%;align-items:var(--textFlexAlign);justify-content:var(--textFlexJustify)}.style_textbox__1Vb-V{padding:var(--textboxpadding);text-align:var(--textAlign);font-size:var(--textSize);color:var(--textboxcolor);--backmark:var(--colorAccent);--foremark:var(--colorBack);--textaccentcolor:var(--colorAccent);font-family:var(--fontText);width:var(--textWidth)}.style_itext__jz90o{border:var(--textboxborder) solid var(--colorAccent);padding:var(--textPadding);border-radius:var(--textboxradius);box-shadow:var(--textboxshadow);background-color:var(--textboxbackcolor)}.style_itext__jz90o img{object-fit:contain;height:4em;vertical-align:middle}.style_itext__jz90o mark{background-color:var(--backmark);color:var(--foremark);padding:.5rem;display:inline-block}.style_itext__jz90o high{color:var(--textaccentcolor)}.style_itext__jz90o bord{border:8px solid var(--backmark);padding:0 .5rem}.style_itext__jz90o a{color:var(--textaccentcolor);text-decoration:underline}.style_itext__jz90o blockquote{font-size:2em;font-weight:400;font-style:italic}.style_itext__jz90o blockquote,.style_itext__jz90o h1,.style_itext__jz90o h2,.style_itext__jz90o h3,.style_itext__jz90o h4,.style_itext__jz90o h5,.style_itext__jz90o h6,.style_itext__jz90o p,.style_itext__jz90o ul{margin:0}.style_itext__jz90o h1 b,.style_itext__jz90o h1 strong,.style_itext__jz90o h2 b,.style_itext__jz90o h2 strong,.style_itext__jz90o h3 b,.style_itext__jz90o h3 strong,.style_itext__jz90o h4 b,.style_itext__jz90o h4 strong,.style_itext__jz90o h5 b,.style_itext__jz90o h5 strong,.style_itext__jz90o h6 b,.style_itext__jz90o h6 strong{color:var(--textaccentcolor)}.style_itext__jz90o ol,.style_itext__jz90o ul{font-size:1.5em;line-height:1.1em;text-align:var(--textListAlign);margin:0;list-style-type:none;counter-reset:li;padding:.5rem 0}.style_itext__jz90o li{list-style-position:inside;margin-bottom:2px;padding:.25em .25em .25em .8em}.style_itext__jz90o ul li:before{content:\"\\2013\";display:inline-block;width:.8em;margin-left:-.8em}.style_itext__jz90o ol li:before{counter-increment:li;content:\".\" counter(li);display:inline-block;width:1.1em;margin-left:-1.3em;margin-right:.2em;text-align:right;direction:rtl}.style_itext__jz90o li p{display:inline}.style_itext__jz90o code,.style_itext__jz90o pre{text-align:left;margin:0}.style_itext__jz90o h1,.style_itext__jz90o h2,.style_itext__jz90o h3,.style_itext__jz90o h4,.style_itext__jz90o h5,.style_itext__jz90o h6{font-family:var(--fontHeading);padding:.5rem 0}.style_itext__jz90o h1{font-size:2em}.style_itext__jz90o h2{font-size:1.5em}.style_itext__jz90o h3{font-size:1.17em}.style_itext__jz90o h4{font-size:1em}.style_itext__jz90o h5{font-size:.83em}.style_itext__jz90o h6{font-size:.67em}.style_itext__jz90o p{padding:.5rem 0}.style_itext__jz90o hr{border:1px solid var(--colorFore);margin:.5rem 0}.style_itext__jz90o h1:first-child,.style_itext__jz90o h1:last-child,.style_itext__jz90o h2:first-child,.style_itext__jz90o h2:last-child,.style_itext__jz90o h3:first-child,.style_itext__jz90o h3:last-child{padding:0}.style_itext__jz90o table{width:100%}.style_itext__jz90o tr{padding:0}.style_itext__jz90o td,.style_itext__jz90o th{padding:.5rem;border-bottom:1px solid var(--colorFore)}.style_itext__jz90o small{font-size:.6em}"; |
1003 | 1070 | var css$8 = {"text":"style_text__3T1cl","inner":"style_inner__11UJC","pretext":"style_pretext__cLjqD","textbox":"style_textbox__1Vb-V","itext":"style_itext__jz90o"}; |
1004 | 1071 | styleInject(css_248z$C); |
1005 | 1072 |
|
|
1075 | 1142 |
|
1076 | 1143 | text.init = () => { |
1077 | 1144 | utils.addGlob(['textVar', 'textStyle']); |
1078 | | - utils.addProp(['textPadding', 'textAlign', 'textFlexAlign', 'textFlexJustify']); |
| 1145 | + utils.addProp(['textPadding', 'textAlign', 'textFlexAlign', 'textFlexJustify', 'textWidth']); |
| 1146 | + if (utils.io.addBaseurl) utils.io.addBaseurl({ |
| 1147 | + type: 'text', |
| 1148 | + html: true |
| 1149 | + }); |
1079 | 1150 | if (utils.io.addMarkdown) utils.io.addMarkdown({ |
1080 | 1151 | type: 'text', |
1081 | 1152 | field: 'text' |
|
1160 | 1231 |
|
1161 | 1232 | image.init = () => { |
1162 | 1233 | utils.addProp(['imagePadding', 'imageBorder', 'imageShadow', 'imageSize', 'imagePosition']); |
1163 | | - utils.io.addPreload({ |
| 1234 | + if (utils.io.addPreload) utils.io.addPreload({ |
1164 | 1235 | type: 'image', |
1165 | 1236 | field: 'url', |
1166 | 1237 | as: 'image' |
1167 | 1238 | }); |
| 1239 | + if (utils.io.addBaseurl) utils.io.addBaseurl({ |
| 1240 | + type: 'image', |
| 1241 | + field: 'url' |
| 1242 | + }); |
1168 | 1243 | }; |
1169 | 1244 |
|
1170 | 1245 | var css_248z$F = ":root{--videoSize:cover;--videoPosition:center}.style_video__1qbdJ{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.style_video__1qbdJ video{width:100%;height:100%;object-fit:var(--videoSize);object-position:var(--videoPosition)}"; |
|
1256 | 1331 |
|
1257 | 1332 | video.init = () => { |
1258 | 1333 | utils.addProp(['videoSize', 'videoPosition']); |
1259 | | - utils.io.addPreload({ |
| 1334 | + if (utils.io.addPreload) utils.io.addPreload({ |
1260 | 1335 | type: 'video', |
1261 | 1336 | field: 'url', |
1262 | 1337 | as: 'video' |
1263 | 1338 | }); |
| 1339 | + if (utils.io.addBaseurl) utils.io.addBaseurl({ |
| 1340 | + type: 'video', |
| 1341 | + field: 'url' |
| 1342 | + }); |
1264 | 1343 | }; |
1265 | 1344 |
|
1266 | 1345 | var css_248z$G = ".solidVar__a{--solidColor:#000}.solidVar__a,.solidVar__b{--solidOpacity:.7;--solidBlend:none}.solidVar__b{--solidColor:#fff}.solidVar__c{--solidColor:var(--colorBack);--solidOpacity:1;--solidBlend:multiply}"; |
|
1310 | 1389 |
|
1311 | 1390 | svg.init = () => { |
1312 | 1391 | utils.addProp(['svgPadding']); |
1313 | | - utils.io.addCache({ |
| 1392 | + if (utils.io.addCache) utils.io.addCache({ |
| 1393 | + type: 'svg', |
| 1394 | + field: 'url' |
| 1395 | + }); |
| 1396 | + if (utils.io.addBaseurl) utils.io.addBaseurl({ |
1314 | 1397 | type: 'svg', |
1315 | 1398 | field: 'url' |
1316 | 1399 | }); |
|
1921 | 2004 | activeKeys.forEach(k => { |
1922 | 2005 | const p = all[k]; |
1923 | 2006 | if (p && p.init) p.init(plugs[k]); |
1924 | | - store.push(p); |
| 2007 | + store.push({ |
| 2008 | + plugin: p, |
| 2009 | + conf: plugs[k], |
| 2010 | + key: k |
| 2011 | + }); |
1925 | 2012 | }); |
1926 | 2013 | }; |
1927 | 2014 |
|
|
1939 | 2026 | blocksKeysArr.forEach(d => blocksKeys[d] = true); |
1940 | 2027 | plugInit(blocks, blocksKeys, plugins); |
1941 | 2028 | const all = []; |
1942 | | - |
1943 | | - for (const k in plugins) { |
1944 | | - const p = plugins[k]; |
| 2029 | + plugins.forEach(plug => { |
| 2030 | + const p = plug.plugin; |
| 2031 | + const c = plug.conf; |
1945 | 2032 |
|
1946 | 2033 | if (p && p.run) { |
1947 | | - all.push(p.run(config)); |
| 2034 | + all.push(p.run(config, c)); |
1948 | 2035 | } |
1949 | | - } |
1950 | | - |
| 2036 | + }); |
1951 | 2037 | return all; |
1952 | 2038 | }); |
1953 | 2039 |
|
|
0 commit comments