From 67bdffb27b8a6b60015d7feab7d506c09c44b9dd Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 10 Jan 2020 20:10:17 +0100 Subject: [PATCH] expose text editor instance and method to add text to editor, closes #819 --- docs/frontend_api/FrontendScriptApi.html | 276 +++++++++++++++++- .../services_frontend_script_api.js.html | 16 + .../services/frontend_script_api.js | 16 + 3 files changed, 295 insertions(+), 13 deletions(-) diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html index 4197e7611..f556d7d72 100644 --- a/docs/frontend_api/FrontendScriptApi.html +++ b/docs/frontend_api/FrontendScriptApi.html @@ -1240,6 +1240,143 @@ + + + + + + +

addTextToActiveTabEditor(text)

+ + + + + + +
+ Adds given text to the editor cursor +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
text + + +string + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -1366,7 +1503,7 @@
Source:
@@ -1785,7 +1922,7 @@
Source:
@@ -1891,7 +2028,7 @@
Source:
@@ -1949,6 +2086,119 @@ +

getActiveTabTextEditor() → {Editor|null}

+ + + + + + +
+ See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ CKEditor instance or null (e.g. if active note is not a text note) +
+ + + +
+
+ Type +
+
+ +Editor +| + +null + + +
+
+ + + + + + + + + + + + +

getDateNote(date) → {Promise.<NoteShort>}

@@ -2050,7 +2300,7 @@
Source:
@@ -2312,7 +2562,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2775,7 +3025,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2930,7 +3180,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -3039,7 +3289,7 @@ note.
Source:
@@ -3194,7 +3444,7 @@ note.
Source:
@@ -3433,7 +3683,7 @@ note.
Source:
@@ -4606,7 +4856,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4757,7 +5007,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -5123,7 +5373,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/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index 460941ea9..3b73eabad 100644 --- a/docs/frontend_api/services_frontend_script_api.js.html +++ b/docs/frontend_api/services_frontend_script_api.js.html @@ -324,12 +324,28 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte */ this.createNoteLink = linkService.createNoteLink; + /** + * Adds given text to the editor cursor + * + * @param {string} text + * @method + */ + this.addTextToActiveTabEditor = linkService.addTextToEditor; + /** * @method * @returns {NoteFull} active note (loaded into right pane) */ this.getActiveTabNote = noteDetailService.getActiveTabNote; + /** + * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance. + * + * @method + * @returns {Editor|null} CKEditor instance or null (e.g. if active note is not a text note) + */ + this.getActiveTabTextEditor = noteDetailService.getActiveEditor; + /** * @method * @returns {Promise<string|null>} returns note path of active note or null if there isn't active note diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js index a141c8f19..1760e21c0 100644 --- a/src/public/javascripts/services/frontend_script_api.js +++ b/src/public/javascripts/services/frontend_script_api.js @@ -296,12 +296,28 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte */ this.createNoteLink = linkService.createNoteLink; + /** + * Adds given text to the editor cursor + * + * @param {string} text - this must be clear text, HTML is not supported. + * @method + */ + this.addTextToActiveTabEditor = linkService.addTextToEditor; + /** * @method * @returns {NoteFull} active note (loaded into right pane) */ this.getActiveTabNote = noteDetailService.getActiveTabNote; + /** + * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance. + * + * @method + * @returns {Editor|null} CKEditor instance or null (e.g. if active note is not a text note) + */ + this.getActiveTabTextEditor = noteDetailService.getActiveEditor; + /** * @method * @returns {Promise} returns note path of active note or null if there isn't active note