Build 584177stable
Module 98341
1,143 characters · in 17091.98ad4a4e4c98d2b2.jsDependencies
Source Raw
function(e,t,n){"use strict";var r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.astFormatter=t.RichTextNodeType=void 0,t.formatToAst=l;let a=n(541202);(i=r||(t.RichTextNodeType=r={})).Text="text",i.Strong="strong",i.Emphasis="em",i.Strikethrough="s",i.Code="inlineCode",i.Link="link",i.Paragraph="paragraph";let o={$b:e=>({type:r.Strong,content:e}),$i:e=>({type:r.Emphasis,content:e}),$del:e=>({type:r.Strikethrough,content:e}),$code:e=>({type:r.Code,content:e}),$link:(e,t,[n])=>({type:r.Link,target:n,content:e}),$p:e=>({type:r.Paragraph,content:e})};class s extends a.FormatBuilder{constructor(){super(...arguments),this.result=[]}pushRichTextTag(e,t,n){if(!(e in o))throw`${e} is not a known rich text formatting tag`;let r=o[e](t,"",n);Array.isArray(r)?this.result.push(...r):this.result.push(r)}pushLiteralText(e){let t=this.result[this.result.length-1];null!=t&&t.type===r.Text?t.content+=e:this.result.push({type:r.Text,content:e})}pushObject(e){this.result.push(e)}finish(){return this.result}}function l(e,t){return"string"==typeof e?[{type:r.Text,content:e}]:this.bindFormatValues(s,e,t)}t.astFormatter={format:l,builder:s}}