/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var showdown__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
/* harmony import */ var showdown__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(showdown__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var showdown_ghost_footnotes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
/* harmony import */ var showdown_ghost_footnotes__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(showdown_ghost_footnotes__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var showdown_toc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
/* harmony import */ var _css_jsNotebook_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
/* harmony import */ var _css_jsNotebook_scss__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_css_jsNotebook_scss__WEBPACK_IMPORTED_MODULE_3__);
///////////////////////////////////////////
// //
// jsNotebook shared logic (0-install) //
// //
///////////////////////////////////////////
//0-install jsNotebook logic
//Copyright (c) 2020 djulien
//rev history:
// 0.20.7 7/15/20 DJ reworked to use Showndown, webpack
//catch more bugs
debug("loading jsNotebook main logic, doc state:", document.readyState);
//NOTE: need import() rather than import ... from syntax; see https://github.com/parcel-bundler/parcel/issues/2358
//"https://unpkg.com/showdown@1.9.1/dist/showdown.min.js";
//const footnotes = require("showdown-ghost-footnotes");
//"https://unpkg.com/showdown-ghost-footnotes@0.0.6/dist/showdown-ghost-footnotes.min.js"; //https://github.com/tivie/showdown-ghost-footnotes
//const toc = require("showdown-toc");
//"https://unpkg.com/showdown-toc@1.0.1/dist/index.js"; //https://github.com/tivie/showdown-toc
const VER = "0.20.7.D";
//load CSS here so caller doesn't see it:
//import "./jsNotebook.css";
//import BkgImage from './rings.png';
//import "./index.html"; //kludge: copy parent HTML file to output
const isHTML_re = /^\s*]*>/i;
//const str = "abc ghi jkl mno";
//console.log(fixup(str, true));
//////////////////////////////////////////////////////////////////////////////
////
/// Viewer/editor (browser side)
//
const opts =
{
omitExtraWLInCodeBlocks: true, //omit trailing newlines in code blocks
parseImgDimensions: true, //image dimensions; ex: 
// simplifiedAutoLink: true, //enable automatic linking to urls
strikethrough: true, //strikethrough syntax. ~~strikethrough~~
tables: true, //tables. Example: | h1 | \n |:------| \n | 100 |
tasklists: true, //GFM tasklists; ex: - [x] This
simpleLineBreaks: true, //line breaks as
, without 2 spaces at line end
backslashEscapesHTMLTags: true, //HTML tag escaping; ex: \foo\
underline: true, //underline double/triple underscores; ex: __underlined word__.
// completeHTMLDocument: true, //output complete , , tags
metadata: true, //doc metadata at top of doc between ««« and »»» or --- and ---
extensions: [showdown_ghost_footnotes__WEBPACK_IMPORTED_MODULE_1__, Object(showdown_toc__WEBPACK_IMPORTED_MODULE_2__["default"])({ toc: [] })],
};
const converter = new showdown__WEBPACK_IMPORTED_MODULE_0__["Converter"](opts);
converter.setFlavor('github'); //strike-thru, checklist, etc
//can only use "await" inside async function:
async function main()
{
//don't start until deferred script(s) load:
console.log("ready state:", document.readyState);
if (document.readyState != "complete")
if ((document.readyState == "loading") || !document.documentElement.app)
await wait4event("DOMContentLoaded");
debug("dom READY(fulfilled)");
const notes = document.getElementById("notes") || document.body; //can be named element or just body
notes.isHTML = function() { return this.innerHTML.match(isHTML_re); }; ///^\s*]*>/i); };
notes.md2html = function(force)
{
if (!force && this.isHTML()) return;
this.svtext = this.innerHTML;
const html = fixup(converter.makeHtml(fixup(this.innerHTML, false)), true); //.replace(/\[toc\]/gi, "\n$&")) //, pathlib.basename(reqpath, pathlib.extname(reqpath)));
// .replace(/\bp>\s*\s*(?=<(ul|ol|li)\b)/gi, ">@")
// .replace(/\s+(?=- (console.log("trim", input.slice(index - 5, index + 20)), "")); //""); //"
=one space/newline only, to allow extra space to be forced; positive look-ahead
// .replace(/<(?<=(ul|ol)\b[^>]*>)\s+- html", html.length);
// if (numkeys(main.metadata)) debug("got metadata"/*.brightBlue*/, JSON.stringify(main.metadata));
// else debug("NO metadata");
};
notes.html2md = function(force)
{
if (!force && !notes.isHTML()) return;
this.innerHTML = this.metadata?
`----\n${this.metadata}\n----\n` + this.svtext:
this.svtext;
};
//const s2d = style2dict(styleof(notes));
//debug(Object.keys(s2d).join(", "));
debug(`old notes class '${notes.classList}', bgcolor: '${style2dict(styleof(notes)).backgroundColor}'`, "inner", notes.innerHTML.length + ":" + notes.innerHTML.slice(0, 30) + " ...");
notes.md2html();
notes.classList.add("jsNotebook");
///////////////// notes.setAttribute("contentEditable", true); //mainly for dev/debug
//user_pref("capability.policy.policynames", "allowclipboard");
//user_pref("capability.policy.allowclipboard.sites", "https://www.mozilla.org");
//user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
//user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");
/*
notes.addEventListener('focus', () =>
{
debug("focus", notes.isHTML());
notes.md2html();
});
notes.addEventListener('blur', () =>
{
debug("blur", notes.isHTML());
notes.html2md();
});
*/
notes.addEventListener('input', () =>
{
debug('edited', notes.isHTML());
// setTimeout(notes.html2ms, 0.5e3);
notes.dirty = true;
});
debug(`new notes class '${notes.classList}', bgcolor: '${style2dict(styleof(notes)).backgroundColor}'`, "inner", notes.innerHTML.length + ":" + notes.innerHTML.slice(0, 30) + " ...");
drag_and_drop();
}
main(); //could use IIFE, but this is easier to read
//////////////////////////////////////////////////////////////////////////////
////
/// drag + drop
//
//from MDN API doc, example at: jsfiddle.net/radonirinamaminiaina/zfnj5rv4/
var dragged;
function drag_and_drop()
{
console.log("set up drag+drop");
/* events fired on the draggable target */
document.addEventListener("drag", function( event ) {
}, false);
document.addEventListener("dragstart", function( event ) {
// store a ref. on the dragged elem
dragged = event.target;
// make it half transparent
event.target.style.opacity = .5;
}, false);
document.addEventListener("dragend", function( event ) {
// reset the transparency
event.target.style.opacity = "";
}, false);
/* events fired on the drop targets */
document.addEventListener("dragover", function( event ) {
// prevent default to allow drop
event.preventDefault();
}, false);
document.addEventListener("dragenter", function( event ) {
// highlight potential drop target when the draggable element enters it
if ( event.target.className == "dropzone" ) {
event.target.style.background = "purple";
}
//TODO: DataTransfer.setDragImage()
}, false);
document.addEventListener("dragleave", function( event ) {
// reset background of potential drop target when the draggable element leaves it
if ( event.target.className == "dropzone" ) {
event.target.style.background = "";
}
//TODO: DataTransfer.setDragImage()
}, false);
document.addEventListener("drop", function( event )
{
// prevent default action (open as link for some elements)
event.preventDefault();
console.log("DROP: ", event.dataTransfer.types.length, ...event.dataTransfer.types);
for (item of event.dataTransfer.items)
{
// if (item.type
item.getAsString(theString => { if (theString) console.log("got str", theString); })
const theFile = item.getAsFile();
if (!theFile)
{
// move dragged elem to the selected drop target
if ( event.target.className == "dropzone" ) {
event.target.style.background = "";
dragged.parentNode.removeChild( dragged );
event.target.appendChild( dragged );
}
continue;
}
console.log("dropped a file: ", theFile); //Object.keys(theFile));
console.log("name:", theFile.name, "size:", theFile.size, "type:", theFile.type, "modified:", theFile.lastModifiedDate);
const reader = new FileReader()
reader.onloadend = event => {
if (event.target.readyState !== FileReader.DONE)
return console.log('Failed to load file');
// ? resolve({name: file.name, fullpath: fullpath, source: convert(event.target.result)})
const contents = convert(event.target.result);
console.log("file name", theFile.name, "contents", contents.length, contents);
const newHTML = document.open("text/html", "replace");
newHTML.write(contents);
newHTML.close();
console.log("REPLACED DOC");
}
// return new Promise(function (resolve, reject) {
reader.readAsArrayBuffer(theFile)
//NO WORKY: console.log("got dropped:", item.getData());
}
}, false); //no bubble
}
// convert binary to text
function convert (buffer) {
let binary = ''
const bytes = new Uint8Array(buffer)
let length = bytes.byteLength
for (let i = 0; i < length; i++) {
binary += String.fromCharCode(bytes[i])
}
return binary
}
//////////////////////////////////////////////////////////////////////////////
////
/// misc helpers
//
//fix up markdown before/after handing it to Showdown:
function fixup(mdtext, ishtml = mdtext.match(isHTML_re))
{
return !ishtml?
no_shebang(mdtext): //strip shebang (interferes with metadata detect)
mdtext //kludge: prevent unwanted line breaks in output
.replace(/\s+(?=<(?:no)?script\b)/gi, "") //"@") //+ look-ahead
.replace(/(?<=<\/(?:no)?script\b[^>]*>)\s+/gi, "") //"#") //+ look-behind
.replace(/\s+(?=