Skip to content

Commit 37ea034

Browse files
committed
fix: attach processors to Markmap
1 parent 3b6c52d commit 37ea034

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/template.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export function fillTemplate(data: any, opts?: any): string {
2727
type: 'iife',
2828
data: {
2929
fn: (data, ...processors) => {
30-
const { markmap } = (window as any).markmap;
31-
markmap.processors = processors;
32-
markmap('svg#mindmap', data);
30+
const { Markmap } = (window as any).markmap;
31+
Markmap.processors = processors;
32+
Markmap.create('svg#mindmap', null, data);
3333
},
3434
getParams: ({ data, processors }) => [
3535
data,

src/view.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,19 @@ ${this.getStyleContent()}
369369
.scale(scale);
370370
this.transition(this.svg).call(this.zoom.transform, newTransform);
371371
}
372+
373+
static create(svg: string | SVGElement | ID3SVGElement, opts?: IMarkmapOptions, data?: INode): Markmap {
374+
const mm = new Markmap(svg, opts);
375+
if (data) {
376+
mm.setData(data);
377+
mm.fit(); // always fit for the first render
378+
}
379+
return mm;
380+
}
372381
}
373382

374383
export function markmap(svg: string | SVGElement | ID3SVGElement, data?: INode, opts?: IMarkmapOptions): Markmap {
375-
const mm = new Markmap(svg, opts);
376-
if (data) {
377-
mm.setData(data);
378-
mm.fit(); // always fit for the first render
379-
}
380-
return mm;
384+
return Markmap.create(svg, opts, data);
381385
}
382386

383387
export async function loadPlugins(items: any[], options: any): Promise<void> {

0 commit comments

Comments
 (0)