renamed text preview to read only text

This commit is contained in:
zadam 2020-04-06 22:21:09 +02:00
parent 3772d97dfa
commit 2d1f3b7633
4 changed files with 10 additions and 11 deletions

View File

@ -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,

View File

@ -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';
}
}

View File

@ -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);

View File

@ -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(() => {