|
@@ -1,4 +1,4 @@
|
|
|
-import {exportMarkdown} from "../export/markdown";
|
|
|
|
|
|
|
+import {exportMarkdown, exportPDF} from "../export";
|
|
|
import {getEventName} from "../util/compatibility";
|
|
import {getEventName} from "../util/compatibility";
|
|
|
import {getMarkdown} from "../util/getMarkdown";
|
|
import {getMarkdown} from "../util/getMarkdown";
|
|
|
import {MenuItem} from "./MenuItem";
|
|
import {MenuItem} from "./MenuItem";
|
|
@@ -9,18 +9,20 @@ export class Export extends MenuItem {
|
|
|
|
|
|
|
|
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
constructor(vditor: IVditor, menuItem: IMenuItem) {
|
|
|
super(vditor, menuItem);
|
|
super(vditor, menuItem);
|
|
|
-
|
|
|
|
|
const actionBtn = this.element.children[0] as HTMLElement;
|
|
const actionBtn = this.element.children[0] as HTMLElement;
|
|
|
-
|
|
|
|
|
const panelElement = document.createElement("div");
|
|
const panelElement = document.createElement("div");
|
|
|
panelElement.className = `vditor-hint${menuItem.level === 2 ? "" : " vditor-panel--arrow"}`;
|
|
panelElement.className = `vditor-hint${menuItem.level === 2 ? "" : " vditor-panel--arrow"}`;
|
|
|
- panelElement.innerHTML = `<button data-type="markdown">Markdown</button>`;
|
|
|
|
|
|
|
+ panelElement.innerHTML = `<button data-type="markdown">Markdown</button>
|
|
|
|
|
+<button data-type="pdf">PDF</button>`;
|
|
|
panelElement.addEventListener(getEventName(), (event: MouseEvent & { target: HTMLElement }) => {
|
|
panelElement.addEventListener(getEventName(), (event: MouseEvent & { target: HTMLElement }) => {
|
|
|
const btnElement = event.target;
|
|
const btnElement = event.target;
|
|
|
if (btnElement.tagName === "BUTTON") {
|
|
if (btnElement.tagName === "BUTTON") {
|
|
|
switch (btnElement.getAttribute("data-type")) {
|
|
switch (btnElement.getAttribute("data-type")) {
|
|
|
case "markdown":
|
|
case "markdown":
|
|
|
- exportMarkdown(getMarkdown(vditor));
|
|
|
|
|
|
|
+ exportMarkdown(vditor, getMarkdown(vditor));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "pdf":
|
|
|
|
|
+ exportPDF(vditor, getMarkdown(vditor));
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|