Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
renamed text preview to read only text
zadam2d1f3b76339f
diff --git a/src/entities/entity_constructor.js b/src/entities/entity_constructor.jsindex e2162b4ae7..180ee971f0 100644--- a/src/entities/entity_constructor.js+++ b/src/entities/entity_constructor.js@@ -6,7 +6,7 @@ const RecentNote = require('../entities/recent_note');const ApiToken = require('../entities/api_token');const Option = require('../entities/option');const repository = require('../services/repository');-const cls = require('./cls');+const cls = require('../services/cls');const ENTITY_NAME_TO_ENTITY = {"attributes": Attribute,diff --git a/src/public/javascripts/widgets/note_detail.js b/src/public/javascripts/widgets/note_detail.jsindex c135ae43b5..c72d7f0e20 100644--- a/src/public/javascripts/widgets/note_detail.js+++ b/src/public/javascripts/widgets/note_detail.js@@ -18,7 +18,7 @@ import appContext from "../services/app_context.js";import keyboardActionsService from "../services/keyboard_actions.js";import noteCreateService from "../services/note_create.js";import DeletedTypeWidget from "./type_widgets/deleted.js";-import TextPreviewTypeWidget from "./type_widgets/text_preview.js";+import ReadOnlyTextTypeWidget from "./type_widgets/read_only_text.js";const TPL = `<div class="note-detail">@@ -37,7 +37,7 @@ const typeWidgetClasses = {'empty': EmptyTypeWidget,'deleted': DeletedTypeWidget,'text': TextTypeWidget,- 'text-preview': TextPreviewTypeWidget,+ 'read-only-text': ReadOnlyTextTypeWidget,'code': CodeTypeWidget,'file': FileTypeWidget,'image': ImageTypeWidget,@@ -181,8 +181,9 @@ export default class NoteDetailWidget extends TabAwareWidget {if (type === 'text' && !this.tabContext.textPreviewDisabled) {const noteComplement = await this.tabContext.getNoteComplement();- if (noteComplement.content && noteComplement.content.length > 10000) {- type = 'text-preview';+ if (note.hasLabel('readOnly') ||+ (noteComplement.content && noteComplement.content.length > 10000)) {+ type = 'read-only-text';}}diff --git a/src/public/javascripts/widgets/type_widgets/text_preview.js b/src/public/javascripts/widgets/type_widgets/read_only_text.jssimilarity index 85%rename from src/public/javascripts/widgets/type_widgets/text_preview.jsrename to src/public/javascripts/widgets/type_widgets/read_only_text.jsindex 8872d5848a..28dce7051c 100644--- a/src/public/javascripts/widgets/type_widgets/text_preview.js+++ b/src/public/javascripts/widgets/type_widgets/read_only_text.js@@ -24,16 +24,16 @@ const TPL = `}</style>- <div class="alert alert-warning" title="This note is long so for performance reasons only text preview is shown by default.">- Text preview is shown. <a href="#" class="edit-note">Click here</a> to edit the note.+ <div class="alert alert-warning">+ Read only text view is shown. <a href="#" class="edit-note">Click here</a> to edit the note.</div><div class="note-detail-text-preview-content"></div></div>`;-export default class TextPreviewTypeWidget extends TypeWidget {- static getType() { return "text-preview"; }+export default class ReadOnlyTextTypeWidget extends TypeWidget {+ static getType() { return "read-only-text"; }doRender() {this.$widget = $(TPL);diff --git a/src/public/javascripts/widgets/type_widgets/text.js b/src/public/javascripts/widgets/type_widgets/text.jsindex 5fc8e488dc..cd5d12111c 100644--- a/src/public/javascripts/widgets/type_widgets/text.js+++ b/src/public/javascripts/widgets/type_widgets/text.js@@ -141,8 +141,6 @@ export default class TextTypeWidget extends TypeWidget {}async doRefresh(note) {- this.textEditor.isReadOnly = note.hasLabel('readOnly');-const noteComplement = await treeCache.getNoteComplement(note.noteId);await this.spacedUpdate.allowUpdateWithoutChange(() => {