mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
removed note detail service
This commit is contained in:
@@ -4,7 +4,6 @@ import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||
import SpacedUpdate from "../services/spaced_update.js";
|
||||
import server from "../services/server.js";
|
||||
import libraryLoader from "../services/library_loader.js";
|
||||
import noteDetailService from "../services/note_detail.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="note-detail">
|
||||
@@ -221,4 +220,8 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
||||
this.refreshWithNote(this.note, this.notePath);
|
||||
}
|
||||
}
|
||||
|
||||
beforeUnloadListener() {
|
||||
this.spacedUpdate.updateNowIfNecessary();
|
||||
}
|
||||
}
|
||||
@@ -102,4 +102,8 @@ export default class NoteTitleWidget extends TabAwareWidget {
|
||||
.trigger('select');
|
||||
}
|
||||
}
|
||||
|
||||
beforeUnloadListener() {
|
||||
this.spacedUpdate.updateNowIfNecessary();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import treeService from '../services/tree.js';
|
||||
import noteDetailService from '../services/note_detail.js';
|
||||
import server from '../services/server.js';
|
||||
import mimeTypesService from '../services/mime_types.js';
|
||||
import TabAwareWidget from "./tab_aware_widget.js";
|
||||
@@ -128,8 +126,6 @@ export default class NoteTypeWidget extends TabAwareWidget {
|
||||
+ '/type/' + encodeURIComponent(type)
|
||||
+ '/mime/' + encodeURIComponent(mime));
|
||||
|
||||
await noteDetailService.reload();
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import libraryLoader from "../../services/library_loader.js";
|
||||
import bundleService from "../../services/bundle.js";
|
||||
import toastService from "../../services/toast.js";
|
||||
import server from "../../services/server.js";
|
||||
import noteDetailService from "../../services/note_detail.js";
|
||||
import keyboardActionService from "../../services/keyboard_actions.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import utils from "../../services/utils.js";
|
||||
import server from "../../services/server.js";
|
||||
import toastService from "../../services/toast.js";
|
||||
import noteDetailService from "../../services/note_detail.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
|
||||
const TPL = `
|
||||
@@ -107,7 +106,7 @@ export default class FileTypeWidget extends TypeWidget {
|
||||
if (result.uploaded) {
|
||||
toastService.showMessage("New file revision has been uploaded.");
|
||||
|
||||
await noteDetailService.reload();
|
||||
// FIXME reload
|
||||
}
|
||||
else {
|
||||
toastService.showError("Upload of a new file revision failed.");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import utils from "../../services/utils.js";
|
||||
import toastService from "../../services/toast.js";
|
||||
import server from "../../services/server.js";
|
||||
import noteDetailService from "../../services/note_detail.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
|
||||
const TPL = `
|
||||
@@ -48,7 +47,7 @@ const TPL = `
|
||||
<input type="file" class="image-upload-new-revision-input" style="display: none">
|
||||
</div>`;
|
||||
|
||||
class NoteDetailImage extends TypeWidget {
|
||||
class ImageTypeWidget extends TypeWidget {
|
||||
static getType() { return "image"; }
|
||||
|
||||
doRender() {
|
||||
@@ -112,6 +111,7 @@ class NoteDetailImage extends TypeWidget {
|
||||
|
||||
await utils.clearBrowserCache();
|
||||
|
||||
// FIXME
|
||||
await noteDetailService.reload();
|
||||
}
|
||||
else {
|
||||
@@ -160,4 +160,4 @@ class NoteDetailImage extends TypeWidget {
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteDetailImage
|
||||
export default ImageTypeWidget
|
||||
@@ -1,4 +1,3 @@
|
||||
import noteDetailService from "../../services/note_detail.js";
|
||||
import searchNotesService from "../../services/search_notes.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
|
||||
|
||||
@@ -185,6 +185,10 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
}
|
||||
|
||||
insertDateTimeToTextListener() {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const date = new Date();
|
||||
const dateString = utils.formatDateTime(date);
|
||||
|
||||
@@ -208,4 +212,47 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
writer.insertText(text, insertPosition);
|
||||
});
|
||||
}
|
||||
|
||||
addTextToActiveEditorListener(text) {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.addTextToEditor(text);
|
||||
}
|
||||
|
||||
async addLinkToActiveEditorListener({linkTitle, linkHref}) {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.initialized;
|
||||
|
||||
if (this.hasSelection()) {
|
||||
this.textEditor.execute('link', linkHref);
|
||||
}
|
||||
else {
|
||||
await this.addLinkToEditor(linkTitle, linkHref);
|
||||
}
|
||||
|
||||
this.textEditor.editing.view.focus();
|
||||
}
|
||||
|
||||
// returns true if user selected some text, false if there's no selection
|
||||
hasSelection() {
|
||||
const model = this.textEditor.model;
|
||||
const selection = model.document.selection;
|
||||
|
||||
return !selection.isCollapsed;
|
||||
}
|
||||
|
||||
async executeInActiveEditorListener({callback}) {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.initialized;
|
||||
|
||||
callback(this.textEditor);
|
||||
}
|
||||
}
|
||||
@@ -24,4 +24,8 @@ export default class TypeWidget extends TabAwareWidget {
|
||||
|
||||
this.doRefresh(note);
|
||||
}
|
||||
|
||||
isActive() {
|
||||
return this.$widget.is(":visible");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user