mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 23:13:43 +08:00
make note revisions work
This commit is contained in:
parent
15a3b42124
commit
025032de42
4 changed files with 104 additions and 1 deletions
2
libraries/excalidraw/utils/excalidraw-utils.min.js
vendored
Normal file
2
libraries/excalidraw/utils/excalidraw-utils.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
object-assign
|
||||
(c) Sindre Sorhus
|
||||
@license MIT
|
||||
*/
|
||||
|
||||
/*
|
||||
object-assign
|
||||
(c) Sindre Sorhus
|
||||
@license MIT
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
||||
pica
|
||||
https://github.com/nodeca/pica
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Lodash <https://lodash.com/>
|
||||
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||
* Released under MIT license <https://lodash.com/license>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
*/
|
||||
|
||||
/** @license React v0.20.2
|
||||
* scheduler.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v17.0.2
|
||||
* react-dom.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v17.0.2
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/** @license React v17.0.2
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0.
|
|
@ -171,6 +171,35 @@ async function setContentPane() {
|
|||
|
||||
$content.html($table);
|
||||
}
|
||||
else if (revisionItem.type === 'canvas-note') {
|
||||
/**
|
||||
* can the revisions called without being on the note type before?
|
||||
* if so: load excalidraw
|
||||
*/
|
||||
await libraryLoader.requireLibrary(libraryLoader.EXCALIDRAW_UTILS);
|
||||
const {exportToSvg} = window.ExcalidrawUtils
|
||||
|
||||
const content = fullNoteRevision.content;
|
||||
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
const excData = {
|
||||
type: "excalidraw",
|
||||
version: 2,
|
||||
source: "trilium",
|
||||
elements: data.elements,
|
||||
appState: data.appState,
|
||||
files: data.files,
|
||||
}
|
||||
const svg = await exportToSvg(excData);
|
||||
console.log("canvas-note", data, svg);
|
||||
$content.html($("<div>").html(svg));
|
||||
} catch(err) {
|
||||
console.error("error parsing fullNoteRevision.content as JSON", fullNoteRevision.content, err);
|
||||
$content.html($("<div>").text("error parsing content"));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$content.text("Preview isn't available for this note type.");
|
||||
}
|
||||
|
|
|
@ -67,6 +67,12 @@ const EXCALIDRAW = {
|
|||
// ]
|
||||
};
|
||||
|
||||
const EXCALIDRAW_UTILS = {
|
||||
js: [
|
||||
"libraries/excalidraw/utils/excalidraw-utils.min.js", //v0.1.2
|
||||
]
|
||||
};
|
||||
|
||||
async function requireLibrary(library) {
|
||||
if (library.css) {
|
||||
library.css.map(cssUrl => requireCss(cssUrl));
|
||||
|
@ -118,5 +124,6 @@ export default {
|
|||
WHEEL_ZOOM,
|
||||
FORCE_GRAPH,
|
||||
MERMAID,
|
||||
EXCALIDRAW
|
||||
EXCALIDRAW,
|
||||
EXCALIDRAW_UTILS
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue