mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
refactorings for add link and include note
This commit is contained in:
parent
7e41a2750c
commit
e06f3ef97e
@ -1,4 +1,4 @@
|
||||
FROM node:12.14.1-alpine
|
||||
FROM node:12.16.0-alpine
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PKG_DIR=dist/trilium-linux-x64-server
|
||||
NODE_VERSION=12.14.1
|
||||
NODE_VERSION=12.16.0
|
||||
|
||||
if [ "$1" != "DONTCOPY" ]
|
||||
then
|
||||
|
2
libraries/ckeditor/ckeditor.js
vendored
2
libraries/ckeditor/ckeditor.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
@ -2669,9 +2669,9 @@
|
||||
"integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA=="
|
||||
},
|
||||
"electron": {
|
||||
"version": "9.0.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-9.0.0-beta.1.tgz",
|
||||
"integrity": "sha512-OUqCC/aGYjFb2cA2ta1eBcjBW9yembcwtOQ9jKu75Lk3zTIVPavKLQxkC0LDy1FqTL9/Et8VtBI86EDvnFm3xw==",
|
||||
"version": "9.0.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-9.0.0-beta.2.tgz",
|
||||
"integrity": "sha512-WkRkUh5gE5B+b9XdTDvC67VvG118J0+wURcBpcXlBZJ9k+oqn0qcX+D3NG1WitXjcrAdV18cx5taUOat8zxAeA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@electron/get": "^1.0.1",
|
||||
|
@ -75,7 +75,7 @@
|
||||
"ws": "7.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "9.0.0-beta.1",
|
||||
"electron": "9.0.0-beta.2",
|
||||
"electron-builder": "22.3.2",
|
||||
"electron-packager": "14.2.1",
|
||||
"electron-rebuild": "1.10.0",
|
||||
|
@ -36,36 +36,10 @@ window.glob.PROFILING_LOG = false;
|
||||
window.glob.isDesktop = utils.isDesktop;
|
||||
window.glob.isMobile = utils.isMobile;
|
||||
|
||||
// required for CKEditor image upload plugin
|
||||
// FIXME
|
||||
window.glob.getActiveNode = () => appContext.getMainNoteTree().getActiveNode();
|
||||
window.glob.getComponentByEl = el => appContext.getComponentByEl(el);
|
||||
window.glob.getHeaders = server.getHeaders;
|
||||
window.glob.showAddLinkDialog = () => import('./dialogs/add_link.js').then(d => d.showDialog());
|
||||
window.glob.showIncludeNoteDialog = cb => import('./dialogs/include_note.js').then(d => d.showDialog(cb));
|
||||
window.glob.loadIncludedNote = async (noteId, el) => {
|
||||
const note = await treeCache.getNote(noteId);
|
||||
|
||||
if (note) {
|
||||
$(el).empty().append($("<h3>").append(await linkService.createNoteLink(note.noteId, {
|
||||
showTooltip: false
|
||||
})));
|
||||
|
||||
const {renderedContent} = await noteContentRenderer.getRenderedContent(note);
|
||||
|
||||
$(el).append(renderedContent);
|
||||
}
|
||||
};
|
||||
// this is required by CKEditor when uploading images
|
||||
window.glob.noteChanged = () => {
|
||||
const activeTabContext = appContext.tabManager.getActiveTabContext();
|
||||
|
||||
if (activeTabContext) {
|
||||
activeTabContext.noteChanged();
|
||||
}
|
||||
};
|
||||
window.glob.refreshTree = treeService.reload;
|
||||
|
||||
// required for ESLint plugin
|
||||
// required for ESLint plugin and CKEditor
|
||||
window.glob.getActiveTabNote = () => appContext.tabManager.getActiveTabNote();
|
||||
window.glob.requireLibrary = libraryLoader.requireLibrary;
|
||||
window.glob.ESLINT = libraryLoader.ESLINT;
|
||||
|
@ -5,10 +5,12 @@ import utils from "../services/utils.js";
|
||||
const $dialog = $("#include-note-dialog");
|
||||
const $form = $("#include-note-form");
|
||||
const $autoComplete = $("#include-note-autocomplete");
|
||||
let callback = null;
|
||||
|
||||
export async function showDialog(cb) {
|
||||
callback = cb;
|
||||
/** @var TextTypeWidget */
|
||||
let textTypeWidget;
|
||||
|
||||
export async function showDialog(widget) {
|
||||
textTypeWidget = widget;
|
||||
|
||||
$autoComplete.val('');
|
||||
|
||||
@ -24,9 +26,9 @@ $form.on('submit', () => {
|
||||
if (notePath) {
|
||||
$dialog.modal('hide');
|
||||
|
||||
if (callback) {
|
||||
callback(treeService.getNoteIdFromNotePath(notePath));
|
||||
}
|
||||
const includedNoteId = treeService.getNoteIdFromNotePath(notePath);
|
||||
|
||||
textTypeWidget.addIncludeNote(includedNoteId);
|
||||
}
|
||||
else {
|
||||
console.error("No noteId to include.");
|
||||
|
@ -16,6 +16,7 @@ class AppContext {
|
||||
this.tabManager = new TabManager(this);
|
||||
this.components = [];
|
||||
this.executors = [];
|
||||
this.idToComponent = {};
|
||||
}
|
||||
|
||||
async start() {
|
||||
@ -59,6 +60,18 @@ class AppContext {
|
||||
this.trigger('initialRenderComplete');
|
||||
}
|
||||
|
||||
registerComponent(componentId, component) {
|
||||
this.idToComponent[componentId] = component;
|
||||
}
|
||||
|
||||
findComponentById(componentId) {
|
||||
return this.idToComponent[componentId];
|
||||
}
|
||||
|
||||
getComponentByEl(el) {
|
||||
return $(el).closest(".component").prop('component');
|
||||
}
|
||||
|
||||
async trigger(name, data) {
|
||||
this.eventReceived(name, data);
|
||||
|
||||
|
@ -5,6 +5,9 @@ class BasicWidget extends Component {
|
||||
render() {
|
||||
const $widget = this.doRender();
|
||||
|
||||
$widget.addClass('component')
|
||||
.prop('component', this);
|
||||
|
||||
keyboardActionsService.updateDisplayedShortcuts($widget);
|
||||
|
||||
this.toggle(this.isEnabled());
|
||||
|
@ -5,6 +5,9 @@ import TypeWidget from "./type_widget.js";
|
||||
import utils from "../../services/utils.js";
|
||||
import appContext from "../../services/app_context.js";
|
||||
import keyboardActionService from "../../services/keyboard_actions.js";
|
||||
import treeCache from "../../services/tree_cache.js";
|
||||
import linkService from "../../services/link.js";
|
||||
import noteContentRenderer from "../../services/note_content_renderer.js";
|
||||
|
||||
const ENABLE_INSPECTOR = false;
|
||||
|
||||
@ -254,4 +257,32 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
addLinkToTextCommand() {
|
||||
import("../../dialogs/add_link.js").then(d => d.showDialog(this));
|
||||
}
|
||||
|
||||
addIncludeNoteToTextCommand() {
|
||||
import("../../dialogs/include_note.js").then(d => d.showDialog(this));
|
||||
}
|
||||
|
||||
async loadIncludedNote(noteId, el) {
|
||||
const note = await treeCache.getNote(noteId);
|
||||
|
||||
if (note) {
|
||||
$(el).empty().append($("<h3>").append(await linkService.createNoteLink(note.noteId, {
|
||||
showTooltip: false
|
||||
})));
|
||||
|
||||
const {renderedContent} = await noteContentRenderer.getRenderedContent(note);
|
||||
|
||||
$(el).append(renderedContent);
|
||||
}
|
||||
}
|
||||
|
||||
addIncludeNote(noteId) {
|
||||
this.textEditor.model.change( writer => {
|
||||
// Insert <includeNote>*</includeNote> at the current selection position
|
||||
// in a way that will result in creating a valid model structure
|
||||
this.textEditor.model.insertContent(writer.createElement('includeNote', {
|
||||
noteId: noteId
|
||||
}));
|
||||
} );
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user