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 ApiToken = require('../entities/api_token');
const Option = require('../entities/option'); const Option = require('../entities/option');
const repository = require('../services/repository'); const repository = require('../services/repository');
const cls = require('./cls'); const cls = require('../services/cls');
const ENTITY_NAME_TO_ENTITY = { const ENTITY_NAME_TO_ENTITY = {
"attributes": Attribute, "attributes": Attribute,

View File

@ -18,7 +18,7 @@ import appContext from "../services/app_context.js";
import keyboardActionsService from "../services/keyboard_actions.js"; import keyboardActionsService from "../services/keyboard_actions.js";
import noteCreateService from "../services/note_create.js"; import noteCreateService from "../services/note_create.js";
import DeletedTypeWidget from "./type_widgets/deleted.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 = ` const TPL = `
<div class="note-detail"> <div class="note-detail">
@ -37,7 +37,7 @@ const typeWidgetClasses = {
'empty': EmptyTypeWidget, 'empty': EmptyTypeWidget,
'deleted': DeletedTypeWidget, 'deleted': DeletedTypeWidget,
'text': TextTypeWidget, 'text': TextTypeWidget,
'text-preview': TextPreviewTypeWidget, 'read-only-text': ReadOnlyTextTypeWidget,
'code': CodeTypeWidget, 'code': CodeTypeWidget,
'file': FileTypeWidget, 'file': FileTypeWidget,
'image': ImageTypeWidget, 'image': ImageTypeWidget,
@ -181,8 +181,9 @@ export default class NoteDetailWidget extends TabAwareWidget {
if (type === 'text' && !this.tabContext.textPreviewDisabled) { if (type === 'text' && !this.tabContext.textPreviewDisabled) {
const noteComplement = await this.tabContext.getNoteComplement(); const noteComplement = await this.tabContext.getNoteComplement();
if (noteComplement.content && noteComplement.content.length > 10000) { if (note.hasLabel('readOnly') ||
type = 'text-preview'; (noteComplement.content && noteComplement.content.length > 10000)) {
type = 'read-only-text';
} }
} }

View File

@ -24,16 +24,16 @@ const TPL = `
} }
</style> </style>
<div class="alert alert-warning" title="This note is long so for performance reasons only text preview is shown by default."> <div class="alert alert-warning">
Text preview is shown. <a href="#" class="edit-note">Click here</a> to edit the note. Read only text view is shown. <a href="#" class="edit-note">Click here</a> to edit the note.
</div> </div>
<div class="note-detail-text-preview-content"></div> <div class="note-detail-text-preview-content"></div>
</div> </div>
`; `;
export default class TextPreviewTypeWidget extends TypeWidget { export default class ReadOnlyTextTypeWidget extends TypeWidget {
static getType() { return "text-preview"; } static getType() { return "read-only-text"; }
doRender() { doRender() {
this.$widget = $(TPL); this.$widget = $(TPL);

View File

@ -141,8 +141,6 @@ export default class TextTypeWidget extends TypeWidget {
} }
async doRefresh(note) { async doRefresh(note) {
this.textEditor.isReadOnly = note.hasLabel('readOnly');
const noteComplement = await treeCache.getNoteComplement(note.noteId); const noteComplement = await treeCache.getNoteComplement(note.noteId);
await this.spacedUpdate.allowUpdateWithoutChange(() => { await this.spacedUpdate.allowUpdateWithoutChange(() => {