@pdftron/webviewer
Version:
[WebViewer](https://www.apryse.com/webviewer) is a powerful JavaScript Document SDK and UI Component Library that is a part of the [Apryse PDF SDK](https://www.apryse.com). It provides a slick, out-of-the-box responsive UI that interacts with the core lib
9 lines (8 loc) • 3.74 kB
JavaScript
/** Notice * This file contains works from many authors under various (but compatible) licenses. Please see core.txt for more information. **/
(function(){(window.wpCoreControlsBundle=window.wpCoreControlsBundle||[]).push([[22],{703:function(wa,ua,e){e.r(ua);var ka=e(0),pa=e(7),na=e(2);wa=e(50);var ia=e(39),ca=e(21);e=function(){function ba(){this.init()}ba.prototype.init=function(){this.OAa=!1;this.Xh=this.Rq=this.connection=null;this.dl={};this.ga=this.vT=null};ba.prototype.RD=function(x){for(var y=this,r=0;r<x.length;++r){var b=x[r];switch(b.at){case "create":this.dl[b.author]||(this.dl[b.author]=b.aName);this.KOa(b);break;case "modify":this.ga.Iu(b.xfdf).then(function(h){y.ga.Ib(h[0])});
break;case "delete":b="<delete><id>".concat(b.aId,"</id></delete>"),this.ga.Iu(b)}}};ba.prototype.KOa=function(x){var y=this;this.ga.Iu(x.xfdf).then(function(r){r=r[0];r.authorId=x.author;y.ga.Ib(r);y.ga.trigger(pa.d.UPDATE_ANNOTATION_PERMISSION,[r])})};ba.prototype.lNa=function(x,y,r){this.Rq&&this.Rq(x,y,r)};ba.prototype.preloadAnnotations=function(x){this.addEventListener("webViewerServerAnnotationsEnabled",this.lNa.bind(this,x,"add",{imported:!1}),{once:!0})};ba.prototype.initiateCollaboration=
function(x,y,r){var b=this;if(x){b.Xh=y;b.ga=r.ja();r.addEventListener(pa.i.DOCUMENT_UNLOADED,function(){b.disableCollaboration()});b.B5a(x);var h=new XMLHttpRequest;h.addEventListener("load",function(){if(200===h.status&&0<h.responseText.length)try{var n=JSON.parse(h.responseText);b.connection=exports.da.g7a(Object(ia.l)(b.Xh,"blackbox/"),"annot");b.vT=n.id;b.dl[n.id]=n.user_name;b.ga.l4(n.id);b.connection.xab(function(f){f.t&&f.t.startsWith("a_")&&f.data&&b.RD(f.data)},function(){b.connection.send({t:"a_retrieve",
dId:x});b.trigger(ba.Events.WEBVIEWER_SERVER_ANNOTATIONS_ENABLED,[b.dl[n.id],b.vT])},function(){b.disableCollaboration()})}catch(f){Object(na.g)(f.message)}});h.open("GET",Object(ia.l)(this.Xh,"demo/SessionInfo.jsp"));h.withCredentials=!0;h.send();b.OAa=!0;b.ga.yma(function(n){return b.dl[n.Author]||n.Author})}else Object(na.g)("Document ID required for collaboration")};ba.prototype.disableCollaboration=function(){this.Rq&&(this.ga.removeEventListener(ca.a.Events.ANNOTATION_CHANGED,this.Rq),this.Rq=
null);this.connection&&this.connection.ix();this.ga&&this.ga.l4("Guest");this.init();this.trigger(ba.Events.WEBVIEWER_SERVER_ANNOTATIONS_DISABLED)};ba.prototype.B5a=function(x){var y=this;this.Rq&&this.ga.removeEventListener(ca.a.Events.ANNOTATION_CHANGED,this.Rq);this.Rq=function(r,b,h){return Object(ka.c)(this,void 0,void 0,function(){var n,f,a,w,aa,z,fa,ea,ma;return Object(ka.e)(this,function(ha){switch(ha.label){case 0:if(h.imported)return[2];n={t:"a_".concat(b),dId:x,annots:[]};return[4,y.ga.Yca()];
case 1:f=ha.aa();"delete"!==b&&(a=(new DOMParser).parseFromString(f,"text/xml"),w=new XMLSerializer);for(aa=0;aa<r.length;aa++)z=r[aa],ea=fa=void 0,"add"===b?(fa=a.querySelector('[name="'.concat(z.Id,'"]')),ea=w.serializeToString(fa),ma=null,z.InReplyTo&&(ma=y.ga.Kf(z.InReplyTo).authorId||"default"),n.annots.push({at:"create",aId:z.Id,author:y.vT,aName:y.dl[y.vT],parent:ma,xfdf:"<add>".concat(ea,"</add>")})):"modify"===b?(fa=a.querySelector('[name="'.concat(z.Id,'"]')),ea=w.serializeToString(fa),
n.annots.push({at:"modify",aId:z.Id,xfdf:"<modify>".concat(ea,"</modify>")})):"delete"===b&&n.annots.push({at:"delete",aId:z.Id});0<n.annots.length&&y.connection.send(n);return[2]}})})}.bind(y);this.ga.addEventListener(ca.a.Events.ANNOTATION_CHANGED,this.Rq)};ba.Events={WEBVIEWER_SERVER_ANNOTATIONS_ENABLED:"webViewerServerAnnotationsEnabled",WEBVIEWER_SERVER_ANNOTATIONS_DISABLED:"webViewerServerAnnotationsDisabled"};return ba}();Object(wa.b)(e);ua["default"]=e}}]);}).call(this || window)