index.js000644 0000007477 14341503510007364 0ustar00000000 000000 !function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";var n=this&&this.__awaiter||function(t,e,o,n){return new(o||(o=Promise))((function(r,i){function u(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(u,a)}l((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const r=o(1),i=o(2);r.default.plugins.register({onStart:function(){return n(this,void 0,void 0,(function*(){yield r.default.contentScripts.register(i.ContentScriptType.MarkdownItPlugin,"net.gagnepain.turnToChart","./turnToChart.js")}))}})},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=joplin},function(t,e,o){"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ContentScriptType=e.SettingStorage=e.AppType=e.SettingItemSubType=e.SettingItemType=e.ToolbarButtonLocation=e.isContextMenuItemLocation=e.MenuItemLocation=e.ModelType=e.ImportModuleOutputFormat=e.FileSystemItem=void 0,function(t){t.File="file",t.Directory="directory"}(e.FileSystemItem||(e.FileSystemItem={})),function(t){t.Markdown="md",t.Html="html"}(e.ImportModuleOutputFormat||(e.ImportModuleOutputFormat={})),function(t){t[t.Note=1]="Note",t[t.Folder=2]="Folder",t[t.Setting=3]="Setting",t[t.Resource=4]="Resource",t[t.Tag=5]="Tag",t[t.NoteTag=6]="NoteTag",t[t.Search=7]="Search",t[t.Alarm=8]="Alarm",t[t.MasterKey=9]="MasterKey",t[t.ItemChange=10]="ItemChange",t[t.NoteResource=11]="NoteResource",t[t.ResourceLocalState=12]="ResourceLocalState",t[t.Revision=13]="Revision",t[t.Migration=14]="Migration",t[t.SmartFilter=15]="SmartFilter",t[t.Command=16]="Command"}(e.ModelType||(e.ModelType={})),function(t){t.File="file",t.Edit="edit",t.View="view",t.Note="note",t.Tools="tools",t.Help="help",t.Context="context",t.NoteListContextMenu="noteListContextMenu",t.EditorContextMenu="editorContextMenu",t.FolderContextMenu="folderContextMenu",t.TagContextMenu="tagContextMenu"}(n=e.MenuItemLocation||(e.MenuItemLocation={})),e.isContextMenuItemLocation=function(t){return[n.Context,n.NoteListContextMenu,n.EditorContextMenu,n.FolderContextMenu,n.TagContextMenu].includes(t)},function(t){t.NoteToolbar="noteToolbar",t.EditorToolbar="editorToolbar"}(e.ToolbarButtonLocation||(e.ToolbarButtonLocation={})),function(t){t[t.Int=1]="Int",t[t.String=2]="String",t[t.Bool=3]="Bool",t[t.Array=4]="Array",t[t.Object=5]="Object",t[t.Button=6]="Button"}(e.SettingItemType||(e.SettingItemType={})),function(t){t.FilePathAndArgs="file_path_and_args",t.FilePath="file_path",t.DirectoryPath="directory_path"}(e.SettingItemSubType||(e.SettingItemSubType={})),function(t){t.Desktop="desktop",t.Mobile="mobile",t.Cli="cli"}(e.AppType||(e.AppType={})),function(t){t[t.Database=1]="Database",t[t.File=2]="File"}(e.SettingStorage||(e.SettingStorage={})),function(t){t.MarkdownItPlugin="markdownItPlugin",t.CodeMirrorPlugin="codeMirrorPlugin"}(e.ContentScriptType||(e.ContentScriptType={}))}]);manifest.json000644 0000000717 14341503510010406 0ustar00000000 000000 { "manifest_version": 1, "id": "net.gagnepain.turnToChart", "app_min_version": "2.8", "version": "1.9.3", "name": "turnToChart", "description": "Transforms a markdown or csv table into an HTML chart", "author": "Samuel Gagnepain", "homepage_url": "https://github.com/Winbee/joplin-turn-to-chart", "repository_url": "https://github.com/Winbee/joplin-turn-to-chart", "keywords": ["joplin", "table", "graph", "chart", "ui"], "categories": [] } turnToChart.js000644 0000701075 14341503515010532 0ustar00000000 000000 exports.default=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(1);t.default=function(e){return{plugin:function(e,t){const n=e.renderer.rules.fence||function(e,t,n,r,i){return i.renderToken(e,t,n,r,i)};e.renderer.rules.fence=function(e,t,i,o,a){const u=e[t];if("turnToChart"!==u.info)return n(e,t,i,o,a);return r.generateHtmlString(u.content).data}},assets:function(){return[]}}}},function(e,t,n){"use strict";n.r(t),n.d(t,"generateHtmlString",(function(){return Vf}));var r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},i={exports:{}}; /* @license Papa Parse v5.3.2 https://github.com/mholt/PapaParse License: MIT */function o(e){switch(e){case 9:case 32:return!0}return!1}function a(e){const t=[];let n=0;const r=e.length;let i,o=!1,a=0,u="";for(i=e.charCodeAt(n);n=this._config.preview;if(r)t.postMessage({results:u,workerId:a.WORKER_ID,finished:l});else if(w(this._config.chunk)&&!n){if(this._config.chunk(u,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);u=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(u.data),this._completeResults.errors=this._completeResults.errors.concat(u.errors),this._completeResults.meta=u.meta),this._completed||!l||!w(this._config.complete)||u&&u.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),l||u&&u.meta.paused||this._nextChunk(),u}this._halted=!0},this._sendError=function(e){w(this._config.error)?this._config.error(e):r&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function l(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),s.call(this,e),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),n||(t.onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var r in e)t.setRequestHeader(r,e[r])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+i)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}n&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){var e;4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=(null===(e=t.getResponseHeader("Content-Range"))?-1:parseInt(e.substring(e.lastIndexOf("/")+1))),this.parseChunk(t.responseText)))},this._chunkError=function(e){var n=t.statusText||e;this._sendError(new Error(n))}}function c(e){var t,n;(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),s.call(this,e);var r=typeof FileReader<"u";this.stream=function(e){this._input=e,n=e.slice||e.webkitSlice||e.mozSlice,r?((t=new FileReader).onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function f(e){var t;s.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,n=this._config.chunkSize;return n?(e=t.substring(0,n),t=t.substring(n)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function h(e){s.call(this,e=e||{});var t=[],n=!0,r=!1;this.pause=function(){s.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){s.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):n=!0},this._streamData=x((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),n&&(n=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=x((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=x((function(){this._streamCleanUp(),r=!0,this._streamData("")}),this),this._streamCleanUp=x((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function d(e){var t,n,r,i=Math.pow(2,53),o=-i,u=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,s=/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/,l=this,c=0,f=0,h=!1,d=!1,m=[],y={data:[],errors:[],meta:{}};if(w(e.step)){var v=e.step;e.step=function(t){if(y=t,S())k();else{if(k(),0===y.data.length)return;c+=t.data.length,e.preview&&c>e.preview?n.abort():(y.data=y.data[0],v(y,l))}}}function x(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function k(){return y&&r&&(T("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),r=!1),e.skipEmptyLines&&(y.data=y.data.filter((function(e){return!x(e)}))),S()&&function(){if(y)if(Array.isArray(y.data[0])){for(var t=0;S()&&t=m.length?"__parsed_extra":m[r]),e.transform&&(a=e.transform(a,o)),a=M(o,a),"__parsed_extra"===o?(i[o]=i[o]||[],i[o].push(a)):i[o]=a}return e.header&&(r>m.length?T("FieldMismatch","TooManyFields","Too many fields: expected "+m.length+" fields but parsed "+r,f+n):r=r.length/2?"\r\n":"\r"}(i,s)),r=!1,e.delimiter)w(e.delimiter)&&(e.delimiter=e.delimiter(i),y.meta.delimiter=e.delimiter);else{var l=function(t,n,r,i,o){var u,s,l,c;o=o||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var f=0;f=u)return j(!0)}else for(F=c,c++;;){if(-1===(F=e.indexOf(t,F+1)))return h||x.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:b.length,index:c}),P();if(F===d-1)return P(e.substring(c,F).replace(E,t));if(t!==l||e[F+1]!==l){if(t===l||0===F||e[F-1]!==l){-1!==C&&C=u)return j(!0);break}x.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:b.length,index:c}),F++}}else F++}return P();function D(e){b.push(e),S=c}function R(t){var n=0;if(-1!==t){var r=e.substring(F+1,t);r&&""===r.trim()&&(n=r.length)}return n}function P(t){return h||(void 0===t&&(t=e.substring(c)),k.push(t),c=d,D(k),v&&L()),j()}function N(t){c=t,D(k),k=[],_=e.indexOf(r,c)}function j(e){return{data:b,errors:x,meta:{delimiter:n,linebreak:r,aborted:f,truncated:!!e,cursor:S+(a||0)}}}function L(){o(j()),b=[],x=[]}},this.abort=function(){f=!0},this.getCharIndex=function(){return c}}function m(e){var t=e.data,n=i[t.workerId],r=!1;if(t.error)n.userError(t.error,t.file);else if(t.results&&t.results.data){var o={abort:function(){r=!0,y(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:v,resume:v};if(w(n.userStep)){for(var a=0;a/g;function s(e){const t=e.replace(u,"").trim().split(/\r\n|\n\r|\n|\r/).map(e=>e.trim()),n=t.length-1;let r,s,l,c,f,h,d,p,g,m;if(t.length<2)throw new Error("String has less than 2 lines");if(f=1,l=0,l+1>t[f].length)throw new Error(`Line '${f+1}' is too small`);if(g=t[f].charCodeAt(l++),124!==g&&45!==g&&58!==g)return function(e){const t=function(e){let t=!1;for(let n=e.length-1;n>=0;n--){const r=e[n];if(null!=r&&""!==r)t=!0;else if(t)return n+1}return-1}(e),n=-1===t?e:e.slice(0,t-1),r=-1===t?[]:e.slice(t),o=i.exports.parse(n.join("\n"),{skipEmptyLines:!0});if(o.errors.length>0)throw new Error(o.errors[0].message);if(o.data.length<2)throw new Error("Csv is less than 2 lines");const a=o.data[0].length;if(a<2)throw new Error("First line has less than 2 columns");return o.data.forEach((e,t)=>{if(e.length!==a)throw new Error(`Line '${t+1}' has ${e.length} columns when first line has ${a} columns`)}),{headList:o.data[0],rowList:o.data.slice(1),configList:r}}(t);if(l+1>t[f].length)throw new Error(`Line '${f+1}' is too small`);if(m=t[f].charCodeAt(l++),124!==m&&45!==m&&58!==m&&!o(m))throw new Error(`Char '${m}' in line '${f+1}' is not a '|', '-', ':' or a space`);if(45===g&&o(m))throw new Error(`Second char '${m}' in line '${f+1}' should not be a space as previous char is "-"`);for(;l(e.customLocale="customLocale",e.legendOrientation="legendOrientation",e.legendTitle="legendTitle",e.xAxisType="xAxisType",e.xAxisFormat="xAxisFormat",e.xAxisNbOfTicks="xAxisNbOfTicks",e.xAxisOrigin="xAxisOrigin",e.yAxisFormat="yAxisFormat",e.yAxisNbOfTicks="yAxisNbOfTicks",e.yAxisOrigin="yAxisOrigin",e))(l||{}),c=(e=>(e.fromZero="from zero",e.fromDataBoundaries="from data boundaries",e))(c||{}),f=(e=>(e.vertical="vertical",e.horizontal="horizontal",e))(f||{}),h=(e=>(e.number="number",e.date="date",e.category="category",e))(h||{});const d=e=>"number"==typeof e&&isFinite(e),p=e=>{const t=new Map;return e.forEach(e=>{const n=e.indexOf(":"),r=e.substr(0,n).trim(),i=e.substr(n+1).trim();if(r&&i){let e,n;switch(r){case l.customLocale:e=r,n=i;break;case l.legendOrientation:e=r,n=Object.values(f).find(e=>e===i);break;case l.legendTitle:e=r,n=i;break;case l.xAxisType:e=r,n=Object.values(h).find(e=>e===i);break;case l.xAxisFormat:e=r,n=i;break;case l.xAxisNbOfTicks:e=r,d(+i)&&(n=i);break;case l.xAxisOrigin:e=r,n=Object.values(c).find(e=>e===i);break;case l.yAxisFormat:e=r,n=i;break;case l.yAxisOrigin:e=r,n=Object.values(c).find(e=>e===i);break;case l.yAxisNbOfTicks:e=r,d(+i)&&(n=i)}!t.has(e)&&e&&n&&t.set(e,n)}}),t},g=/(.*?)\[(.*?)\]/,m=/(.*?)\((.*?)\)/;var y,v={},b={exports:{}},x={}; /** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */function w(){if(y)return x;y=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),c=Symbol.for("react.lazy"),f=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},d=Object.assign,p={};function g(e,t,n){this.props=e,this.context=t,this.refs=p,this.updater=n||h}function m(){}function v(e,t,n){this.props=e,this.context=t,this.refs=p,this.updater=n||h}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=g.prototype;var b=v.prototype=new m;b.constructor=v,d(b,g.prototype),b.isPureReactComponent=!0;var w=Array.isArray,k=Object.prototype.hasOwnProperty,S={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function T(t,n,r){var i,o={},a=null,u=null;if(null!=n)for(i in void 0!==n.ref&&(u=n.ref),void 0!==n.key&&(a=""+n.key),n)k.call(n,i)&&!M.hasOwnProperty(i)&&(o[i]=n[i]);var s=arguments.length-2;if(1===s)o.children=r;else if(1