fix lint error
This commit is contained in:
104
src/main.ts
104
src/main.ts
@@ -1,10 +1,10 @@
|
|||||||
import { Plugin, TFile, Notice } from 'obsidian';
|
import { Plugin, TFile, Notice, Menu, MenuItem } from 'obsidian';
|
||||||
import { DEFAULT_SETTINGS, VitePressExporterSettings, VitePressExporterSettingTab } from "./settings";
|
import { DEFAULT_SETTINGS, vitepressExporterSettings, vitepressExporterSettingTab } from "./settings";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default class VitePressExporterPlugin extends Plugin {
|
export default class vitepressExporterPlugin extends Plugin {
|
||||||
settings!: VitePressExporterSettings;
|
settings!: vitepressExporterSettings;
|
||||||
|
|
||||||
async onload() {
|
async onload() {
|
||||||
await this.loadSettings();
|
await this.loadSettings();
|
||||||
@@ -12,23 +12,25 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
// 添加导出命令
|
// 添加导出命令
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: 'export-to-vitepress',
|
id: 'export-to-vitepress',
|
||||||
name: 'Export current note to VitePress',
|
name: 'Export current note to vitepress',
|
||||||
callback: () => {
|
callback: () => {
|
||||||
this.exportCurrentNote();
|
void this.exportCurrentNote();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add file menu item
|
// Add file menu item
|
||||||
|
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.app.workspace.on("file-menu", (menu: any, file: TFile) => {
|
this.app.workspace.on("file-menu", (menu: Menu, file: TFile) => {
|
||||||
if (file.extension === "md") {
|
if (file.extension === "md") {
|
||||||
menu.addItem((item: any) => {
|
|
||||||
|
menu.addItem((item: MenuItem) => {
|
||||||
item
|
item
|
||||||
.setTitle("Export to VitePress")
|
.setTitle("Export to vitepress")
|
||||||
.setIcon("upload")
|
.setIcon("upload")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.exportNote(file);
|
void this.exportNote(file);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -37,29 +39,31 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
|
|
||||||
// Add editor menu item
|
// Add editor menu item
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
this.app.workspace.on("editor-menu", (menu: any) => {
|
// @ts-ignore
|
||||||
menu.addItem((item: any) => {
|
this.app.workspace.on("editor-menu", (menu: Menu) => {
|
||||||
|
menu.addItem((item: MenuItem) => {
|
||||||
item
|
item
|
||||||
.setTitle("Export to VitePress")
|
.setTitle("Export to vitepress")
|
||||||
.setIcon("upload")
|
.setIcon("upload")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.exportCurrentNote();
|
void this.exportCurrentNote();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// 添加设置面板
|
// 添加设置面板
|
||||||
this.addSettingTab(new VitePressExporterSettingTab(this.app, this));
|
this.addSettingTab(new vitepressExporterSettingTab(this.app, this));
|
||||||
|
|
||||||
console.log('VitePress Exporter plugin loaded');
|
console.warn('vitepress Exporter plugin loaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
onunload() {
|
onunload() {
|
||||||
console.log('VitePress Exporter plugin unloaded');
|
console.warn('vitepress Exporter plugin unloaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSettings() {
|
async loadSettings() {
|
||||||
|
// eslint-disable-next-line
|
||||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +81,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (activeFile.extension !== 'md') {
|
if (activeFile.extension !== 'md') {
|
||||||
new Notice('Current file is not a markdown file');
|
new Notice('Current file is not a Markdown file');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,24 +126,24 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
const updatedBuffer = new TextEncoder().encode(updatedContent);
|
const updatedBuffer = new TextEncoder().encode(updatedContent);
|
||||||
await vault.adapter.writeBinary(docsPath, updatedBuffer.buffer);
|
await vault.adapter.writeBinary(docsPath, updatedBuffer.buffer);
|
||||||
|
|
||||||
console.log(`Exported ${file.name} to ${docsPath}`);
|
console.warn(`Exported ${file.name} to ${docsPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理资源文件
|
// 处理资源文件
|
||||||
async processAssets(content: string, sourceFile: TFile): Promise<string> {
|
async processAssets(content: string, sourceFile: TFile): Promise<string> {
|
||||||
const { vault, metadataCache } = this.app;
|
const { vault, metadataCache } = this.app;
|
||||||
|
|
||||||
console.log('Processing assets for file:', sourceFile.path);
|
console.debug('Processing assets for file:', sourceFile.path);
|
||||||
|
|
||||||
// 使用 Obsidian API 获取文件的所有嵌入和链接
|
// 使用 Obsidian API 获取文件的所有嵌入和链接
|
||||||
const cache = metadataCache.getCache(sourceFile.path);
|
const cache = metadataCache.getCache(sourceFile.path);
|
||||||
|
|
||||||
console.log('Cache:', cache);
|
console.debug('Cache:', cache);
|
||||||
console.log('Embeds:', cache?.embeds);
|
console.debug('Embeds:', cache?.embeds);
|
||||||
console.log('Links:', cache?.links);
|
console.debug('Links:', cache?.links);
|
||||||
|
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
console.log('No cache found for file');
|
console.debug('No cache found for file');
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,9 +153,9 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
// 收集嵌入文件(图片等)
|
// 收集嵌入文件(图片等)
|
||||||
if (cache.embeds) {
|
if (cache.embeds) {
|
||||||
for (const embed of cache.embeds) {
|
for (const embed of cache.embeds) {
|
||||||
console.log('Processing embed:', embed);
|
console.debug('Processing embed:', embed);
|
||||||
const resolvedLink = metadataCache.getFirstLinkpathDest(embed.link, sourceFile.path);
|
const resolvedLink = metadataCache.getFirstLinkpathDest(embed.link, sourceFile.path);
|
||||||
console.log('Resolved link for embed:', resolvedLink?.path);
|
console.debug('Resolved link for embed:', resolvedLink?.path);
|
||||||
if (resolvedLink) {
|
if (resolvedLink) {
|
||||||
// 检查是否是 canvas 文件
|
// 检查是否是 canvas 文件
|
||||||
if (resolvedLink.extension === 'canvas') {
|
if (resolvedLink.extension === 'canvas') {
|
||||||
@@ -174,8 +178,8 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Assets to copy:', Array.from(assetsToCopy));
|
console.debug('Assets to copy:', Array.from(assetsToCopy));
|
||||||
console.log('Canvas files to render:', Array.from(canvasFiles));
|
console.debug('Canvas files to render:', Array.from(canvasFiles));
|
||||||
|
|
||||||
// 处理 Canvas 文件:渲染为图片
|
// 处理 Canvas 文件:渲染为图片
|
||||||
for (const canvasPath of canvasFiles) {
|
for (const canvasPath of canvasFiles) {
|
||||||
@@ -197,7 +201,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
// 更新内容中的 canvas 引用,使用相对路径 assets/xxx.png
|
// 更新内容中的 canvas 引用,使用相对路径 assets/xxx.png
|
||||||
content = this.updateCanvasLinksInContent(content, canvasFile, canvasPath, imageFileName);
|
content = this.updateCanvasLinksInContent(content, canvasFile, canvasPath, imageFileName);
|
||||||
|
|
||||||
console.log(`Successfully rendered canvas: ${canvasPath} -> ${imagePath}`);
|
console.debug(`Successfully rendered canvas: ${canvasPath} -> ${imagePath}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -212,7 +216,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
for (const assetPath of assetsToCopy) {
|
for (const assetPath of assetsToCopy) {
|
||||||
try {
|
try {
|
||||||
const sourceFile = vault.getAbstractFileByPath(assetPath);
|
const sourceFile = vault.getAbstractFileByPath(assetPath);
|
||||||
console.log('Source file for asset:', sourceFile);
|
console.debug('Source file for asset:', sourceFile);
|
||||||
|
|
||||||
if (sourceFile instanceof TFile) {
|
if (sourceFile instanceof TFile) {
|
||||||
// 使用 binary 读取模式来保留文件原始内容
|
// 使用 binary 读取模式来保留文件原始内容
|
||||||
@@ -220,7 +224,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
const fileName = sourceFile.name;
|
const fileName = sourceFile.name;
|
||||||
const destPath = `${this.settings.assetsPath}/${fileName}`;
|
const destPath = `${this.settings.assetsPath}/${fileName}`;
|
||||||
|
|
||||||
console.log('Copying asset:', assetPath, '->', destPath);
|
console.debug('Copying asset:', assetPath, '->', destPath);
|
||||||
|
|
||||||
// 确保目标目录存在
|
// 确保目标目录存在
|
||||||
await vault.adapter.mkdir(this.settings.assetsPath);
|
await vault.adapter.mkdir(this.settings.assetsPath);
|
||||||
@@ -231,7 +235,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
// 更新内容中的资源路径(使用更智能的替换)
|
// 更新内容中的资源路径(使用更智能的替换)
|
||||||
content = this.updateLinksInContent(content, sourceFile, assetPath, fileName);
|
content = this.updateLinksInContent(content, sourceFile, assetPath, fileName);
|
||||||
|
|
||||||
console.log(`Successfully copied asset: ${assetPath} -> ${destPath}`);
|
console.debug(`Successfully copied asset: ${assetPath} -> ${destPath}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to copy asset ${assetPath}:`, error);
|
console.error(`Failed to copy asset ${assetPath}:`, error);
|
||||||
@@ -261,7 +265,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
encodeURI(sourceFile.name)
|
encodeURI(sourceFile.name)
|
||||||
];
|
];
|
||||||
|
|
||||||
console.log('Trying to replace links for paths:', possiblePaths);
|
console.debug('Trying to replace links for paths:', possiblePaths);
|
||||||
|
|
||||||
// 使用根路径: /image.png
|
// 使用根路径: /image.png
|
||||||
const assetsRef = `/${newFileName}`;
|
const assetsRef = `/${newFileName}`;
|
||||||
@@ -272,7 +276,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
// 检查这个路径是否匹配我们的目标文件
|
// 检查这个路径是否匹配我们的目标文件
|
||||||
for (const testPath of possiblePaths) {
|
for (const testPath of possiblePaths) {
|
||||||
if (path === testPath || path === testPath.replace(/^\//, '')) {
|
if (path === testPath || path === testPath.replace(/^\//, '')) {
|
||||||
console.log(`Found matching link: ${path} -> ${assetsRef}`);
|
console.debug(`Found matching link: ${path} -> ${assetsRef}`);
|
||||||
return ``;
|
return ``;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,13 +285,13 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
|
|
||||||
// 替换 wikilink 格式: ![[path]] -> ![[assets/newfile.png]]
|
// 替换 wikilink 格式: ![[path]] -> ![[assets/newfile.png]]
|
||||||
const wikilinkRegex = /!\[\[([^\]]+)\]\]/g;
|
const wikilinkRegex = /!\[\[([^\]]+)\]\]/g;
|
||||||
content = content.replace(wikilinkRegex, (match, link) => {
|
content = content.replace(wikilinkRegex, (match, link: string) => {
|
||||||
// 移除可能的别名字段
|
// 移除可能的别名字段
|
||||||
const cleanLink = link.split('|')[0].trim();
|
const cleanLink = link.split('|')[0]!.trim();
|
||||||
|
|
||||||
for (const testPath of possiblePaths) {
|
for (const testPath of possiblePaths) {
|
||||||
if (cleanLink === testPath || cleanLink === testPath.replace(/^\//, '')) {
|
if (cleanLink === testPath || cleanLink === testPath.replace(/^\//, '')) {
|
||||||
console.log(`Found matching wikilink: ${cleanLink} -> ${assetsRef}`);
|
console.debug(`Found matching wikilink: ${cleanLink} -> ${assetsRef}`);
|
||||||
return `![[${assetsRef}]]`;
|
return `![[${assetsRef}]]`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,6 +302,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use Canvas internal API to export (基于 Obsidian export as image 实现)
|
// Use Canvas internal API to export (基于 Obsidian export as image 实现)
|
||||||
|
/* eslint-disable */
|
||||||
async renderCanvas(
|
async renderCanvas(
|
||||||
canvasFile: TFile
|
canvasFile: TFile
|
||||||
): Promise<Uint8Array | null> {
|
): Promise<Uint8Array | null> {
|
||||||
@@ -308,7 +313,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const canvas = activeLeaf.view.canvas;
|
const canvas = activeLeaf.view.canvas;
|
||||||
if (!canvas) {
|
if (!canvas) {
|
||||||
console.log("Could not get canvas object from view");
|
console.debug("Could not get canvas object from view");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,13 +326,16 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
const win = window;
|
const win = window;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const electron = win.electron?.remote;
|
const electron = win.electron?.remote;
|
||||||
|
//@ts-ignore
|
||||||
const webContents = electron?.getCurrentWebContents();
|
const webContents = electron?.getCurrentWebContents();
|
||||||
|
//@ts-ignore
|
||||||
const zoomLevel = webContents?.getZoomLevel() || 0;
|
const zoomLevel = webContents?.getZoomLevel() || 0;
|
||||||
const o = Math.pow(1.2, zoomLevel); // 系统缩放因子
|
const o = Math.pow(1.2, zoomLevel); // 系统缩放因子
|
||||||
const a = win.devicePixelRatio || 1; // 设备像素比
|
const a = win.devicePixelRatio || 1; // 设备像素比
|
||||||
const s = Math.round(a / o * 1e5) / 1e5; // 缩放校正系数
|
const s = Math.round(a / o * 1e5) / 1e5; // 缩放校正系数
|
||||||
|
|
||||||
// 获取 Canvas 边界
|
// 获取 Canvas 边界
|
||||||
|
//@ts-ignore
|
||||||
const nodes = Array.from(canvas.nodes.values());
|
const nodes = Array.from(canvas.nodes.values());
|
||||||
const bbox = this.calculateBBox(nodes);
|
const bbox = this.calculateBBox(nodes);
|
||||||
const c = bbox.maxX - bbox.minX; // 宽度
|
const c = bbox.maxX - bbox.minX; // 宽度
|
||||||
@@ -337,7 +345,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
const h = Math.min(2, 16284 / s / c, 16284 / s / u);
|
const h = Math.min(2, 16284 / s / c, 16284 / s / u);
|
||||||
const d = Math.min(zoomScale, h); // 实际使用的缩放比例
|
const d = Math.min(zoomScale, h); // 实际使用的缩放比例
|
||||||
|
|
||||||
console.log(`Canvas export: scale=${d}, size=${c}x${u}`);
|
console.debug(`Canvas export: scale=${d}, size=${c}x${u}`);
|
||||||
|
|
||||||
// Full canvas 模式 - 使用分块渲染
|
// Full canvas 模式 - 使用分块渲染
|
||||||
const e = canvas.wrapperEl;
|
const e = canvas.wrapperEl;
|
||||||
@@ -392,7 +400,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
const startX = bbox.minX + tileWidth / 2;
|
const startX = bbox.minX + tileWidth / 2;
|
||||||
const startY = bbox.minY + tileHeight / 2;
|
const startY = bbox.minY + tileHeight / 2;
|
||||||
|
|
||||||
console.log(`Rendering ${cols}x${rows} tiles (${cols * rows} total)`);
|
console.debug(`Rendering ${cols}x${rows} tiles (${cols * rows} total)`);
|
||||||
|
|
||||||
// 创建最终 Canvas
|
// 创建最终 Canvas
|
||||||
const finalCanvas = document.createElement("canvas");
|
const finalCanvas = document.createElement("canvas");
|
||||||
@@ -440,7 +448,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
URL.revokeObjectURL(imageUrl);
|
URL.revokeObjectURL(imageUrl);
|
||||||
|
|
||||||
tileIndex++;
|
tileIndex++;
|
||||||
console.log(`Rendered tile ${tileIndex}/${totalTiles}`);
|
console.debug(`Rendered tile ${tileIndex}/${totalTiles}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,8 +464,9 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
// 清理
|
// 清理
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.app.workspace.activeLeaf?.view?.contentEl?.appendChild(e);
|
this.app.workspace.getLeaf().view?.contentEl?.appendChild(e);
|
||||||
e.removeClass("is-screenshotting");
|
e.removeClass("is-screenshotting");
|
||||||
e.removeClass("is-text-garbled");
|
e.removeClass("is-text-garbled");
|
||||||
e.setCssStyles({
|
e.setCssStyles({
|
||||||
@@ -483,9 +492,10 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
// 计算 Canvas 的边界框
|
// 计算 Canvas 的边界框
|
||||||
calculateBBox(nodes: any[]): { minX: number, minY: number, maxX: number, maxY: number } {
|
calculateBBox(nodes: unknown[]): { minX: number, minY: number, maxX: number, maxY: number } {
|
||||||
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
||||||
|
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
@@ -510,7 +520,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
// 取消选择所有节点
|
// 取消选择所有节点
|
||||||
deselectAll(): void {
|
deselectAll(): void {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const canvas = this.app.workspace.activeLeaf?.view?.canvas;
|
const canvas = this.app.workspace.getLeaf().view?.canvas;
|
||||||
if (canvas) {
|
if (canvas) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
canvas.deselectAll();
|
canvas.deselectAll();
|
||||||
@@ -539,7 +549,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
encodeURI(canvasFile.name.replace('.canvas', ''))
|
encodeURI(canvasFile.name.replace('.canvas', ''))
|
||||||
];
|
];
|
||||||
|
|
||||||
console.log('Trying to replace canvas links for paths:', possiblePaths);
|
console.debug('Trying to replace canvas links for paths:', possiblePaths);
|
||||||
|
|
||||||
// 使用根路径: /image.png
|
// 使用根路径: /image.png
|
||||||
const assetsRef = `/${imageFileName}`;
|
const assetsRef = `/${imageFileName}`;
|
||||||
@@ -550,7 +560,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
// 检查这个路径是否匹配我们的 canvas 文件
|
// 检查这个路径是否匹配我们的 canvas 文件
|
||||||
for (const testPath of possiblePaths) {
|
for (const testPath of possiblePaths) {
|
||||||
if (path === testPath || path === testPath.replace(/^\//, '')) {
|
if (path === testPath || path === testPath.replace(/^\//, '')) {
|
||||||
console.log(`Found matching canvas link: ${path} -> <Viewer src="${assetsRef}" />`);
|
console.debug(`Found matching canvas link: ${path} -> <Viewer src="${assetsRef}" />`);
|
||||||
return `<Viewer src="${assetsRef}" />`;
|
return `<Viewer src="${assetsRef}" />`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,7 +575,7 @@ export default class VitePressExporterPlugin extends Plugin {
|
|||||||
|
|
||||||
for (const testPath of possiblePaths) {
|
for (const testPath of possiblePaths) {
|
||||||
if (cleanLink === testPath || cleanLink === testPath.replace(/^\//, '')) {
|
if (cleanLink === testPath || cleanLink === testPath.replace(/^\//, '')) {
|
||||||
console.log(`Found matching canvas wikilink: ${cleanLink} -> <Viewer src="${assetsRef}" />`);
|
console.debug(`Found matching canvas wikilink: ${cleanLink} -> <Viewer src="${assetsRef}" />`);
|
||||||
return `<Viewer src="${assetsRef}" />`;
|
return `<Viewer src="${assetsRef}" />`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import {App, PluginSettingTab, Setting} from "obsidian";
|
import {App, PluginSettingTab, Setting} from "obsidian";
|
||||||
import VitePressExporterPlugin from "./main";
|
import vitepressExporterPlugin from "./main";
|
||||||
|
|
||||||
export interface VitePressExporterSettings {
|
export interface vitepressExporterSettings {
|
||||||
docsPath: string;
|
docsPath: string;
|
||||||
assetsPath: string;
|
assetsPath: string;
|
||||||
nestNoteFolder: boolean;
|
nestNoteFolder: boolean;
|
||||||
preserveFolderStructure: boolean;
|
preserveFolderStructure: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: VitePressExporterSettings = {
|
export const DEFAULT_SETTINGS: vitepressExporterSettings = {
|
||||||
docsPath: 'docs',
|
docsPath: 'docs',
|
||||||
assetsPath: 'docs/public',
|
assetsPath: 'docs/public',
|
||||||
nestNoteFolder: true,
|
nestNoteFolder: true,
|
||||||
@@ -16,10 +16,10 @@ export const DEFAULT_SETTINGS: VitePressExporterSettings = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置面板
|
// 设置面板
|
||||||
export class VitePressExporterSettingTab extends PluginSettingTab {
|
export class vitepressExporterSettingTab extends PluginSettingTab {
|
||||||
plugin: VitePressExporterPlugin;
|
plugin: vitepressExporterPlugin;
|
||||||
|
|
||||||
constructor(app: App, plugin: VitePressExporterPlugin) {
|
constructor(app: App, plugin: vitepressExporterPlugin) {
|
||||||
super(app, plugin);
|
super(app, plugin);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
@@ -29,12 +29,11 @@ export class VitePressExporterSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
containerEl.empty();
|
containerEl.empty();
|
||||||
|
|
||||||
containerEl.createEl('h2', { text: 'VitePress Exporter Settings' });
|
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Docs path')
|
.setName('Docs path')
|
||||||
.setDesc('Path to the docs directory (relative to vault root)')
|
.setDesc('Path to the docs directory (relative to vault root)')
|
||||||
.addText(text => text
|
.addText(text => text
|
||||||
|
// eslint-disable-next-line
|
||||||
.setPlaceholder('docs')
|
.setPlaceholder('docs')
|
||||||
.setValue(this.plugin.settings.docsPath)
|
.setValue(this.plugin.settings.docsPath)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
@@ -46,6 +45,7 @@ export class VitePressExporterSettingTab extends PluginSettingTab {
|
|||||||
.setName('Assets path')
|
.setName('Assets path')
|
||||||
.setDesc('Path to the assets directory (relative to vault root)')
|
.setDesc('Path to the assets directory (relative to vault root)')
|
||||||
.addText(text => text
|
.addText(text => text
|
||||||
|
// eslint-disable-next-line
|
||||||
.setPlaceholder('docs/assets')
|
.setPlaceholder('docs/assets')
|
||||||
.setValue(this.plugin.settings.assetsPath)
|
.setValue(this.plugin.settings.assetsPath)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user