summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2015-10-22 16:19:07 +0100
committerJohn McLear <john@mclear.co.uk>2015-10-22 16:19:07 +0100
commitc337a0585c7c5ec9de8813af9770f1dfd704c5f3 (patch)
tree5cfe35bcecdd97abc9a1b82d183dc345567bdd92
parent08c6e3e29f264d0900767ad27fc0d41420af4a26 (diff)
parent008d4e653c8075299444f39f1376e12571ae15fb (diff)
downloadetherpad-lite-c337a0585c7c5ec9de8813af9770f1dfd704c5f3.zip
Merge pull request #2724 from xavidotron/develop
Add a aceSelectionChanged hook to allow plugins to react when the cursor moves
-rw-r--r--doc/api/hooks_client-side.md11
-rw-r--r--src/static/js/ace2_inner.js5
2 files changed, 16 insertions, 0 deletions
diff --git a/doc/api/hooks_client-side.md b/doc/api/hooks_client-side.md
index fccdaf46..367e0688 100644
--- a/doc/api/hooks_client-side.md
+++ b/doc/api/hooks_client-side.md
@@ -339,3 +339,14 @@ Things in context:
This hook is provided to allow author highlight style to be modified.
Registered hooks should return 1 if the plugin handles highlighting. If no plugin returns 1, the core will use the default background-based highlighting.
+
+## aceSelectionChanged
+Called from: src/static/js/ace2_inner.js
+
+Things in context:
+
+1. rep - information about where the user's cursor is
+2. documentAttributeManager - information about attributes in the document
+
+This hook allows a plugin to react to a cursor or selection change,
+perhaps to update a UI element based on the style at the cursor location.
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index 55a1b5ac..d912dfb1 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -2901,6 +2901,11 @@ function Ace2Inner(){
rep.selFocusAtStart = newSelFocusAtStart;
currentCallStack.repChanged = true;
+ hooks.callAll('aceSelectionChanged', {
+ rep: rep,
+ documentAttributeManager: documentAttributeManager,
+ });
+
return true;
//console.log("selStart: %o, selEnd: %o, focusAtStart: %s", rep.selStart, rep.selEnd,
//String(!!rep.selFocusAtStart));