markmap-lib
Advanced tools
Comparing version 0.11.2 to 0.11.3
@@ -1,4 +0,4 @@ | ||
/*! markmap-lib v0.11.2 | MIT License */ | ||
/*! markmap-lib v0.11.3 | MIT License */ | ||
import _extends from '@babel/runtime/helpers/esm/extends'; | ||
import { persistCSS, persistJS, wrapFunction, Hook } from 'markmap-common'; | ||
import _extends from '@babel/runtime/helpers/esm/extends'; | ||
import { Remarkable } from 'remarkable'; | ||
@@ -10,3 +10,3 @@ import remarkableKatex from 'remarkable-katex'; | ||
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n"; | ||
const baseJs = [`https://cdn.jsdelivr.net/npm/d3@${"6.3.1"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.2"}`].map(src => ({ | ||
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.6.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.3"}`].map(src => ({ | ||
type: 'script', | ||
@@ -17,3 +17,12 @@ data: { | ||
})); | ||
function fillTemplate(data, assets, getOptions) { | ||
function fillTemplate(data, assets, extra) { | ||
if (typeof extra === 'function') { | ||
extra = { | ||
getOptions: extra | ||
}; | ||
} | ||
extra = _extends({ | ||
baseJs: BASE_JS | ||
}, extra); | ||
const { | ||
@@ -26,6 +35,6 @@ scripts, | ||
getMarkmap: () => window.markmap, | ||
getOptions, | ||
getOptions: extra.getOptions, | ||
data | ||
}; | ||
const jsList = [...persistJS(baseJs), ...(scripts ? persistJS(scripts, context) : []), ...persistJS([{ | ||
const jsList = [...persistJS(extra.baseJs), ...persistJS([...(scripts || []), { | ||
type: 'iife', | ||
@@ -52,4 +61,4 @@ data: { | ||
const name = 'katex'; | ||
function transform(transformHooks) { | ||
const name$1 = 'katex'; | ||
function transform$1(transformHooks) { | ||
transformHooks.parser.tap((md, features) => { | ||
@@ -59,3 +68,3 @@ md.use(remarkableKatex); | ||
after: () => { | ||
features[name] = true; | ||
features[name$1] = true; | ||
} | ||
@@ -104,12 +113,12 @@ }); | ||
__proto__: null, | ||
name: name, | ||
transform: transform | ||
name: name$1, | ||
transform: transform$1 | ||
}); | ||
const name$1 = 'prism'; | ||
function transform$1(transformHooks) { | ||
const name = 'prism'; | ||
function transform(transformHooks) { | ||
transformHooks.parser.tap((md, features) => { | ||
md.set({ | ||
highlight: (str, lang) => { | ||
features[name$1] = true; | ||
features[name] = true; | ||
let grammar = Prism.languages[lang]; | ||
@@ -142,4 +151,4 @@ | ||
__proto__: null, | ||
name: name$1, | ||
transform: transform$1 | ||
name: name, | ||
transform: transform | ||
}); | ||
@@ -267,2 +276,6 @@ | ||
if (token.lines) { | ||
payload.lines = token.lines; | ||
} | ||
if (type === 'heading') { | ||
@@ -269,0 +282,0 @@ depth = token.hLevel; |
@@ -1,6 +0,6 @@ | ||
/*! markmap-lib v0.11.2 | MIT License */ | ||
/*! markmap-lib v0.11.3 | MIT License */ | ||
'use strict'; | ||
var _extends = require('@babel/runtime/helpers/extends'); | ||
var markmapCommon = require('markmap-common'); | ||
var _extends = require('@babel/runtime/helpers/extends'); | ||
var remarkable = require('remarkable'); | ||
@@ -19,3 +19,3 @@ var remarkableKatex = require('remarkable-katex'); | ||
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n"; | ||
const baseJs = [`https://cdn.jsdelivr.net/npm/d3@${"6.3.1"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.2"}`].map(src => ({ | ||
const BASE_JS = [`https://cdn.jsdelivr.net/npm/d3@${"6.6.0"}`, `https://cdn.jsdelivr.net/npm/markmap-view@${"0.2.3"}`].map(src => ({ | ||
type: 'script', | ||
@@ -26,3 +26,12 @@ data: { | ||
})); | ||
function fillTemplate(data, assets, getOptions) { | ||
function fillTemplate(data, assets, extra) { | ||
if (typeof extra === 'function') { | ||
extra = { | ||
getOptions: extra | ||
}; | ||
} | ||
extra = _extends__default({ | ||
baseJs: BASE_JS | ||
}, extra); | ||
const { | ||
@@ -35,6 +44,6 @@ scripts, | ||
getMarkmap: () => window.markmap, | ||
getOptions, | ||
getOptions: extra.getOptions, | ||
data | ||
}; | ||
const jsList = [...markmapCommon.persistJS(baseJs), ...(scripts ? markmapCommon.persistJS(scripts, context) : []), ...markmapCommon.persistJS([{ | ||
const jsList = [...markmapCommon.persistJS(extra.baseJs), ...markmapCommon.persistJS([...(scripts || []), { | ||
type: 'iife', | ||
@@ -61,4 +70,4 @@ data: { | ||
const name = 'katex'; | ||
function transform(transformHooks) { | ||
const name$1 = 'katex'; | ||
function transform$1(transformHooks) { | ||
transformHooks.parser.tap((md, features) => { | ||
@@ -68,3 +77,3 @@ md.use(remarkableKatex__default); | ||
after: () => { | ||
features[name] = true; | ||
features[name$1] = true; | ||
} | ||
@@ -113,12 +122,12 @@ }); | ||
__proto__: null, | ||
name: name, | ||
transform: transform | ||
name: name$1, | ||
transform: transform$1 | ||
}); | ||
const name$1 = 'prism'; | ||
function transform$1(transformHooks) { | ||
const name = 'prism'; | ||
function transform(transformHooks) { | ||
transformHooks.parser.tap((md, features) => { | ||
md.set({ | ||
highlight: (str, lang) => { | ||
features[name$1] = true; | ||
features[name] = true; | ||
let grammar = Prism__default.languages[lang]; | ||
@@ -151,4 +160,4 @@ | ||
__proto__: null, | ||
name: name$1, | ||
transform: transform$1 | ||
name: name, | ||
transform: transform | ||
}); | ||
@@ -276,2 +285,6 @@ | ||
if (token.lines) { | ||
payload.lines = token.lines; | ||
} | ||
if (type === 'heading') { | ||
@@ -278,0 +291,0 @@ depth = token.hLevel; |
{ | ||
"name": "markmap-lib", | ||
"version": "0.11.2", | ||
"version": "0.11.3", | ||
"description": "Visualize your Markdown as mindmaps with Markmap", | ||
@@ -12,8 +12,9 @@ "author": "Gerald <gera2ld@live.com>", | ||
"dev": "rollup -wc rollup.conf.js", | ||
"clean": "del dist", | ||
"clean": "del-cli dist", | ||
"prebuild": "run-s ci clean", | ||
"prepublishOnly": "run-s build", | ||
"ci": "run-s lint", | ||
"build:types": "tsc", | ||
"build:js": "rollup -c rollup.conf.js", | ||
"prebuild": "npm run ci && npm run clean", | ||
"prepublishOnly": "npm run build", | ||
"ci": "npm run lint", | ||
"build": "tsc && npm run build:js", | ||
"build": "run-s build:types build:js", | ||
"lint": "eslint --ext .ts ." | ||
@@ -42,3 +43,3 @@ }, | ||
"devDependencies": { | ||
"markmap-view": "^0.2.2" | ||
"markmap-view": "^0.2.3" | ||
}, | ||
@@ -48,3 +49,3 @@ "dependencies": { | ||
"katex": "^0.12.0", | ||
"markmap-common": "^0.1.3", | ||
"markmap-common": "^0.1.4", | ||
"prismjs": "^1.21.0", | ||
@@ -54,3 +55,3 @@ "remarkable": "^2.0.0", | ||
}, | ||
"gitHead": "cb2ed0a25207e2617bb8b4d3735d61d4b5392560" | ||
"gitHead": "efdba06cf8ff88739cafc02e2b324aee91340abc" | ||
} |
export * from './types'; | ||
export * from './template'; | ||
export * from './transform'; |
@@ -0,0 +0,0 @@ import { IWrapContext, Hook } from 'markmap-common'; |
@@ -0,0 +0,0 @@ import * as katex from './katex'; |
import { IAssets, ITransformHooks } from '../types'; | ||
export declare const name = "katex"; | ||
export declare function transform(transformHooks: ITransformHooks): IAssets; |
import { IAssets, ITransformHooks } from '../types'; | ||
export declare const name = "katex"; | ||
export declare function transform(transformHooks: ITransformHooks): IAssets; |
import { IAssets, ITransformHooks } from '../types'; | ||
export declare const name = "prism"; | ||
export declare function transform(transformHooks: ITransformHooks): IAssets; |
import { IAssets, ITransformHooks } from '../types'; | ||
export declare const name = "prism"; | ||
export declare function transform(transformHooks: ITransformHooks): IAssets; |
@@ -1,3 +0,6 @@ | ||
import { INode } from 'markmap-common'; | ||
import { JSItem, INode } from 'markmap-common'; | ||
import { IAssets } from './types'; | ||
export declare function fillTemplate(data: INode | undefined, assets: IAssets, getOptions?: () => any): string; | ||
export declare function fillTemplate(data: INode | undefined, assets: IAssets, extra?: { | ||
baseJs?: JSItem[]; | ||
getOptions?: () => any; | ||
} | (() => any)): string; |
@@ -0,0 +0,0 @@ import { Remarkable } from 'remarkable'; |
@@ -0,0 +0,0 @@ import { CSSItem, JSItem, INode } from 'markmap-common'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
309766
8753
Updatedmarkmap-common@^0.1.4