fixed switch between autobook and text

This commit is contained in:
zadam
2020-02-02 11:44:08 +01:00
parent 34150e7177
commit 27ab55d26a
22 changed files with 3311 additions and 805 deletions

View File

@@ -1,16 +0,0 @@
import appContext from "./app_context.js";
function getActiveEditor() {
const activeTabContext = appContext.getActiveTabContext();
if (activeTabContext && activeTabContext.note && activeTabContext.note.type === 'text') {
return activeTabContext.getComponent().getEditor();
}
else {
return null;
}
}
export default {
getActiveEditor
};

View File

@@ -47,6 +47,8 @@ class TabContext extends Component {
this.notePath = notePath;
this.noteId = treeService.getNoteIdFromNotePath(notePath);
this.autoBookDisabled = false;
//this.cleanup(); // esp. on windows autocomplete is not getting closed automatically
setTimeout(async () => {

View File

@@ -19,10 +19,18 @@ export default class Component {
let propagateToChildren = true;
const start = Date.now();
if (typeof fun === 'function') {
propagateToChildren = await fun.call(this, data) !== false;
}
const end = Date.now();
if (end - start > 10) {
console.log(`Event ${name} in component ${this.componentId} took ${end-start}ms`);
}
if (propagateToChildren) {
const promise = this.triggerChildren(name, data, sync);

View File

@@ -143,7 +143,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
typeWidget.eventReceived('setTabContext', {tabContext: this.tabContext});
}
async getWidgetType(disableAutoBook) {
async getWidgetType() {
const note = this.tabContext.note;
if (!note) {
@@ -152,7 +152,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
let type = note.type;
if (type === 'text' && !disableAutoBook
if (type === 'text' && !this.tabContext.autoBookDisabled
&& note.hasChildren()
&& utils.isDesktop()) {
@@ -224,4 +224,8 @@ export default class NoteDetailWidget extends TabAwareWidget {
beforeUnloadListener() {
this.spacedUpdate.updateNowIfNecessary();
}
autoBookDisabledListener() {
this.refresh();
}
}

View File

@@ -200,7 +200,9 @@ export default class BookTypeWidget extends TypeWidget {
if (this.isAutoBook()) {
const $addTextLink = $('<a href="javascript:">here</a>').on('click', () => {
// FIXME
this.tabContext.autoBookDisabled = true;
this.trigger('autoBookDisabled');
});
this.$content.append($('<div class="note-book-auto-message"></div>')