mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-27 19:06:15 -04:00
extending get attribute on selection
This commit is contained in:
parent
47f43e7094
commit
62be430203
2 changed files with 24 additions and 4 deletions
|
@ -37,10 +37,16 @@ Returns the `rep` object.
|
|||
## editorInfo.ace_isCaret(?)
|
||||
## editorInfo.ace_getLineAndCharForPoint(?)
|
||||
## editorInfo.ace_performDocumentApplyAttributesToCharRange(?)
|
||||
## editorInfo.ace_setAttributeOnSelection(?)
|
||||
## editorInfo.ace_setAttributeOnSelection(attribute, enabled)
|
||||
Sets an attribute on current range.
|
||||
Example: `call.editorInfo.ace_setAttributeOnSelection("turkey::balls", true); // turkey is the attribute here, balls is the value
|
||||
Notes: to remove the attribute pass enabled as false
|
||||
|
||||
## editorInfo.ace_toggleAttributeOnSelection(?)
|
||||
## editorInfo.ace_getAttributeOnSelection(attribute)
|
||||
## editorInfo.ace_getAttributeOnSelection(attribute, prevChar)
|
||||
Returns a boolean if an attribute exists on a selected range.
|
||||
prevChar value should be true if you want to get the previous Character attribute instead of the current selection for example
|
||||
if the caret is at position 0,1 (after first character) it's probable you want the attributes on the character at 0,0
|
||||
The attribute should be the string name of the attribute applied to the selection IE subscript
|
||||
Example usage: Apply the activeButton Class to a button if an attribute is on a highlighted/selected caret position or range.
|
||||
Example: `call.editorInfo.ace_getAttributeOnSelection("subscript");` // call here is the callstack from aceEditEvent.
|
||||
|
|
|
@ -449,6 +449,8 @@ function Ace2Inner(){
|
|||
return oldEvent;
|
||||
}
|
||||
|
||||
if(!evt) var evt = null;
|
||||
|
||||
currentCallStack = {
|
||||
type: type,
|
||||
docTextChanged: false,
|
||||
|
@ -2337,10 +2339,22 @@ function Ace2Inner(){
|
|||
}
|
||||
editorInfo.ace_setAttributeOnSelection = setAttributeOnSelection;
|
||||
|
||||
|
||||
function getAttributeOnSelection(attributeName){
|
||||
// Get the the attribute on selection
|
||||
// prevChar tells the function if it needs to look at the previous character
|
||||
function getAttributeOnSelection(attributeName, prevChar){
|
||||
if (!(rep.selStart && rep.selEnd)) return
|
||||
|
||||
// If we're looking for the caret attribute not the selection
|
||||
if(prevChar){
|
||||
// If it's not the start of the line
|
||||
if(rep.selStart[1] !== 0){
|
||||
rep.selStart[1]--;
|
||||
}else{
|
||||
// It's the start of the line so look at the first character
|
||||
rep.selEnd[1]++;
|
||||
}
|
||||
}
|
||||
|
||||
var withIt = Changeset.makeAttribsString('+', [
|
||||
[attributeName, 'true']
|
||||
], rep.apool);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue