allow specifying include note widget size

This commit is contained in:
zadam 2020-04-11 11:49:58 +02:00
parent 6c76d862d2
commit 242f139be4
6 changed files with 39 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -25,13 +25,15 @@ async function includeNote(notePath) {
const noteId = treeService.getNoteIdFromNotePath(notePath); const noteId = treeService.getNoteIdFromNotePath(notePath);
const note = await treeCache.getNote(noteId); const note = await treeCache.getNote(noteId);
const boxSize = $("input[name='include-note-box-size']:checked").val();
if (note.type === 'image') { if (note.type === 'image') {
// there's no benefit to use insert note functionlity for images // there's no benefit to use insert note functionlity for images
// so we'll just add an IMG tag // so we'll just add an IMG tag
textTypeWidget.addImage(noteId); textTypeWidget.addImage(noteId);
} }
else { else {
textTypeWidget.addIncludeNote(noteId); textTypeWidget.addIncludeNote(noteId, boxSize);
} }
} }

View file

@ -237,12 +237,13 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
import("../../dialogs/include_note.js").then(d => d.showDialog(this)); import("../../dialogs/include_note.js").then(d => d.showDialog(this));
} }
addIncludeNote(noteId) { addIncludeNote(noteId, boxSize) {
this.textEditor.model.change( writer => { this.textEditor.model.change( writer => {
// Insert <includeNote>*</includeNote> at the current selection position // Insert <includeNote>*</includeNote> at the current selection position
// in a way that will result in creating a valid model structure // in a way that will result in creating a valid model structure
this.textEditor.model.insertContent(writer.createElement('includeNote', { this.textEditor.model.insertContent(writer.createElement('includeNote', {
noteId: noteId noteId: noteId,
boxSize: boxSize
})); }));
} ); } );
} }

View file

@ -864,3 +864,13 @@ body {
.hidden-int, .hidden-ext { .hidden-int, .hidden-ext {
display: none !important; display: none !important;
} }
.include-note.box-size-small {
max-height: 12em;
overflow: auto;
}
.include-note.box-size-medium {
max-height: 25em;
overflow: auto;
}

View file

@ -15,6 +15,27 @@
<input id="include-note-autocomplete" class="form-control" placeholder="search for note by its name"> <input id="include-note-autocomplete" class="form-control" placeholder="search for note by its name">
</div> </div>
</div> </div>
Box size of the included note:
<div class="form-check">
<input class="form-check-input" type="radio" name="include-note-box-size" value="small" id="include-note-box-size-small">
<label class="form-check-label" for="include-note-box-size-small">
small (~ 10 lines)
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="include-note-box-size" value="medium" id="include-note-box-size-medium" checked>
<label class="form-check-label" for="include-note-box-size-medium">
medium (~ 30 lines)
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="include-note-box-size" value="full" id="include-note-box-size-full">
<label class="form-check-label" for="include-note-box-size-full">
full (box shows complete text)
</label>
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary">Include note <kbd>enter</kbd></button> <button type="submit" class="btn btn-primary">Include note <kbd>enter</kbd></button>