@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 9.43 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[8198],{74858:(t,e,n)=>{n.d(e,{Er:()=>s,X0:()=>i});var r=n(24620),o=n(22871);function i(t,e,n){var i,s;return n?(i="[x]",s="[ ]"):(i="[ ]",s="[x]"),(0,o.v)(t,(function(t){return(0,r.replace_all_function)(t,i,(function(t){return t===e?s:i}))}))}function s(t){for(var e=t.trim().split("\n"),n=0,r=e.length,o=0<=r;o?n<r:n>r;o?n++:n--)if(""===e[n].trim())return n===e.length-1?t:e.slice(0,n).join("\n");return t}},38198:(t,e,n)=>{n.r(e),n.d(e,{Actions:()=>O});var r=n(20812),o=n(95788),i=n(74858),s=n(23040),a=n.n(s),c=n(5010),l=n(78193),u=n(86016),f=n(67351),_=n(85460),h=n(1527),p=n(83815),y=n(97891);function d(t,e,n,r,o,i,s){try{var a=t[i](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,o)}function v(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){d(i,r,o,s,a,"next",t)}function a(t){d(i,r,o,s,a,"throw",t)}s(void 0)}))}}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function g(t,e,n){return g="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=b(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}},g(t,e,n||t)}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}function w(t,e){return!e||"object"!==S(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function E(t,e){return E=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},E(t,e)}var S=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};var k=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},O=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&E(t,e)}(c,t);var e,n,s=(e=c,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=b(e);if(n){var o=b(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return w(this,t)});function c(){var t;return m(this,c),(t=s.apply(this,arguments)).slateEditors={},t}var d=c.prototype;return d._init2=function(){var t=this;this.is_public||(this._init_syncstring_value(),this._init_spellcheck(),this.store.on("close-frame",(function(e){var n=e.id;"slate"==e.type&&t.slateEditors[n]&&delete t.slateEditors[n]})),this._syncstring.on("change",(0,r.debounce)(this.updateTableOfContents.bind(this),1500)))},d._raw_default_frame_tree=function(){return this.is_public?{type:"markdown"}:{direction:"col",type:"node",first:{type:"cm"},second:{type:"slate"}}},d.toggle_markdown_checkbox=function(t,e,n){this.set_syncstring_to_codemirror(t);var r=(0,i.X0)(this._syncstring.to_str(),e,n);this._syncstring.from_str(r),this.set_codemirror_to_syncstring(),this._syncstring.save(),this.setState({value:r})},d.print=function(t){var e=this._get_frame_node(t);if(e)if("cm"!==e.get("type"))try{(0,l.kX)({html:a()("#frame-".concat(t)).html(),project_id:this.project_id,path:this.path})}catch(t){this.set_error(t)}else g(b(c.prototype),"print",this).call(this,t)},d.delete_trailing_whitespace=function(){},d.undo=function(t){var e;if("slate"==this._get_frame_type(t)){var n=this._syncstring.undo().to_str();this._syncstring.set(n,!0),this._syncstring.commit(),null===(e=this._get_cm())||void 0===e||e.setValueNoJump(n,!0)}else g(b(c.prototype),"undo",this).call(this,t)},d.redo=function(t){var e;if("slate"==this._get_frame_type(t)){if(this._syncstring.in_undo_mode()){var n=this._syncstring.redo();if(null!=n){var r=n.to_str();this._syncstring.set(r,!0),this._syncstring.commit(),null===(e=this._get_cm())||void 0===e||e.setValueNoJump(r,!0)}}}else g(b(c.prototype),"redo",this).call(this,t)},d.format_action=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this,o=this,i=function(){return g(b(c.prototype),"format_action",r)};return v((function(){var r;return k(this,(function(s){return r=o._get_active_id(),"slate"!=o._get_frame_type(r)||null==o.slateEditors[r]?(i().call(o,t,e,n),[2]):((0,f.e)(o.slateEditors[r],t,e),[2])}))}))()},d.getSlateEditor=function(t){if(null==t){for(var e in this.slateEditors)return this.slateEditors[e];throw Error("no slate editors")}return this.slateEditors[t]},d.registerSlateEditor=function(t,e){this.slateEditors[t]=e},d.show_table_of_contents=function(){var t=this;return v((function(){var e;return k(this,(function(n){switch(n.label){case 0:return e=t.show_focused_frame_of_type("markdown_table_of_contents","col",!0,1/3),[4,(0,o.delay)(0)];case 1:return n.sent(),"closed"===t._state||t.set_active_id(e,!0),[2]}}))}))()},d.updateTableOfContents=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if("closed"!=this._state&&null!=this._syncstring&&(t||this.get_matching_frame({type:"markdown_table_of_contents"}))){var e=(0,_.fromJS)((0,h.parseTableOfContents)(this._syncstring.to_str()));this.setState({contents:e})}},d.scrollToHeading=function(t){var e=this;return v((function(){var n,r;return k(this,(function(i){switch(i.label){case 0:return null==(n=e.show_focused_frame_of_type("slate"))?[2]:null!=(r=e.getSlateEditor(n))?[3,2]:[4,(0,o.delay)(1)];case 1:i.sent(),r=e.getSlateEditor(n),i.label=2;case 2:return null==r||(0,u.UR)(r,parseInt(t.id)),[2]}}))}))()},d.edit=function(t){this.is_public||this.set_frame_type(t,"slate")},d.readonly_view=function(t){this.set_frame_type(t,"markdown")},d.sync_cm_to_slate=function(t,e){var n=this;return v((function(){var r,i,s,a;return k(this,(function(c){switch(c.label){case 0:return null==(r=e._cm[t])||null==(i=n.show_focused_frame_of_type("slate"))?[2]:(n.set_active_id(t),null!=(s=n.getSlateEditor(i))?[3,2]:[4,(0,o.delay)(1)]);case 1:c.sent(),s=n.getSlateEditor(i),c.label=2;case 2:if(null==s)return[2];if(null==(a=(0,p.uk)({markdown:r.getValue(),pos:r.getDoc().getCursor(),editor:s})))return[2];try{(0,p.zT)(s,a)}catch(t){console.log("point not found",a)}return[2]}}))}))()},d.sync_slate_to_cm=function(t){var e,n=this.getSlateEditor(t);if(null!=n){var r=null===(e=n.selection)||void 0===e?void 0:e.focus;if(null!=r){var o=(0,p.WM)(n,r);null!=o&&this.programmatical_goto_line(o.line+1,!0,!1,void 0,o.ch)}}},d.sync=function(t,e){var n=this;return v((function(){var r;return k(this,(function(o){if(!(r=n._get_frame_node(t)))return[2];switch(r.get("type")){case"slate":return n.sync_slate_to_cm(t),[2];case"cm":return n.sync_cm_to_slate(t,e),[2]}return[2]}))}))()},d.help=function(){(0,y.open_new_tab)("https://doc.cocalc.com/markdown.html")},c}(c.e)},22871:(t,e,n)=>{function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}e.v=void 0;var o=n(83841),i=n(24620);e.v=function(t,e){var n,s,a,c;(0,i.is_array)(e)||(e=[e]),t=(a=(0,o.remove_math)(t),c=2,s=function(t){if(Array.isArray(t))return t}(a)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);s=!0);}catch(t){a=!0,o=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw o}}return i}}(a,c)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(a,c)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],n=s[1];var l=!0,u=!1,f=void 0;try{for(var _,h=e[Symbol.iterator]();!(l=(_=h.next()).done);l=!0)t=(0,_.value)(t)}catch(t){u=!0,f=t}finally{try{l||null==h.return||h.return()}finally{if(u)throw f}}return(0,o.replace_math)(t,n)}}}]);