diff --git a/docs/backend_api/becca_entities_note.js.html b/docs/backend_api/becca_entities_note.js.html
index ad2571123..3af1da710 100644
--- a/docs/backend_api/becca_entities_note.js.html
+++ b/docs/backend_api/becca_entities_note.js.html
@@ -266,7 +266,7 @@ class Note extends AbstractEntity {
setContent(content, ignoreMissingProtectedSession = false) {
if (content === null || content === undefined) {
- throw new Error(`Cannot set null content to note ${this.noteId}`);
+ throw new Error(`Cannot set null content to note '${this.noteId}'`);
}
if (this.isStringNote()) {
@@ -288,7 +288,7 @@ class Note extends AbstractEntity {
pojo.content = protectedSessionService.encrypt(pojo.content);
}
else if (!ignoreMissingProtectedSession) {
- throw new Error(`Cannot update content of noteId=${this.noteId} since we're out of protected session.`);
+ throw new Error(`Cannot update content of noteId '${this.noteId}' since we're out of protected session.`);
}
}
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html
index 59f3b0fff..4a1c6b2da 100644
--- a/docs/frontend_api/FrontendScriptApi.html
+++ b/docs/frontend_api/FrontendScriptApi.html
@@ -1928,7 +1928,7 @@
Source:
@@ -2479,6 +2479,223 @@
+
+
+
+
+
+
+
+
+ Get access to the widget handling note detail. Methods like `getWidgetType()` and `getTypeWidget()` to get to the
+implementation of actual widget type.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<NoteDetailWidget>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getActiveTabCodeEditor() → {Promise.<CodeMirror>}
+
+
+
+
+
+
+
+ See https://codemirror.net/doc/manual.html#api
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ instance of CodeMirror
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<CodeMirror>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
getActiveTabNote() → {NoteShort}
@@ -2633,7 +2850,7 @@
Source:
@@ -2691,7 +2908,7 @@
- getActiveTabTextEditor(callback)
+ getActiveTabTextEditor(callbackopt) → {Promise.<CKEditor>}
@@ -2723,6 +2940,8 @@
Type |
+ Attributes |
+
@@ -2743,10 +2962,20 @@
+
+
+ <optional>
+
+
+
+
+
+ |
+
- method receiving "textEditor" instance |
+ deprecated (use returned promise): callback receiving "textEditor" instance |
@@ -2787,7 +3016,7 @@
Source:
@@ -2812,6 +3041,183 @@
+Returns:
+
+
+
+ instance of CKEditor
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<CKEditor>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getComponentByEl(el) → {Component}
+
+
+
+
+
+
+
+ Returns component which owns given DOM element (the nearest parent component in DOM tree)
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ el |
+
+
+
+
+
+Element
+
+
+
+ |
+
+
+
+
+
+ DOM element |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Component
+
+
+
+
+
+
@@ -2926,7 +3332,7 @@
Source:
@@ -3081,7 +3487,7 @@
Source:
@@ -3343,7 +3749,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3806,7 +4212,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -3961,7 +4367,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4116,7 +4522,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4553,7 +4959,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4709,7 +5115,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4865,7 +5271,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5002,7 +5408,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5156,7 +5562,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6097,7 +6503,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6248,7 +6654,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6614,7 +7020,7 @@ Typical use case is when new note has been created, we should wait until it is s
Source:
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html
index 20a9ad597..724618c18 100644
--- a/docs/frontend_api/entities_note_short.js.html
+++ b/docs/frontend_api/entities_note_short.js.html
@@ -152,7 +152,7 @@ class NoteShort {
return JSON.parse(content);
}
catch (e) {
- console.log(`Cannot parse content of note ${this.noteId}: `, e.message);
+ console.log(`Cannot parse content of note '${this.noteId}': `, e.message);
return null;
}
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index 451ca46bc..0f47ab437 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -364,9 +364,27 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance.
*
* @method
- * @param callback - method receiving "textEditor" instance
+ * @param [callback] - deprecated (use returned promise): callback receiving "textEditor" instance
+ * @returns {Promise<CKEditor>} instance of CKEditor
*/
- this.getActiveTabTextEditor = callback => appContext.triggerCommand('executeInActiveEditor', {callback});
+ this.getActiveTabTextEditor = callback => new Promise(resolve => appContext.triggerCommand('executeInActiveTextEditor', {callback, resolve}));
+
+ /**
+ * See https://codemirror.net/doc/manual.html#api
+ *
+ * @method
+ * @returns {Promise<CodeMirror>} instance of CodeMirror
+ */
+ this.getActiveTabCodeEditor = () => new Promise(resolve => appContext.triggerCommand('executeInActiveCodeEditor', {callback: resolve}));
+
+ /**
+ * Get access to the widget handling note detail. Methods like `getWidgetType()` and `getTypeWidget()` to get to the
+ * implementation of actual widget type.
+ *
+ * @method
+ * @returns {Promise<NoteDetailWidget>}
+ */
+ this.getActiveNoteDetailWidget = () => new Promise(resolve => appContext.triggerCommand('executeInActiveNoteDetailWidget', {callback: resolve}));
/**
* @method
@@ -374,6 +392,15 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*/
this.getActiveTabNotePath = () => appContext.tabManager.getActiveContextNotePath();
+ /**
+ * Returns component which owns given DOM element (the nearest parent component in DOM tree)
+ *
+ * @method
+ * @param {Element} el - DOM element
+ * @returns {Component}
+ */
+ this.getComponentByEl = el => appContext.getComponentByEl(el);
+
/**
* @method
* @param {object} $el - jquery object on which to setup the tooltip
diff --git a/src/public/app/dialogs/markdown_import.js b/src/public/app/dialogs/markdown_import.js
index 6faa7737f..e83522cf7 100644
--- a/src/public/app/dialogs/markdown_import.js
+++ b/src/public/app/dialogs/markdown_import.js
@@ -16,7 +16,7 @@ async function convertMarkdownToHtml(text) {
const result = writer.render(parsed);
- appContext.triggerCommand('executeInActiveEditor', {
+ appContext.triggerCommand('executeInActiveTextEditor', {
callback: textEditor => {
const viewFragment = textEditor.data.processor.toView(result);
const modelFragment = textEditor.data.toModel(viewFragment);
diff --git a/src/public/app/services/frontend_script_api.js b/src/public/app/services/frontend_script_api.js
index bcb8b5301..2cd12f8bc 100644
--- a/src/public/app/services/frontend_script_api.js
+++ b/src/public/app/services/frontend_script_api.js
@@ -336,9 +336,27 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance.
*
* @method
- * @param callback - method receiving "textEditor" instance
+ * @param [callback] - deprecated (use returned promise): callback receiving "textEditor" instance
+ * @returns {Promise} instance of CKEditor
*/
- this.getActiveTabTextEditor = callback => appContext.triggerCommand('executeInActiveEditor', {callback});
+ this.getActiveTabTextEditor = callback => new Promise(resolve => appContext.triggerCommand('executeInActiveTextEditor', {callback, resolve}));
+
+ /**
+ * See https://codemirror.net/doc/manual.html#api
+ *
+ * @method
+ * @returns {Promise} instance of CodeMirror
+ */
+ this.getActiveTabCodeEditor = () => new Promise(resolve => appContext.triggerCommand('executeInActiveCodeEditor', {callback: resolve}));
+
+ /**
+ * Get access to the widget handling note detail. Methods like `getWidgetType()` and `getTypeWidget()` to get to the
+ * implementation of actual widget type.
+ *
+ * @method
+ * @returns {Promise}
+ */
+ this.getActiveNoteDetailWidget = () => new Promise(resolve => appContext.triggerCommand('executeInActiveNoteDetailWidget', {callback: resolve}));
/**
* @method
@@ -346,6 +364,15 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*/
this.getActiveTabNotePath = () => appContext.tabManager.getActiveContextNotePath();
+ /**
+ * Returns component which owns given DOM element (the nearest parent component in DOM tree)
+ *
+ * @method
+ * @param {Element} el - DOM element
+ * @returns {Component}
+ */
+ this.getComponentByEl = el => appContext.getComponentByEl(el);
+
/**
* @method
* @param {object} $el - jquery object on which to setup the tooltip
diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js
index a54fc4250..ef1d0fd42 100644
--- a/src/public/app/widgets/note_detail.js
+++ b/src/public/app/widgets/note_detail.js
@@ -302,6 +302,16 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
}
}
+ async executeInActiveNoteDetailWidgetEvent({callback}) {
+ if (!this.isActiveNoteContext()) {
+ return;
+ }
+
+ await this.initialized;
+
+ callback(this);
+ }
+
async cutIntoNoteCommand() {
const note = appContext.tabManager.getActiveContextNote();
diff --git a/src/public/app/widgets/type_widgets/editable_code.js b/src/public/app/widgets/type_widgets/editable_code.js
index 605d0db2b..7bbc356c3 100644
--- a/src/public/app/widgets/type_widgets/editable_code.js
+++ b/src/public/app/widgets/type_widgets/editable_code.js
@@ -170,4 +170,14 @@ export default class EditableCodeTypeWidget extends TypeWidget {
});
}
}
+
+ async executeInActiveCodeEditorEvent({callback}) {
+ if (!this.isActive()) {
+ return;
+ }
+
+ await this.initialized;
+
+ callback(this.codeEditor);
+ }
}
diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.js
index d497ecbbe..44469fdc6 100644
--- a/src/public/app/widgets/type_widgets/editable_text.js
+++ b/src/public/app/widgets/type_widgets/editable_text.js
@@ -229,14 +229,18 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
return !selection.isCollapsed;
}
- async executeInActiveEditorEvent({callback}) {
+ async executeInActiveTextEditorEvent({callback, resolve}) {
if (!this.isActive()) {
return;
}
await this.initialized;
- callback(this.textEditor);
+ if (callback) {
+ callback(this.textEditor);
+ }
+
+ resolve(this.textEditor);
}
addLinkToTextCommand() {