mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 18:49:00 +01:00
fix(export/share): missing templates after merge
This commit is contained in:
parent
ea53665e64
commit
aa102ab393
@ -1,8 +1,9 @@
|
|||||||
import type NoteMeta from "../../meta/note_meta.js";
|
import type NoteMeta from "../../meta/note_meta.js";
|
||||||
import { escapeHtml } from "../../utils";
|
import { escapeHtml, getResourceDir, isDev } from "../../utils";
|
||||||
import cssContent from "@triliumnext/ckeditor5/content.css";
|
|
||||||
import html from "html";
|
import html from "html";
|
||||||
import { ZipExportProvider } from "./abstract_provider.js";
|
import { ZipExportProvider } from "./abstract_provider.js";
|
||||||
|
import path from "path";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
export default class HtmlExportProvider extends ZipExportProvider {
|
export default class HtmlExportProvider extends ZipExportProvider {
|
||||||
|
|
||||||
@ -164,6 +165,10 @@ export default class HtmlExportProvider extends ZipExportProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cssFile = isDev
|
||||||
|
? path.join(__dirname, "../../../../../node_modules/ckeditor5/dist/ckeditor5-content.css")
|
||||||
|
: path.join(getResourceDir(), "ckeditor5-content.css");
|
||||||
|
const cssContent = fs.readFileSync(cssFile, "utf-8");
|
||||||
this.archive.append(cssContent, { name: cssMeta.dataFileName });
|
this.archive.append(cssContent, { name: cssMeta.dataFileName });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -189,15 +189,22 @@ function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render with the default view otherwise.
|
// Render with the default view otherwise.
|
||||||
const templatePath = join(getResourceDir(), "share-theme", "templates", "page.ejs");
|
const templatePath = getDefaultTemplatePath("page");
|
||||||
return ejs.render(readTemplate(templatePath), opts, {
|
return ejs.render(readTemplate(templatePath), opts, {
|
||||||
includer: (path) => {
|
includer: (path) => {
|
||||||
const templatePath = join(getResourceDir(), "share-theme", "templates", `${path}.ejs`);
|
// Path is relative to apps/server/dist/assets/views
|
||||||
return { template: readTemplate(templatePath) };
|
return { template: readTemplate(getDefaultTemplatePath(path)) };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDefaultTemplatePath(template: string) {
|
||||||
|
// Path is relative to apps/server/dist/assets/views
|
||||||
|
return process.env.NODE_ENV === "development"
|
||||||
|
? join(__dirname, `../../../../packages/share-theme/src/templates/${template}.ejs`)
|
||||||
|
: `../../share-theme/templates/${template}.ejs`;
|
||||||
|
}
|
||||||
|
|
||||||
function readTemplate(path: string) {
|
function readTemplate(path: string) {
|
||||||
const cachedTemplate = templateCache.get(path);
|
const cachedTemplate = templateCache.get(path);
|
||||||
if (cachedTemplate) {
|
if (cachedTemplate) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user