@richmd/react 2.2.0-rc.1 → 3.0.0
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.
|
@@ -416,7 +416,7 @@ const iT = (t, e = !0) => {
|
|
|
416
416
|
u(a), r.push(new br.EndDetails()), a = "";
|
|
417
417
|
else if (n === Or && $C.test(y)) {
|
|
418
418
|
u(a);
|
|
419
|
-
const C = y.replace(
|
|
419
|
+
const C = y.replace(/\<\>/, "").trim();
|
|
420
420
|
C ? bo = C.split(".") : bo = ["span", ""], r.push(new br.StartTag(bo[0] ?? "span", bo[1])), a = "";
|
|
421
421
|
} else if (n === Or && XC.test(y))
|
|
422
422
|
u(a), r.push(new br.EndTag(bo ? bo[0] : "span")), a = "";
|
|
@@ -75975,7 +75975,7 @@ function(t) {
|
|
|
75975
75975
|
*/
|
|
75976
75976
|
function(t) {
|
|
75977
75977
|
function e() {
|
|
75978
|
-
return (Ct.canvg ? Promise.resolve(Ct.canvg) : import("./index.es-
|
|
75978
|
+
return (Ct.canvg ? Promise.resolve(Ct.canvg) : import("./index.es-D9cMJu41.mjs")).catch(function(r) {
|
|
75979
75979
|
return Promise.reject(new Error("Could not load canvg: " + r));
|
|
75980
75980
|
}).then(function(r) {
|
|
75981
75981
|
return r.default ? r.default : r;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as Ma } from "./index-
|
|
1
|
+
import { _ as Ma } from "./index-BjeMFIcO.mjs";
|
|
2
2
|
var qa = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
3
3
|
function Zu(n) {
|
|
4
4
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
package/dist/index.es.jsx
CHANGED
package/dist/index.umd.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(ai,kr){typeof exports=="object"&&typeof module<"u"?kr(exports,require("react"),require("html-react-parser")):typeof define=="function"&&define.amd?define(["exports","react","html-react-parser"],kr):(ai=typeof globalThis<"u"?globalThis:ai||self,kr((ai.richmd=ai.richmd||{},ai.richmd.react={}),ai.React,ai.parse))})(this,function(ai,kr,sp){"use strict";function cB(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const wA=cB(kr);class lr{constructor(e,t){this.name=e,this.type=t}}const AB=/^!\[([^\]]*)?\]\(([^\)]+)\)$/,uB=/^@\[([^\]]*)?\]\(([^\)]+)\)$/,dB=/^\[([^\]]*)?\]\(([^\)]+)\)$/;class pB extends lr{constructor(e){super("text","inline"),this.value=e}}class gB extends lr{constructor(e){super("html","inline"),this.value=e}}class fB extends lr{constructor(e){super("htmlcomment","inline"),this.value=e}}class _B extends lr{constructor(e){super("em","inline"),this.value=e}}class mB extends lr{constructor(e){super("italic","inline"),this.value=e}}class hB extends lr{constructor(e){super("emitalic","inline"),this.value=e}}class bB extends lr{constructor(e){super("strikethrough","inline"),this.value=e}}class yB extends lr{constructor(e){super("code","inline"),this.value=e}}class vB extends lr{constructor(e){const t=e.match(AB);super("image","inline"),t?(this.alt=t[1]||"",this.src=t[2]||""):(this.alt="",this.src="")}}class EB extends lr{constructor(e){const t=e.match(uB);super("video","inline"),t?this.src=t[2]||"":this.src=""}}let SB=class extends lr{constructor(r){const e=r.match(dB);super("link","inline"),e?(this.title=e[1]||"",this.href=e[2]||""):(this.title="",this.href="")}};class wB extends lr{constructor(e){super("katex","inline"),this.value=e}}class CB extends lr{constructor(e){super("emoji","inline"),this.value=e}}const cr={Text:pB,Html:gB,HtmlComment:fB,Em:_B,Italic:mB,EmItalic:hB,Strikethrough:bB,InlineCode:yB,Image:vB,Video:EB,Link:SB,InlineKatex:wB,Emoji:CB},TB=/^\s*$/,NB=r=>r.length===0||TB.test(r),Zl={isEmpty:NB},rn=0,op=1,CA=2,TA=3,lp=4,cp=5,Ap=6,up=7,Zo=8,Jl=9,po=10,go=11,Jo=12,aE=13,hs=r=>{const e=[];let t="",a=rn,n=!1;const i=[];for(let s=0;s<r.length;s+=1){const o=r[s];if(n===!0){t+=o,n=!1;continue}switch(o){case"*":if(r[s+1]==="*"){s+=1,r[s+1]==="*"?(s+=1,a===TA?(e.push(new cr.EmItalic(t)),a=rn):(e.push(new cr.Text(t)),a=TA),t=""):(a===CA?(e.push(new cr.Em(t)),a=rn):(e.push(new cr.Text(t)),a=CA),t="");continue}else if(a===TA){e.push(new cr.EmItalic(t)),a=CA,t="";continue}a===op?(e.push(new cr.Italic(t)),a=rn,t=""):(e.push(new cr.Text(t)),a=op,t="");continue;case"_":if(a===Jo||a===Zo||a===Jl){t+=o;continue}if(r[s+1]==="_"){s+=1,r[s+1]==="_"?(s+=1,a===Ap?(e.push(new cr.EmItalic(t)),a=rn):(e.push(new cr.Text(t)),a=Ap),t=""):(a===cp?(e.push(new cr.Em(t)),a=rn):(e.push(new cr.Text(t)),a=cp),t="");continue}a===lp?(e.push(new cr.Italic(t)),a=rn):(e.push(new cr.Text(t)),a=lp),t="";continue;case"~":if(a===Jo||a===Zo||a===Jl){t+=o;continue}if(r[s+1]==="~"){s+=1,a===up?(e.push(new cr.Strikethrough(t)),a=rn):(e.push(new cr.Text(t)),a=up),t="";continue}t+=o;continue;case"`":a===po?(e.push(new cr.InlineCode(t)),a=rn):(e.push(new cr.Text(t)),a=po),t="";continue;case"$":a===go?(e.push(new cr.InlineKatex(t)),a=rn):(e.push(new cr.Text(t)),a=go),t="";continue;case"<":{Zl.isEmpty(t)||(i.length===0?e.push(new cr.Text(t)):i[i.length-1]+=t,t="");let l=o;if(l!=="<"){do t+=l,l=r[s+=1];while(l!==">");t+=l}else t+=l;if(t[1]==="/"){const c=i.pop()+t;e.push(new cr.Html(c))}else t[1]==="!"?e.push(new cr.HtmlComment(t)):t==="<"?e.push(new cr.Text(t)):i.push(t);t="";continue}case"!":if(a===po||a===go){t+=o;continue}if(!Zl.isEmpty(t)){t+=o;continue}if(r[s+1]==="["){t="",a=Zo,t=o;continue}case"@":if(a===po||a===go){t+=o;continue}if(!Zl.isEmpty(t)){t+=o;break}if(r[s+1]==="["){t="",a=Jo,t=o;continue}case"[":if(a!==Zo&&a!==Jo){e.push(new cr.Text(t)),a=Jl,t=o;continue}else{t+=o;continue}case")":if(t+=o,a===Zo){e.push(new cr.Image(t)),a=rn,t="";continue}else if(a===Jo){e.push(new cr.Video(t)),a=rn,t="";continue}else if(a===Jl){e.push(new cr.Link(t)),a=rn,t="";continue}else continue;case"\\":if(a!==po&&a!==go){n=!0;continue}break;case":":if(a===po||a===go||a===Jo||a===Zo||a===Jl){t+=o;continue}a===aE?(e.push(new cr.Emoji(t)),a=rn):(e.push(new cr.Text(t)),a=aE),t="";continue;default:t+=o;break}}if(!Zl.isEmpty(t)){const s=e[e.length-1];if(!s||a===rn)e.push(new cr.Text(t));else{let o="";switch(a){case op:o="*";break;case CA:o="**";break;case TA:o="***";break;case lp:o="_";break;case cp:o="__";break;case Ap:o="___";break;case up:o="~~";break;case po:o="`";break;case go:o="$";break}s.value+=`${o}${t}`}}return e};class kB extends lr{constructor(e){super("mode","block"),this.mode=e}}class OB extends lr{constructor(e){super("paragraph","block"),this.values=hs(e)}}class IB extends lr{constructor(){super("horizontal","block")}}class RB extends lr{constructor(){super("br","block")}}class BB extends lr{constructor(e,t,a){super("code","block"),this.syntax=t,this.file=a,this.values=[new cr.Text(e)]}}class xB extends lr{constructor(e){super("katex","block"),this.values=[new cr.Text(e)]}}class DB extends lr{constructor(e,t){super("color","block"),this.style=t,this.values=hs(e)}}class LB extends lr{constructor(e,t){super("blockquote","block"),this.level=t,this.values=hs(e)}}class MB extends lr{constructor(e,t){if(t===0||t>6)throw new Error("Invalid heading: heading support only between H1 and H6");super("heading","block"),this.level=t,this.values=hs(e)}}class FB extends lr{constructor(e,t){super("list","block"),this.level=t,this.values=hs(e)}}class PB extends lr{constructor(e,t,a){super("orderedlist","block"),this.level=a,this.order=t,this.values=hs(e)}}class UB extends lr{constructor(e,t,a){super("checklist","block"),this.level=a,this.checked=t,this.values=hs(e)}}class QB extends lr{constructor(e){super("table","block"),this.headings=[],this.aligns=[],this.rows=[];const[t,a,...n]=e.map(i=>i.replace(/^\||\|$/g,"").split("|"));t!==void 0&&(this.headings=t.map(i=>i.trim())),a!==void 0&&(this.aligns=a.map(i=>{const s=i.trim();let o="left";return s[s.length-1]===":"&&(o=s[0]===":"?"center":"right"),o})),n!==void 0&&(this.rows=n.map(i=>i.map(s=>hs(s.trim()))))}}class zB extends lr{constructor(e){super("startDetails","block"),this.summary=e}}class HB extends lr{constructor(){super("endDetails","block")}}class GB extends lr{constructor(e,t){super("startTag","block"),this.style=t,this.tag=e}}class qB extends lr{constructor(e){super("endTag","block"),this.tag=e}}class VB extends lr{constructor(e,t,a){super("startSlide","block"),this.layout=e,this.mode=t,this.theme=a}}class YB extends lr{constructor(){super("endSlide","block")}}const Lr={Paragraph:OB,Horizontal:IB,Code:BB,Katex:xB,ColorBlock:DB,Blockquote:LB,Heading:MB,List:FB,CheckList:UB,OrderedList:PB,Table:QB,Br:RB,StartDetails:zB,EndDetails:HB,StartTag:GB,EndTag:qB,StartSlide:VB,EndSlide:YB,Mode:kB},nE=/^(#{1,})\s(.+)$/,iE=/^(\s*)?(?:\-|\*)\s(.+)$/,sE=/^(\s*)?([0-9]+)\.\s(.+)$/,jB=/^[\*\-_\s]+$/,KB=/^[`~]{3}(.*)|[`~]{3}(.*)\b[\l]+\b\:\b[\u\l]+\b$/,oE=/^(>{1,})\s?(.+)$/,lE=/(?:\s*)?\|(.+)\|(?:\s*)$/,WB=/^[\$]{2}(.*)$/,$B=/^[\=]{3}(.*)|[\=]{3}(.*)\b[\l]+\b$/,XB=/^\<\>\b[a-z]+\b|\:\:\b[a-z]+\b\.\b[a-z]+\b|\<\>\.\b[a-z]+\b$/,ZB=/^\<\>$/,JB=/^\=\>(\b[\w_\.\/]+\b|[\u3040-\u309F\u30A0-\u30FF\u3400-\u9FFF])+$/,ex=/^\=\>$/,tx=/^\|use\sslide\|$/,rx=/^\|\|---\|\|(title|content)(?:\.[A-Za-z]+)?$/,ax=/^\|\|<--\|\|(title|content)(?:\.[A-Za-z]+)?$/,nx=/^\|\|-->\|\|(title|content)(?:\.[A-Za-z]+)?$/,ix=/^\|{2}\-{3}\|{2}$/,NA=/^\bhttps?:\/\/(?:www\.)?[a-zA-Z0-9\-._~:/?#[@\]!$&'()*+,;=%]+\b$/,Kr=0,dp=1,cE=2,AE=3,el=4,uE=0,ec=1;let tl;const sx=(r,e=!0)=>{const t=[];let a="",n=Kr,i=uE,s=[],o,l="",c="",A="default",d="";const u=m=>{s.length>0&&(t.push(new Lr.Table(s)),s=[]),Zl.isEmpty(m)||t.push(new Lr.Paragraph(m))},g=r.replace(/\r/g,"").split(`
|
|
2
|
-
`);for(let m=0;m<g.length;m++){let _=g[m];if(t.length===0&&i===uE&&(tx.test(_)&&e?(t.push(new Lr.Mode("slide")),i=ec,n=el):t.push(new Lr.Mode("default"))),i===ec&&n===el&&rx.test(_)){const E=_.replace(/\|{2}\-{3}\|{2}/,"").trim().split(".");t.push(new Lr.StartSlide("center",E[0],E[1]??"default")),n=Kr,a=""}else if(i===ec&&n===el&&ax.test(_)){const E=_.replace(/\|{2}\<\-{2}\|{2}/,"").trim().split(".");t.push(new Lr.StartSlide("left",E[0],E[1]??"default")),n=Kr,a=""}else if(i===ec&&n===el&&nx.test(_)){const E=_.replace(/\|{2}\-{2}\>\|{2}/,"").trim().split(".");t.push(new Lr.StartSlide("right",E[0],E[1]??"default")),n=Kr,a=""}else if(i===ec&&n===Kr&&ix.test(_))u(a),t.push(new Lr.EndSlide),n=el,a="";else if(n===Kr&&JB.test(_)){u(a);const E=_.replace(/\=\>/,"").trim();t.push(new Lr.StartDetails(E)),a=""}else if(n===Kr&&ex.test(_))u(a),t.push(new Lr.EndDetails),a="";else if(n===Kr&&XB.test(_)){u(a);const E=_.replace(
|
|
2
|
+
`);for(let m=0;m<g.length;m++){let _=g[m];if(t.length===0&&i===uE&&(tx.test(_)&&e?(t.push(new Lr.Mode("slide")),i=ec,n=el):t.push(new Lr.Mode("default"))),i===ec&&n===el&&rx.test(_)){const E=_.replace(/\|{2}\-{3}\|{2}/,"").trim().split(".");t.push(new Lr.StartSlide("center",E[0],E[1]??"default")),n=Kr,a=""}else if(i===ec&&n===el&&ax.test(_)){const E=_.replace(/\|{2}\<\-{2}\|{2}/,"").trim().split(".");t.push(new Lr.StartSlide("left",E[0],E[1]??"default")),n=Kr,a=""}else if(i===ec&&n===el&&nx.test(_)){const E=_.replace(/\|{2}\-{2}\>\|{2}/,"").trim().split(".");t.push(new Lr.StartSlide("right",E[0],E[1]??"default")),n=Kr,a=""}else if(i===ec&&n===Kr&&ix.test(_))u(a),t.push(new Lr.EndSlide),n=el,a="";else if(n===Kr&&JB.test(_)){u(a);const E=_.replace(/\=\>/,"").trim();t.push(new Lr.StartDetails(E)),a=""}else if(n===Kr&&ex.test(_))u(a),t.push(new Lr.EndDetails),a="";else if(n===Kr&&XB.test(_)){u(a);const E=_.replace(/\<\>/,"").trim();E?tl=E.split("."):tl=["span",""],t.push(new Lr.StartTag(tl[0]??"span",tl[1])),a=""}else if(n===Kr&&ZB.test(_))u(a),t.push(new Lr.EndTag(tl?tl[0]:"span")),a="";else if(KB.test(_))if(n===dp)t.push(new Lr.Code(a.trim(),l,c)),l="",c="",n=Kr,a="";else if(n===Kr){u(a);const E=_.replace(/\`\`\`/,"").trim().split(":");l=E[0],c=E[1],n=dp,a=""}else a+=_!==""?`${_}
|
|
3
3
|
`:`
|
|
4
4
|
`;else if(WB.test(_))n===cE?(t.push(new Lr.Katex(a.trim())),n=Kr,a=""):n===Kr?(u(a),n=cE,a=""):a+=_!==""?`${_}
|
|
5
5
|
`:`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@richmd/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "It is a react package of Richmd.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@react-hook/event": "^1.2.6",
|
|
44
|
-
"@richmd/js": "3.0.0
|
|
44
|
+
"@richmd/js": "3.0.0",
|
|
45
45
|
"html-react-parser": "^5.2.2",
|
|
46
46
|
"html2canvas": "^1.4.1",
|
|
47
47
|
"jspdf": "^3.0.1",
|