@primeui-devkit/lit-markdown 0.1.0-beta.2 → 0.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {ReactiveElement}from'lit';var u=new Set(["h1","h2","h3","h4","h5","h6"]),f=new Set(["p","a","blockquote","code","em","strong","hr","img","li","ol","ul","table","thead","tbody","tr","th","td"]),p='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',h='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6 9 17l-5-5"/></svg>';function g(n,r){for(let[e,t]of Object.entries(r))t==null||typeof t=="function"||typeof t=="object"||(typeof t=="boolean"?t&&n.setAttribute(e,""):n.setAttribute(e,String(t)));}function w(n,r,e){let t=document.createElement(n);t.className=`prose-${n}`;let c=typeof r.id=="string"?r.id:null;if(c){t.id=c;let s=document.createElement("a");s.href=`#${c}`,s.className="prose-heading-link";let o=document.createElement("span");o.className="prose-heading-anchor",o.textContent="#",s.append(o,e),t.append(s);}else t.append(e);return t}function k(n,r){let e=document.createElement("div");e.className="prose-pre";let t=typeof n.filename=="string"?n.filename:"",c=t.replace(":line-numbers","");if(c){let i=document.createElement("div");i.className="prose-pre-filename",i.innerHTML="<span></span>",i.querySelector("span").textContent=c,e.append(i);}let s=document.createElement("div");s.className="prose-pre-actions";let o=document.createElement("button");o.type="button",o.className="prose-pre-copy",o.title="Copy Code",o.innerHTML=p,o.addEventListener("click",async()=>{let i=typeof n.code=="string"?n.code:"";i&&(await navigator.clipboard.writeText(i),o.innerHTML=h,o.title="Copied",setTimeout(()=>{o.innerHTML=p,o.title="Copy Code";},2e3));}),s.append(o),e.append(s);let a=document.createElement("pre");return t.includes(":line-numbers")&&(a.className="prose-pre-line-numbers"),a.append(r),e.append(a),e}function E(n){let r=document.createElement("div");r.className="prose-table-scroll";let e=document.createElement("table");return e.className="prose-table",e.append(n),r.append(e),r}function l(n,r){if(typeof n=="string")return document.createTextNode(n);let[e,t={},...c]=n,s=document.createDocumentFragment();for(let i of c)s.append(l(i,r));let o=r[e];if(o)return o(t,s,n);if(u.has(e))return w(e,t,s);if(e==="pre")return k(t,s);if(e==="table")return E(s);let a=document.createElement(e);return g(a,t),f.has(e)&&a.classList.add(`prose-${e}`),a.append(s),a}function b(n,r={}){let e=document.createDocumentFragment();for(let t of n.nodes||[])e.append(l(t,r));return e}var d=class extends ReactiveElement{static properties={tree:{attribute:false},markdown:{type:String},components:{attribute:false}};#e=0;constructor(){super(),this.tree=null,this.markdown="",this.components={};}createRenderRoot(){return this}update(r){if(super.update(r),r.has("markdown")&&this.markdown){let e=++this.#e;import('@primeui-devkit/markdown-core').then(t=>t.parseMarkdown(this.markdown)).then(t=>{e===this.#e&&(this.tree=t);});return}(r.has("tree")||r.has("components"))&&(this.replaceChildren(),this.tree&&(this.classList.add("prose"),this.append(b(this.tree,this.components))));}};function y(n="lit-markdown"){customElements.get(n)||customElements.define(n,d);}export{d as LitMarkdown,y as defineLitMarkdown,l as renderNode,b as renderTree};
1
+ import {ReactiveElement}from'lit';var f=new Set(["h1","h2","h3","h4","h5","h6"]),h=new Set(["p","a","blockquote","code","em","strong","hr","img","li","ol","ul","table","thead","tbody","tr","th","td"]),p='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',g='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6 9 17l-5-5"/></svg>';function w(t,r){for(let[e,n]of Object.entries(r)){if(Array.isArray(n)){let i=n.filter(Boolean).join(" ");i&&t.setAttribute(e,i);continue}n==null||typeof n=="function"||typeof n=="object"||(typeof n=="boolean"?n&&t.setAttribute(e,""):t.setAttribute(e,String(n)));}}function k(t,r,e){let n=document.createElement(t);n.className=`prose-${t}`;let i=typeof r.id=="string"?r.id:null;if(i){n.id=i;let s=document.createElement("a");s.href=`#${i}`,s.className="prose-heading-link";let o=document.createElement("span");o.className="prose-heading-anchor",o.textContent="#",s.append(o,e),n.append(s);}else n.append(e);return n}function y(t,r){let e=document.createElement("div");e.className="prose-pre";let n=typeof t.filename=="string"?t.filename:"",i=n.replace(":line-numbers","");if(i){let c=document.createElement("div");c.className="prose-pre-filename",c.innerHTML="<span></span>",c.querySelector("span").textContent=i,e.append(c);}let s=document.createElement("div");s.className="prose-pre-actions";let o=document.createElement("button");o.type="button",o.className="prose-pre-copy",o.title="Copy Code",o.innerHTML=p,o.addEventListener("click",async()=>{let c=typeof t.code=="string"?t.code:"";c&&(await navigator.clipboard.writeText(c),o.innerHTML=g,o.title="Copied",setTimeout(()=>{o.innerHTML=p,o.title="Copy Code";},2e3));}),s.append(o),e.append(s);let a=document.createElement("pre"),d=Array.isArray(t.class)?t.class.filter(Boolean).join(" "):typeof t.class=="string"?t.class:"";return a.className=[d,n.includes(":line-numbers")?"prose-pre-line-numbers":""].filter(Boolean).join(" "),a.append(r),e.append(a),e}function b(t){let r=document.createElement("div");r.className="prose-table-scroll";let e=document.createElement("table");return e.className="prose-table",e.append(t),r.append(e),r}function m(t,r){if(typeof t=="string")return document.createTextNode(t);let[e,n={},...i]=t,s=document.createDocumentFragment();for(let d of i)s.append(m(d,r));let o=r[e];if(o)return o(n,s,t);if(f.has(e))return k(e,n,s);if(e==="pre")return y(n,s);if(e==="table")return b(s);let a=document.createElement(e);return w(a,n),h.has(e)&&a.classList.add(`prose-${e}`),a.append(s),a}function E(t,r={}){let e=document.createDocumentFragment();for(let n of t.nodes||[])e.append(m(n,r));return e}var l=class extends ReactiveElement{static properties={tree:{attribute:false},markdown:{type:String},components:{attribute:false}};#e=0;constructor(){super(),this.tree=null,this.markdown="",this.components={};}createRenderRoot(){return this}update(r){if(super.update(r),r.has("markdown")&&this.markdown){let e=++this.#e;import('@primeui-devkit/markdown-core').then(n=>n.parseMarkdown(this.markdown)).then(n=>{e===this.#e&&(this.tree=n);});return}(r.has("tree")||r.has("components"))&&(this.replaceChildren(),this.tree&&(this.classList.add("prose"),this.append(E(this.tree,this.components))));}};function M(t="lit-markdown"){customElements.get(t)||customElements.define(t,l);}export{l as LitMarkdown,M as defineLitMarkdown,m as renderNode,E as renderTree};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primeui-devkit/lit-markdown",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-rc.2",
4
4
  "description": "Lit renderer for the PrimeUI DevKit markdown AST with built-in prose behaviors: heading anchors, code copy button and table scroll wrapper. Renders into light DOM so shared prose styles apply.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "sideEffects": false,
20
20
  "dependencies": {
21
- "@primeui-devkit/markdown-core": "0.1.0-beta.2"
21
+ "@primeui-devkit/markdown-core": "0.1.0-rc.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "lit": "^3.0.0"
@@ -29,9 +29,9 @@
29
29
  "tsup": "^8.5.1",
30
30
  "typescript": "~6.0.0",
31
31
  "vitest": "4.1.10",
32
+ "@primeui-devkit/test-config": "0.0.0",
32
33
  "@primeui-devkit/bundler": "0.0.0",
33
- "@primeui-devkit/ts-config": "0.0.0",
34
- "@primeui-devkit/test-config": "0.0.0"
34
+ "@primeui-devkit/ts-config": "0.0.0"
35
35
  },
36
36
  "types": "./dist/index.d.ts",
37
37
  "module": "./dist/index.js",