@eastgatesystems/tbx-reader 0.1.1 → 0.1.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.
|
@@ -21,6 +21,7 @@ var TbxDocument=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`
|
|
|
21
21
|
cursor: pointer;
|
|
22
22
|
}
|
|
23
23
|
a.tbx-url { color: var(--tbx-url-color, #2255cc); }
|
|
24
|
+
a.tbx-url::after { content: ' ⧉'; font-size: 0.75em; vertical-align: super; }
|
|
24
25
|
`,_t=class extends dt{constructor(e,t){super(e),this.onNavigate=t,this.container.addEventListener(`click`,e=>{let n=e.target.closest(`a[data-dest]`);if(!n)return;e.preventDefault(),e.stopPropagation();let r=n.getAttribute(`data-dest`);if(!r||!this.currentNote)return;let i=this.currentNote.ht.findNote(r);i&&t(i)})}render(e){this.currentNote=e;let t=e.get(`NoteCSS`),n=t?`<style>${t}</style>`:``,r=`<h1>${V(e.get(`DisplayName`))}</h1>`,i=e.getColor(`TextBackgroundColor`);if(this.container.style.backgroundColor=i?i.hex:``,e.html){let t=ft(e),i=t.length?mt(e.html,e.text,t):e.html;this.container.innerHTML=n+r+i;return}if(e.isRichText){this.container.innerHTML=n+r+`<em>Rich text content not yet supported.</em>`;return}this.container.innerHTML=n+r+ht(e.text,ft(e))}};function vt(e){return{anchor:{x:e.right,y:(e.top+e.bottom)/2},tx:1,ty:0}}function yt(e){return{anchor:{x:e.left,y:(e.top+e.bottom)/2},tx:-1,ty:0}}function bt(e){return{anchor:{x:(e.left+e.right)/2,y:e.top},tx:0,ty:-1}}function xt(e){return{anchor:{x:(e.left+e.right)/2,y:e.bottom},tx:0,ty:1}}function St(e,t,n,r){if(n)return{src:xt(e),dst:vt(t)};let i=(e.left+e.right)/2,a=(e.top+e.bottom)/2,o=(t.left+t.right)/2,s=(t.top+t.bottom)/2,c=o-i,l=s-a,u=Math.abs(c),d=Math.abs(l),f=u-(e.right-e.left)/2-(t.right-t.left)/2,p=d-(e.bottom-e.top)/2-(t.bottom-t.top)/2,m=f<4*r,h=p<4*r,g=c>0?vt(e):yt(e);if(m&&(g=l>0?xt(e):bt(e)),h&&f<4*r){let n=yt(t),r=xt(e),i=bt(e);n.anchor.y>r.anchor.y?g=r:n.anchor.y<i.anchor.y&&(g=i)}let _=l>0?bt(t):xt(t),v=yt(t),y=vt(t);return m&&(v.anchor.x-g.anchor.x>4*r?_=v:g.anchor.x-y.anchor.x>4*r&&(_=y)),h&&(v.anchor.x-g.anchor.x>0?_=v:g.anchor.x-y.anchor.x>0&&(_=y)),{src:g,dst:_}}function Ct(e,t){let n=Math.hypot(t.anchor.x-e.anchor.x,t.anchor.y-e.anchor.y)/3;return{p0:e.anchor,p1:{x:e.anchor.x+n*e.tx,y:e.anchor.y+n*e.ty},p2:{x:t.anchor.x+n*t.tx,y:t.anchor.y+n*t.ty},p3:t.anchor}}function wt(e){if(e.isPrototype())return!1;let t=e.src.ht.linkTypes.get(e.name);return!(t&&!t.visible)}function Tt(e){let t=e.src.ht.linkTypes.get(e.name)?.color??``;return!t||t===`normal`?`black`:e.src.ht.colors.resolve(t.trim())?.hex??`black`}function Et(e){return e.src.ht.linkTypes.get(e.name)?.dotted??!1}function Dt(e){return e.src.ht.linkTypes.get(e.name)?.dashed??!1}function Ot(e,t,n=8){if(e.length===0)return[];let r=new Set(e.map(e=>e.id)),i=[],a=e[0].ht.links.filter(e=>wt(e)&&e.dest!==null&&!e.isUrlLink());for(let e of a){let a=e.dest;if(!r.has(e.src.id)||!r.has(a.id))continue;let{src:o,dst:s}=St(t.get(e.src.id),t.get(a.id),e.src===a,n),{p0:c,p1:l,p2:u,p3:d}=Ct(o,s);i.push({kind:`full`,p0:c,p1:l,p2:u,p3:d,color:Tt(e),arrowSize:n,dotted:Et(e),dashed:Dt(e)})}let o=new Map;for(let e of a){if(!r.has(e.src.id)||r.has(e.dest.id))continue;let t=o.get(e.src.id);t?t.count++:o.set(e.src.id,{count:1,color:Tt(e)})}for(let[e,{count:r,color:a}]of o){let o=t.get(e),s={x:(o.left+o.right)/2,y:o.bottom},c={x:s.x,y:s.y+4*n};i.push({kind:`out-stub`,from:s,tip:c,count:r,color:a,arrowSize:n,dotted:!1,dashed:!1})}let s=new Map;for(let e of a){if(!r.has(e.dest.id)||r.has(e.src.id))continue;let t=s.get(e.dest.id);t?t.count++:s.set(e.dest.id,{count:1,color:Tt(e)})}for(let[e,{count:r,color:a}]of s){let o=t.get(e),s={x:(o.left+o.right)/2,y:o.top},c={x:s.x,y:s.y-4*n};i.push({kind:`in-stub`,from:c,tip:s,count:r,color:a,arrowSize:n,dotted:!1,dashed:!1})}return i}function H(e){return Math.round(e*100)/100}function kt(e,t,n,r){let i=t.x-e.x,a=t.y-e.y,o=Math.hypot(i,a);if(o<1)return``;let s=i/o,c=a/o,l=-c,u=s,d=t.x-s*r,f=t.y-c*r,p=d+l*r*.4,m=f+u*r*.4,h=d-l*r*.4,g=f-u*r*.4;return`<polygon points="${H(t.x)},${H(t.y)} ${H(p)},${H(m)} ${H(h)},${H(g)}" fill="${n}" opacity="0.7"/>`}function At(e,t,n){return`<circle cx="${H(e)}" cy="${H(t)}" r="8" fill="#777"/><text x="${H(e)}" y="${H(t)}" dy="0.35em" text-anchor="middle" font-size="9" font-family="system-ui,sans-serif" font-variant-numeric="lining-nums" fill="white" font-weight="bold">${n}</text>`}function jt(e,t,n){let r=[];for(let t of e){let e=t.dotted?` stroke-dasharray="3 5"`:t.dashed?` stroke-dasharray="8 5"`:``;if(t.kind===`full`){let{p0:n,p1:i,p2:a,p3:o,color:s,arrowSize:c}=t,l=`M${H(n.x)},${H(n.y)} C${H(i.x)},${H(i.y)} ${H(a.x)},${H(a.y)} ${H(o.x)},${H(o.y)}`;r.push(`<path d="${l}" stroke="${s}" fill="none" stroke-opacity="0.5"${e}/>`),r.push(kt(a,o,s,c))}else{let{from:n,tip:i,count:a,color:o,arrowSize:s}=t;r.push(`<line x1="${H(n.x)}" y1="${H(n.y)}" x2="${H(i.x)}" y2="${H(i.y)}" stroke="${o}" stroke-width="1.5" stroke-opacity="0.7"${e}/>`),r.push(kt(n,i,o,s)),t.kind===`out-stub`?r.push(At(i.x,i.y+4,a)):r.push(At(n.x,n.y-4,a))}}return`<svg width="${t}" height="${n}" overflow="visible" style="position:absolute;top:0;left:0;pointer-events:none;">`+r.join(``)+`</svg>`}var Mt=32,U=16,Nt=new Set([`gradient`,`radial`,`diagonal`,`cylinder`]);function Pt(e,t,n){switch(e){case`gradient`:return`linear-gradient(to bottom, ${t}, ${n})`;case`cylinder`:return`linear-gradient(to bottom, ${t}, ${n} 50%, ${t})`;case`diagonal`:return`linear-gradient(135deg, ${t}, ${n})`;case`radial`:return`radial-gradient(ellipse at center, ${t}, ${n})`;default:return t.hex}}function Ft(e,t,n,r){let i=`<stop offset="0%" stop-color="${n}"/><stop offset="100%" stop-color="${r}"/>`;switch(t){case`gradient`:return{fill:`url(#${e})`,defs:`<defs><linearGradient id="${e}" x1="0" y1="0" x2="0" y2="1">${i}</linearGradient></defs>`};case`cylinder`:return{fill:`url(#${e})`,defs:`<defs><linearGradient id="${e}" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="${n}"/><stop offset="50%" stop-color="${r}"/><stop offset="100%" stop-color="${n}"/></linearGradient></defs>`};case`diagonal`:return{fill:`url(#${e})`,defs:`<defs><linearGradient id="${e}" x1="0" y1="0" x2="1" y2="1">${i}</linearGradient></defs>`};case`radial`:return{fill:`url(#${e})`,defs:`<defs><radialGradient id="${e}" cx="50%" cy="50%" r="70%">${i}</radialGradient></defs>`};default:return{fill:n.hex,defs:``}}}function It(e,t,n,r,i,a,o=0,s=0,c=!1,l=0){switch(e){case`lozenge`:return{kind:`css`,extra:`border-radius:${Math.min(t,n)/2}px;`};case`rounded`:return{kind:`css`,extra:`border-radius:${Math.min(t,n)/16}px;`};case`oval`:return{kind:`css`,extra:`border-radius:50%;`};case`diamond`:return{kind:`svg`,points:`${t/2},0 ${t},${n/2} ${t/2},${n} 0,${n/2}`};case`vertical tag`:{let e=n/4;return c?{kind:`svg`,points:`0,0 ${t},0 ${t},${n-e} ${t/2+e},${n-e} ${t/2},${n} ${t/2-e},${n-e} 0,${n-e}`}:{kind:`svg`,points:`0,${e} ${t/2-e},${e} ${t/2},0 ${t/2+e},${e} ${t},${e} ${t},${n} 0,${n}`}}case`arrow`:{let e=Math.min(n/2,t*.75),r=n*(.1+o*.2),i=e/4*s;return c?{kind:`svg`,points:`0,${r} ${t-e},${r} ${t-e-i},0 ${t},${n/2} ${t-e-i},${n} ${t-e},${n-r} 0,${n-r}`}:{kind:`svg`,points:`${e+i},0 ${e},${r} ${t},${r} ${t},${n-r} ${e},${n-r} ${e+i},${n} 0,${n/2}`}}case`hex`:{let e=Math.min(t/2,n/2);return t>=n?{kind:`svg`,points:`0,${n/2} ${e},0 ${t-e},0 ${t},${n/2} ${t-e},${n} ${e},${n}`}:{kind:`svg`,points:`0,${e} ${t/2},0 ${t},${e} ${t},${n-e} ${t/2},${n} 0,${n-e}`}}case`bubble`:{let e=.17,r=Math.sin(e),i=Math.cos(e),a=.4*n,o=t/2,s=a,l=a*(1+i),u=o*(1-r),d=o*(1+r),f=a*(1+i+.4),p=c?o*1.3:o*.7;return c?{kind:`path`,d:`M${d},${l} A${o},${s} 0 1 0 ${u},${l} L${p},${f} Z`}:{kind:`path`,d:`M${u},${l} A${o},${s} 0 1 1 ${d},${l} L${p},${f} Z`}}case`tag`:case`left tag`:{let e=Math.min(Math.round(n/2),t-5);return{kind:`svg`,points:`${e},0 ${t},0 ${t},${n} ${e},${n} 0,${n/2}`}}case`cloud`:{let e=Math.SQRT2/2,r=t/3,i=n/3,a=t/4,o=n/4;return{kind:`path`,d:`M${r*(1-e)},${i*(1+e)} A${r},${i} 0 0 1 ${r*(1+e)},${i*(1-e)} L${t*3/4-a*e},${n/4-o*e} A${a},${o} 0 0 1 ${t*3/4+a*e},${n/4+o*e} L${t*2/3+r*e},${n*2/3-i*e} A${r},${i} 0 0 1 ${t*2/3-r*e},${n*2/3+i*e} L${t/4+a*e},${n*3/4+o*e} A${a},${o} 0 0 1 ${t/4-a*e},${n*3/4-o*e} Z`}}case`leaf`:{let e=-1+o/2,r=-1+o,i=r+s,a=s,u=c?-1:1,d=e=>t/2*(1+u*e),f=e=>n/2*(1+e);return{kind:`path`,d:`M${d(-1)},${f(0)} C${d(e)},${f(-.5)} ${d(e)},${f(-1)} ${d(r)},${f(-1)} C${d(i)},${f(-.95)} ${d(a)},${f(0)} ${d(1)},${f(l)} C${d(a)},${f(0)} ${d(i)},${f(1)} ${d(r)},${f(1)} C${d(e)},${f(1)} ${d(e)},${f(.5)} ${d(-1)},${f(0)} Z`}}default:{let e=Math.min(t/8,16);return i?{kind:`css`,extra:`border-radius:${e}px ${e}px 0 0;`}:r?{kind:`css`,extra:`border-radius:0 0 ${e}px ${e}px;`}:{kind:`css`,extra:``}}}}var Lt=`
|
|
25
26
|
#tbx-outline { overflow-x: auto; }
|
|
26
27
|
.tbx-map-canvas { position: relative; cursor: grab; }
|
package/dist/tbx-document.mjs
CHANGED
|
@@ -2708,7 +2708,7 @@ function mt(e, t) {
|
|
|
2708
2708
|
}
|
|
2709
2709
|
//#endregion
|
|
2710
2710
|
//#region src/views/text-view.ts
|
|
2711
|
-
var ht = "\n #tbx-content { flex: 1; min-height: 8em; padding: 24px 24px 0; overflow-y: auto; }\n #tbx-content * { line-height: 1.4 !important; }\n h1 {\n font-family: var(--tbx-heading-font-family, Helvetica, Arial, sans-serif);\n font-size: 1.1em;\n font-weight: bold;\n text-align: center;\n margin: 0 0 0.75em 0;\n line-height: 1.2 !important;\n }\n p { margin: 0 0 0.8em 0; }\n p:last-child { margin-bottom: 0; }\n a {\n color: var(--tbx-link-color, inherit);\n text-decoration: underline;\n cursor: pointer;\n }\n a.tbx-url { color: var(--tbx-url-color, #2255cc); }\n", gt = class extends B {
|
|
2711
|
+
var ht = "\n #tbx-content { flex: 1; min-height: 8em; padding: 24px 24px 0; overflow-y: auto; }\n #tbx-content * { line-height: 1.4 !important; }\n h1 {\n font-family: var(--tbx-heading-font-family, Helvetica, Arial, sans-serif);\n font-size: 1.1em;\n font-weight: bold;\n text-align: center;\n margin: 0 0 0.75em 0;\n line-height: 1.2 !important;\n }\n p { margin: 0 0 0.8em 0; }\n p:last-child { margin-bottom: 0; }\n a {\n color: var(--tbx-link-color, inherit);\n text-decoration: underline;\n cursor: pointer;\n }\n a.tbx-url { color: var(--tbx-url-color, #2255cc); }\n a.tbx-url::after { content: ' ⧉'; font-size: 0.75em; vertical-align: super; }\n", gt = class extends B {
|
|
2712
2712
|
constructor(e, t) {
|
|
2713
2713
|
super(e), this.onNavigate = t, this.container.addEventListener("click", (e) => {
|
|
2714
2714
|
let n = e.target.closest("a[data-dest]");
|
package/package.json
CHANGED