1
1
Fork 0
mirror of https://github.com/zadam/trilium.git synced 2025-03-03 10:33:23 +08:00

clean up code

This commit is contained in:
Tom 2022-05-03 22:06:24 +02:00
parent a37d75a08f
commit 1a4bc0b989
5 changed files with 11 additions and 34 deletions
src
app.js
public/app/widgets/type_widgets
routes/api
share
routes.js
shaca/entities

View file

@ -30,10 +30,7 @@ app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/libraries', express.static(path.join(__dirname, '..', 'libraries')));
/**
* FIXME: is it (~~crazy~~) insecure to expose node_modules globally without auth?
* without out is required for excalidraw-view mode in shared notes
*/
// node_modules required for excalidraw-view mode in shared notes
app.use('/node_modules', express.static(path.join(__dirname, '..', 'node_modules')));
app.use('/images', express.static(path.join(__dirname, '..', 'images')));
const sessionParser = session({

View file

@ -54,15 +54,6 @@ const TPL = `
* (However, using trilium desktop instance, does not care too much about bandwidth. Size increase is probably
* acceptable, as a trade off.)
*/
/**
* FIXME: Buttons from one excalidraw get activated. Problems with instance?! (maybe it is only visually, once
* mouse is over one instance they change?)
*/
/**
* FIXME: FONTS from unpkg.com are loaded. Change font to HELVETICA?
* See: https://www.npmjs.com/package/@excalidraw/excalidraw => FONT_FAMILY
* => window.EXCALIDRAW_ASSET_PATH is set, however svg still contains wrong link (to excalidraw.com)
*/
export default class ExcalidrawTypeWidget extends TypeWidget {
constructor() {
super();
@ -418,18 +409,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
detectScroll: false,
handleKeyboardGlobally: false,
autoFocus: true,
// renderTopRightUI: () => {
// return React.createElement(
// React.Fragment,
// null,
// React.createElement(
// "div",
// {
// className: "excalidraw-top-right-ui",
// },
// synchronized?"✔️":"⏳ unsaved changes"
// ));
// },
onLinkOpen,
})
)

View file

@ -20,15 +20,14 @@ function returnImage(req, res) {
}
/**
* special "image" type. the canvas-note is actually type application/json but can be
* rendered on the fly to svg.
* special "image" type. the canvas-note is actually type application/json
* to avoid bitrot and enable usage as referenced image the svg is included.
*/
if (image.type === 'canvas-note') {
// render the svg in node.js using excalidraw and jsdom
const content = image.getContent();
try {
const data = JSON.parse(content);
const svg = data.svg || '<svg />'
res.set('Content-Type', "image/svg+xml");
res.set("Cache-Control", "no-cache, no-store, must-revalidate");

View file

@ -122,13 +122,14 @@ function register(router) {
return res.status(400).send("Requested note is not a shareable image");
} else if (image.type === "canvas-note") {
/**
* FIXME: deduplicate the code from api/image.js
* special "image" type. the canvas-note is actually type application/json
* to avoid bitrot and enable usage as referenced image the svg is included.
*/
// render the svg in node.js using excalidraw and jsdom
const content = image.getContent();
try {
const data = JSON.parse(content)
const svg = data.svg || '<svg />'
const data = JSON.parse(content);
const svg = data.svg || '<svg />';
addNoIndexHeader(image, res);
res.set('Content-Type', "image/svg+xml");
res.set("Cache-Control", "no-cache, no-store, must-revalidate");

View file

@ -38,7 +38,8 @@ class Attribute extends AbstractEntity {
/**
* FIXME: why can we have branch is undefined? issue when
* sharing and not sharing notes? canvas-note specific?
* sharing and not sharing notes? canvas-note specific?
* This error occured during development.
*/
if(branch) {
branch.isHidden = true;