@ones-editor/editor 0.0.3-beta.78 → 0.0.3-beta.79

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.
package/dist/index.js CHANGED
@@ -684,7 +684,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
684
684
  <rect width="6" height="7" fill="white" transform="translate(6 6)"/>
685
685
  </clipPath>
686
686
  </defs>
687
- </svg>`,B6={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},Df={dwg:t$,rvt:e$,skp:n$,img:o$,txt:r$,zip:w6,rar:w6,ppt:i$,excel:s$,pdf:l$,word:c$};function E6(n,t){const e=Object.keys(B6);for(let r=0;r<e.length;r+=1){const i=e[r];if(B6[i].includes(t))return Df[i]}const o=Iu(n.toLowerCase());return Df[o]?Df[o]:a$}async function u$(n,t,e){var k;const{fileName:o,fileType:r,fileSize:i}=e,s=b("div",["card-root"],t),l=b("div",["file-icon"],s),{renderFileCardIcon:c}=((k=n.options.componentsOptions)==null?void 0:k.file)||{};if(!c)l.innerHTML=E6(o,r);else{const v=c&&await c(n,e);v?l.append(v):l.innerHTML=E6(o,r)}const a=b("div",["file-details"],s),d=Iu(o),f=o.length-d.length-3,m=b("div",["file-name"],a);f>0?(b("span",["file-name-pre"],m,o.slice(0,f)),b("span",[],m,o.slice(f))):m.textContent=o,b("div",["file-size"],a,Xm(i));const p=b("div",["file-actions"],s),A=b("button",["download"],p);return A.innerHTML=Sf,{card:s,downloadButton:A}}const UV="";function I6(n,t){const o=n.getBlockData(t).embedData,r=n.options.componentsOptions.file;if(r!=null&&r.onDownloadFile){r.onDownloadFile(n,o);return}const i=n.doc.buildResourceUrl(o.src,{downloadFileName:o.fileName});Pl(i,o.fileName)}async function d$(n,t,e){const{embedData:o}=e,r=o,{card:i,downloadButton:s}=await u$(n,t,r);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const a=U(c.target);!a||I6(l,a)}),n.domEvents.addEventListener(i,"click",(l,c)=>{if(!c.target)return;const a=U(c.target);if(!a||xr(c,"button"))return;const d=l.options.componentsOptions.file;if(d!=null&&d.onClick){d.onClick(l,a,c);return}const m=l.getBlockData(a).embedData,p=l.doc.buildResourceUrl(m.src,{downloadFileName:m.fileName});Pl(p,m.fileName)})}class h${constructor(){h(this,"group","file-card");h(this,"commands",[{id:"download",name:"Download",icon:Sf},{id:"sep",name:"",type:"separator"},{id:"to-link",name:"To link",icon:b6},{id:"to-card",name:"To card",icon:v6,states:["checked"]},{id:"sep",name:"",type:"separator"},{id:"add-comment",name:"Add Comment",icon:Ts}])}executeCommand(t,e,o){if(o.id==="to-link"){const r=z(e),i=q(r),s=K(e),l=t.getBlockData(e),{embedData:c}=l,a=c,d={id:P(),box:!0,type:"file",created:Date.now(),src:a.src,fileName:a.fileName,fileSize:a.fileSize,fileType:a.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const f=[op(d)];t.insertTextBlock(f,i,s)})}else o.id==="download"?I6(t,e):o.id==="add-comment"&&la(t,e)}}function f$(n,t){const e=n.getBlockData(t),{embedData:o,id:r}=e,i=o;return{blockCommands:{"hovering-toolbar":new h$},abstract:i.fileName}}function m$(n,t,e,o){const{embedData:r}=t,i=r;return o==="html"?i.src?`<p><a href="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" >${i.fileName}</a></p>`:`<p>[${i.fileName}]</p>`:o==="markdown"?i.src?`![${i.fileName}](${n.doc.buildResourceUrl(i.src,{withToken:!0})})
687
+ </svg>`,B6={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},Df={dwg:t$,rvt:e$,skp:n$,img:o$,txt:r$,zip:w6,rar:w6,ppt:i$,excel:s$,pdf:l$,word:c$};function E6(n,t){const e=Object.keys(B6);for(let r=0;r<e.length;r+=1){const i=e[r];if(B6[i].includes(t))return Df[i]}const o=Iu(n.toLowerCase());return Df[o]?Df[o]:a$}async function u$(n,t,e){var k;const{fileName:o,fileType:r,fileSize:i}=e,s=b("div",["card-root"],t),l=b("div",["file-icon"],s),{renderFileCardIcon:c}=((k=n.options.componentsOptions)==null?void 0:k.file)||{};if(!c)l.innerHTML=E6(o,r);else{const v=c&&await c(n,e);v?l.append(v):l.innerHTML=E6(o,r)}const a=b("div",["file-details"],s),d=Iu(o),f=o.length-d.length-3,m=b("div",["file-name"],a);f>0?(b("span",["file-name-pre"],m,o.slice(0,f)),b("span",[],m,o.slice(f))):m.textContent=o,b("div",["file-size"],a,Xm(i));const p=b("div",["file-actions"],s),A=b("button",["download"],p);return A.innerHTML=Sf,{card:s,downloadButton:A}}const UV="";function I6(n,t){const o=n.getBlockData(t).embedData,r=n.options.componentsOptions.file;if(r!=null&&r.onDownloadFile){r.onDownloadFile(n,o);return}const i=n.doc.buildResourceUrl(o.src,{downloadFileName:o.fileName});Pl(i,o.fileName)}async function d$(n,t,e){const{embedData:o}=e,r=o,{card:i,downloadButton:s}=await u$(n,t,r);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const a=U(c.target);!a||I6(l,a)}),n.domEvents.addEventListener(i,"click",(l,c)=>{if(!c.target)return;const a=U(c.target);if(!a||xr(c,"button"))return;const d=l.options.componentsOptions.file;if(d!=null&&d.onClick){d.onClick(l,a,c);return}const m=l.getBlockData(a).embedData,p=l.doc.buildResourceUrl(m.src,{downloadFileName:m.fileName});Pl(p,m.fileName)})}class h${constructor(t){h(this,"group","file-card");h(this,"_commands",[{id:"download",name:"Download",icon:Sf},{id:"sep",name:"",type:"separator"},{id:"to-link",name:"To link",icon:b6},{id:"to-card",name:"To card",icon:v6,states:["checked"]},{id:"sep",name:"",type:"separator"},{id:"add-comment",name:"Add Comment",icon:Ts}]);this.editor=t}get commands(){return this.editor.readonly?[]:this._commands}executeCommand(t,e,o){if(o.id==="to-link"){const r=z(e),i=q(r),s=K(e),l=t.getBlockData(e),{embedData:c}=l,a=c,d={id:P(),box:!0,type:"file",created:Date.now(),src:a.src,fileName:a.fileName,fileSize:a.fileSize,fileType:a.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const f=[op(d)];t.insertTextBlock(f,i,s)})}else o.id==="download"?I6(t,e):o.id==="add-comment"&&la(t,e)}}function f$(n,t){const e=n.getBlockData(t),{embedData:o}=e,r=o;return{blockCommands:{"hovering-toolbar":new h$(n)},abstract:r.fileName}}function m$(n,t,e,o){const{embedData:r}=t,i=r;return o==="html"?i.src?`<p><a href="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" >${i.fileName}</a></p>`:`<p>[${i.fileName}]</p>`:o==="markdown"?i.src?`![${i.fileName}](${n.doc.buildResourceUrl(i.src,{withToken:!0})})
688
688
  `:`[${i.fileName}]
689
689
  `:i.src?`[${i.fileName}](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:`[${i.fileName}]`}const g$={embedType:"office",createEmbedContent:d$,getBlockProperties:f$,convertTo:m$};function p$(n){const t=/(\s|^)(http|https):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$/;return t.test(n)?n.search(t):-1}function C$(n){const t=n.selection.range;if(!t.isCollapsed()||!t.isSimple())return;const{start:e}=t,o=n.getBlockById(e.blockId);if(!_(n,o))return;const r=n.getBlockText(o),s=ld(r).slice(0,e.offset),l=p$(s);if(l===-1)return;const c=s.slice(l),a=s.length;let d=Yi(l,a-l,r,"link",c);return d=po(d,a," ",null),n.setBlockText(o,d),n.selection.selectBlock(o,a+1),!0}const A$={Space:C$},VV="",b$={media:{upload:{failed:'<div class="line-1">{name} \u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">{name} \u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},v$={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}};T.mergeLang({"zh-CN":b$,"en-US":v$});var gn=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(gn||{}),al=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(al||{});const x6=10*1024*1024,y$=["wav","mp3","aac","ogg","webm","flac"],k$=["ogg","mp4","webm"],w$=()=>{};function T6(n){var d,f,m,p,A,k;const t=(d=n.getComponentOptions("media"))!=null?d:{},{allowedMedias:e,maxSize:o,callbacks:r}=t,i=(f=e==null?void 0:e.audio)!=null?f:y$,s=(m=e==null?void 0:e.video)!=null?m:k$,l=(p=o==null?void 0:o.audio)!=null?p:x6,c=(A=o==null?void 0:o.video)!=null?A:x6,a=(k=r==null?void 0:r.onError)!=null?k:w$;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:c},callbacks:{onError:a}}}const B$=w("file-utils");function E$(n){u(B$,n instanceof File,`The file: ${n} isn't instance of File`);const{name:t}=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function S6(n,t){const e=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=T6(n),r=o[t];return r?e(r):"*"}function I$(n,t,e){const{maxSize:o,callbacks:r,allowedMedias:i}=T6(t),{[e]:s}=o,{[e]:l}=i;if(s&&n.size>s){const a=new Error("media is too large");return a.code=`MaxMediaSize-${e}`,r!=null&&r.onError&&(r==null||r.onError(t,a)),a}const c=E$(n);if(l&&!l.includes(c)){const a=new Error(`media file is not allowed: ${c}`);return a.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(t,a)),a}return!0}function x$(n){return n===al.Empty||n===al.Error}const ue=w("media");class T${constructor(t){h(this,"mediaContainer",null);h(this,"media",null);h(this,"abstract",null);h(this,"handleMediaLoadError",(t,e)=>{if(!e.target||!(e.target instanceof Node)||!(e.target instanceof Element?e.target:e.target.parentElement))return;const r=U(e.target);if(!r||!r.contains(this.mediaContainer))return;const i=this.renderError();this.updateMediaContent(i)});h(this,"handleRetry",async t=>{if(t.readonly)return;u(ue,this.abstract,"no abstract");const{mediaType:e}=this.abstract,o=S6(t,e),r=await Qo(o);this.handleUploadFile(r)});h(this,"handleUploadFile",async t=>{u(ue,this.abstract,"no abstract"),u(ue,this.mediaContainer,"The media element not exist");const{editor:e}=this.options,{mediaType:o}=this.abstract,r=U(this.mediaContainer);u(ue,r,"The block element not exist");const i=e.getBlockData(r);if(!!I$(t,e,o)){try{const{resourceId:s}=await e.doc.uploadResource(t,{onProgress:f=>{this.renderProgress(f,t)}}),{name:l,type:c,size:a}=t,d={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:a,fileType:c}};e.updateBlockData(r,d)}catch{this.renderRetry()}H(r,"media-block-uploading")}});h(this,"destroy",()=>{this.mediaContainer=null});this.options=t}bindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(t){u(ue,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){u(ue,this.abstract,"no abstract");const{editor:t,createMediaElement:e}=this.options,{mediaIcon:o,mediaName:r}=this.abstract;u(ue,this.mediaContainer,"The media element not exist");const i=U(this.mediaContainer);u(ue,i,"The block element not exist");const s=t.getBlockData(i),l=s.embedData.src,c=b("div",["media-error","embed-selected-content","embed-hover-content"],null),a=b("span",["media-error-icon"],c);a.innerHTML=o;const d=b("div",[],c);d.innerHTML=T.t("media.load.failed",{name:r}),c.appendChild(d);const f=d.querySelector("a");return u(ue,f,"The element not exist"),t.domEvents.addEventListener(f,"click",(m,p)=>{if(p.preventDefault(),p.target instanceof HTMLElement&&p.target.tagName==="A"){const A=b("div",["media-element"],null),k=this.getResourceUrl(l),v=e(m,A,s,k);this.unbindMediaEvent(),this.media=v,this.bindMediaEvent(),this.updateMediaContent(A)}}),c}renderRetry(){u(ue,this.abstract,"no abstract");const{editor:t}=this.options,{mediaIcon:e,mediaName:o}=this.abstract,r=b("div",["media-error","embed-selected-content","embed-hover-content"],null),i=b("span",["media-error-icon"],r);i.innerHTML=e;const s=b("div",[],r);s.innerHTML=T.t("media.upload.failed",{name:o}),r.appendChild(s);const l=s.querySelector("a");u(ue,l,"The element not exist"),t.domEvents.addEventListener(l,"click",this.handleRetry),this.updateMediaContent(r)}renderProgress(t,e){u(ue,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope .media-progress"),r=t===-1||t===100?100:t;if(o){const{updateProgressElement:i}=this.options;i(o,r)}else{const{createProgressElement:i}=this.options,s=U(this.mediaContainer);u(ue,s,"The element not exist"),R(s,"media-block-uploading");const l=b("div",["media-progress"],null);i(l,r,e),this.updateMediaContent(l)}}renderMediaElement(t){u(ue,this.mediaContainer,"The media element not exist");const e=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:o,updateMediaElement:r,editor:i}=this.options,s=this.getResourceUrl(t.embedData.src);if(e){const l=r(i,e,t,s);this.unbindMediaEvent(),this.media=l,this.bindMediaEvent()}else{const l=b("div",["media-element"],null),c=o(i,l,t,s);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent(),this.updateMediaContent(l)}}renderEmpty(){u(ue,this.abstract,"no abstract"),u(ue,this.mediaContainer,"The media element not exist");const t=b("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);t.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(t)}getResourceUrl(t){const{editor:e}=this.options;return e.doc.buildResourceUrl(t)}render(t,e){const{src:o}=t.embedData;(!this.mediaContainer||!e.contains(this.mediaContainer))&&(this.mediaContainer=b("div",["media"],e)),x$(o)?o===al.Empty&&this.renderEmpty():this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}w("media-embed");class D6{constructor(){h(this,"handleInsertEmptyEmbed",async(t,e)=>{var d;const{containerId:o,blockIndex:r}=e;let i;(d=e.data)!=null&&d.file&&(i=e.data.file);const s=S6(t,this.embedType);if(i=i!=null?i:await Qo(s,{}),!i)return null;const l={id:P(),type:"embed",embedType:this.embedType,embedData:{src:al.Empty}},c=t.insertBlock(o,r,l);return await this.getMedia(t,l.id).handleUploadFile(i),c})}getMedia(t,e){const o=t.addCustom(`media-${e}`,()=>new T$({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.abstract}),o}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:o,order:r,group:i}=this.abstract;return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:r,group:i,subText:Ce(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,o){const{id:r}=o;this.getMedia(t,r).render(o,e)}handleUpdateBlock(t,e,o){const{id:r}=o,i=this.getMedia(t,r),s=st(e);return i.render(o,s),!0}handleDeleteBlock(t,e){const o=e.id;this.getMedia(t,o).destroy()}convertTo(t,e,o,r){const i=e.embedData,s=t.doc.buildResourceUrl(i.src,{withToken:!0});return r==="html"?`<${i.type} src="${s}" />`:r==="markdown"?`![${i.src}](${s})`:s}}function L6(n,t){const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e),r=b("div",["uploading-progress-bar-value"],o);r.style.width=`${t}%`}function M6(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const S$=w("media-audio");class D$ extends D6{constructor(){super(...arguments);h(this,"embedType",gn.AUDIO);h(this,"abstract",{mediaIcon:Gw,mediaName:T.t(`media.${gn.AUDIO}.menuItem`),menuItem:T.t(`media.${gn.AUDIO}.menuItem`),order:800,mediaType:gn.AUDIO,group:"common"});h(this,"updateProgressElement",M6)}getBlockProperties(){return{abstract:`[${T.t(`media.${gn.AUDIO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=b("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return u(S$,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(e,o){const r=b("audio",[],e);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",L6(e,o)}}const Lf=new D$;w("video-resizer");function R6(n){return n&&Te(n)&&Ne(n)==="video"}const L$=50;class M${constructor(t){h(this,"currentResizableElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&(e&&R6(e)&&this.disableBlockResize(e),t&&R6(t))){const o=this.getVideoElement(t);if(!o)return;this.enableBlockResize(t,o)}});h(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=t.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(e.width,L$),r);this.currentResizableElement.style.width=`${i}px`});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const o=this.editor.getBlockData(e),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(e,{...o,width:r})});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return st(t).querySelector(":scope .video-container > video")}disableBlockResize(t){const e=this.editor.findCustom(`${j(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const o=this.editor.addCustom(`${j(t)}-resizer`,()=>new sa(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(t,e),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=e}}const R$=w("video");class O$ extends D6{constructor(){super(...arguments);h(this,"embedType",gn.VIDEO);h(this,"abstract",{mediaName:T.t(`media.${gn.VIDEO}.menuItem`),mediaIcon:Zw,menuItem:T.t(`media.${gn.VIDEO}.menuItem`),order:700,mediaType:gn.VIDEO,group:"common"});h(this,"updateProgressElement",M6);h(this,"createProgressElement",(e,o,r)=>{const i=b("video",["progress-video"],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,L6(e,o),Tr(r).then(s=>{const l=e.querySelector(".progress-video");l&&Pu(e)&&(l.src=s)})})}getBlockProperties(){return{abstract:`[${T.t(`media.${gn.VIDEO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["video-container","embed-selected-content","drag-preview-element"],o),l=b("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,e.addCustom("video-resizer",()=>new M$(e)),r.width&&(l.style.width=`${r.width}px`),l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .video-container > video");return u(R$,s,"The media element not exist"),s.src!==i&&(s.src=i),s}}const Mf=new O$,qV="",N$={version:{latest:"\u5F53\u524D\u7248\u672C",insert:"{name} \u6DFB\u52A0",delete:"{name} \u5220\u9664",goBack:"\u8FD4\u56DE",revertVersion:"\u8FD8\u539F\u5185\u5BB9",play:"\u64AD\u653E\u5386\u53F2\u64CD\u4F5C",versionList:"\u5386\u53F2\u7248\u672C {count}",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C {from}",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4"}},P$={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Versions ({count})",unknown:"Unknown version",restoreFrom:"Reverted from {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version."}};T.mergeLang({"zh-CN":N$,"en-US":P$});var O6=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(O6||{});const vi="--op-color",yi="--op-selected-color",WV="";class $${constructor(t){h(this,"root");this.content=t;const e=b("div",["dialog-root"],null);e.append(t),this.root=e}show(t=document.body){t.append(this.root)}hide(){this.root.remove()}destroy(){}}const{t:ki}=T,N6=w("version-list");class _${constructor(t){h(this,"activeVersionElement");h(this,"versionsList");h(this,"versionsListHeader");h(this,"handleClickVersionItem",t=>{const o=t.target.closest(".dialog-version-list-item");if(this.isVersionElement(o)){this.toggleActiveVersionElement(o);const r=this.getVersionFromElement(o),{onSelectVersion:i}=this.options;i(r)}});this.options=t;const{versions:e,defaultSelectedIndex:o=0}=t,r=b("div",["version-dialog-list-header"],null,"count");r.innerText=ki("version.versionList",{count:`${e.length}`});const i=b("div",["version-dialog-list"],null),s=this.convertVersionsToFragment(e);i.append(s);const l=i.children[o];R(l,"active"),this.activeVersionElement=l,this.versionsList=i,this.versionsListHeader=r,i.onclick=this.handleClickVersionItem}get isSelectedFirstVersion(){return!!this.activeVersionElement&&this.versionsList.firstChild===this.activeVersionElement}get isSelectedLastVersion(){return!!this.activeVersionElement&&this.versionsList.lastChild===this.activeVersionElement}get beforeVersion(){return u(N6,this.activeVersionElement,"No active version element"),this.activeVersionElement.nextElementSibling?this.activeVersionElement.nextElementSibling.versionData:null}get beforeMajorVersion(){u(N6,this.activeVersionElement,"No active version element");let t=this.activeVersionElement.nextElementSibling;for(;t;){if(t.versionData.type)return t.versionData;t=t.nextElementSibling}return null}convertVersionsToFragment(t){const e=document.createDocumentFragment(),o=i=>{var l;let s;if(i.version!==-1){const c=new Date((l=i.created)!=null?l:i.version);s=`${c.toLocaleDateString()} ${c.toLocaleTimeString()}`}else s=ki("version.latest");return s},r=(i,s,l,c=!1)=>{var p;const a=b("div",["dialog-version-list-item"],e);a.versionData=i,s&&R(a,"child");const d=b("div",["dialog-version-list-item-title"],a);if(b("div",["dialog-version-list-item-date"],d,o(i)),c&&b("div",["dialog-version-list-item-now-ver"],d,ki("version.latest")),typeof i.source=="object"&&((p=i.source)==null?void 0:p.restore)){const A=i.source.restore,k=l.find(M=>M.version==A),v=k?o(k):ki("version.unknown"),x=ki("version.restoreFrom",{from:v}),E=ki("version.restoreInfo"),L=b("div",["dialog-version-item-from-container"],a);b("div",["dialog-version-item-from-main"],L,x),b("div",["dialog-version-item-from-info"],L,E)}const f=b("ul",["dialog-version-list-item-authors"],a),m=A=>{const k=b("li",["dialog-version-list-item-author"],f),v=b("span",["dialog-version-list-item-mark-author"],k);v.style.background=this.options.getMarkColor(A),b("span",["dialog-version-list-item-author-name"],k,A.displayName)};if(this.options.useCreatedBy)if(i.createdBy){const A=i.createdBy;m(A)}else i.authors&&i.authors.length>0&&i.authors.forEach(A=>{m(A)});else if(i.authors&&i.authors.length>0)i.authors.forEach(A=>{m(A)});else if(i.createdBy){const A=i.createdBy;m(A)}};return t.forEach((i,s)=>{r(i,!1,t,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,t,!1)})}),e}isVersionElement(t){return t?rt(t,"dialog-version-list-item"):!1}getVersionFromElement(t){return t.versionData}get activeVersion(){return this.getVersionFromElement(this.activeVersionElement)}toggleActiveVersionElement(t){this.activeVersionElement!==t&&(H(this.activeVersionElement,"active"),R(t,"active"),this.activeVersionElement=t)}selectVersionByVersionNum(t){const e=Array.from(this.versionsList.children).find(o=>o.versionData.version===t);return this.isVersionElement(e)?(this.toggleActiveVersionElement(e),this.getVersionFromElement(e)):null}render(t){t.innerHTML="",t.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null}}class F${constructor(t,e){this.doc=t,this.user=e}onDeleteBlock(t,e){this.doc.onDeleteBlock(t,e,this.user)}onInsertBlock(t,e,o){this.doc.onInsertBlock(t,e,o,this.user)}onUpdateBlockText(t,e,o){this.doc.onUpdateBlockText(t,e,o,this.user)}onUpdateBlockData(t,e,o){this.doc.onUpdateBlockData(t,e,o,this.user)}onCreateContainer(t,e){this.doc.onCreateContainer(t,e,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}function H$(n){return new Promise(t=>{setTimeout(t,n)})}async function j$(n,t,e,o){for(const r of e){const i=new F$(n,r.user);t.parseHistoryData(r,i),o.play&&await H$(o.speed||150)}}const z$=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
690
690
  <path d="M0 0h24v24H0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "0.0.3-beta.78",
3
+ "version": "0.0.3-beta.79",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",