@contentarchitect/quote
Version:
Blockquote block for ContentArchitect editor
2 lines (1 loc) • 2.74 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@contentarchitect/editor")):"function"==typeof define&&define.amd?define(["@contentarchitect/editor"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Quote=t(e.ContentArchitect)}(this,(function(e){"use strict";function t(e,t,n,i,o,r,s,c,a,d){"boolean"!=typeof s&&(a=c,c=s,s=!1);const l="function"==typeof n?n.options:n;let u;if(e&&e.render&&(l.render=e.render,l.staticRenderFns=e.staticRenderFns,l._compiled=!0,o&&(l.functional=!0)),i&&(l._scopeId=i),r?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,a(e)),e&&e._registeredComponents&&e._registeredComponents.add(r)},l._ssrRegister=u):t&&(u=s?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,c(e))}),u)if(l.functional){const e=l.render;l.render=function(t,n){return u.call(n),e(t,n)}}else{const e=l.beforeCreate;l.beforeCreate=e?[].concat(e,u):[u]}return n}const n={directives:{edit:e.EditDirective},props:["value"],data:()=>({blockquoteSettings:{placeholder:"Type your text"},citeSettings:{placeholder:"Type the citation"}})};var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("blockquote",[n("div",{directives:[{name:"edit",rawName:"v-edit:[blockquoteSettings].block",value:e.value.content,expression:"value.content",arg:e.blockquoteSettings,modifiers:{block:!0}}]}),e._v(" "),n("cite",{directives:[{name:"edit",rawName:"v-edit:[citeSettings]",value:e.value.cite,expression:"value.cite",arg:e.citeSettings}],staticClass:"cite"})])};i._withStripped=!0;const o=t({render:i,staticRenderFns:[]},undefined,n,undefined,false,undefined,!1,void 0,void 0,void 0);var r={render:function(){var e=this.$createElement,t=this._self._c||e;return t("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",height:"24",width:"24"}},[t("path",{attrs:{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"}}),t("path",{attrs:{d:"M0 0h24v24H0z",fill:"none"}})])}};class Quote extends e.Block{static get viewComponent(){return o}static get icon(){return r}static defaultData(){return{content:"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",cite:"Anonym"}}toHTML(){let e="";return e+=this.content,this.cite&&""!==this.cite&&(e+=`<cite>${this.cite}</cite>`),`<blockquote>${e}</blockquote>`}static serializeFromHTML(e){let t={content:"",cite:""};const n=e.getElementsByTagName("blockquote")[0],i=n?n.getElementsByTagName("cite")[0]:void 0;return i&&(n.removeChild(i),t.cite=i.innerHTML),n&&(t.content=n.innerHTML),t}}return Quote}));