mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-08 03:02:03 +01:00
renamed performDocumentApplyAttributesToRange to setAttributesOnRange and moved it to AttributeManager
This commit is contained in:
parent
093b7ab4bf
commit
5833cb1037
2 changed files with 19 additions and 17 deletions
|
@ -43,6 +43,20 @@ AttributeManager.prototype = _(AttributeManager.prototype).extend({
|
||||||
return changeset;
|
return changeset;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sets attributes on a range
|
||||||
|
@param start [row, col] tuple pointing to the start of the range
|
||||||
|
@param end [row, col] tuple pointing to the end of the range
|
||||||
|
@param attribute: an array of attributes
|
||||||
|
*/
|
||||||
|
setAttributesOnRange: function(start, end, attribs)
|
||||||
|
{
|
||||||
|
var builder = Changeset.builder(rep.lines.totalWidth());
|
||||||
|
ChangesetUtils.buildKeepToStartOfRange(rep, builder, start);
|
||||||
|
ChangesetUtils.buildKeepRange(this.rep, builder, start, end, attribs, this.rep.apool);
|
||||||
|
return this.applyChangeset(builder);
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns if the line already has a line marker
|
Returns if the line already has a line marker
|
||||||
@param lineNum: the number of the line
|
@param lineNum: the number of the line
|
||||||
|
|
|
@ -2277,24 +2277,12 @@ function Ace2Inner(){
|
||||||
}
|
}
|
||||||
editorInfo.ace_performDocumentApplyAttributesToCharRange = performDocumentApplyAttributesToCharRange;
|
editorInfo.ace_performDocumentApplyAttributesToCharRange = performDocumentApplyAttributesToCharRange;
|
||||||
|
|
||||||
function performDocumentApplyAttributesToRange(start, end, attribs)
|
|
||||||
{
|
|
||||||
var builder = Changeset.builder(rep.lines.totalWidth());
|
|
||||||
ChangesetUtils.buildKeepToStartOfRange(rep, builder, start);
|
|
||||||
ChangesetUtils.buildKeepRange(rep, builder, start, end, attribs, rep.apool);
|
|
||||||
var cs = builder.toString();
|
|
||||||
performDocumentApplyChangeset(cs);
|
|
||||||
}
|
|
||||||
editorInfo.ace_performDocumentApplyAttributesToRange = performDocumentApplyAttributesToRange;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO move to AttributeManager
|
|
||||||
function setAttributeOnSelection(attributeName, attributeValue)
|
function setAttributeOnSelection(attributeName, attributeValue)
|
||||||
{
|
{
|
||||||
if (!(rep.selStart && rep.selEnd)) return;
|
if (!(rep.selStart && rep.selEnd)) return;
|
||||||
|
|
||||||
performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, [
|
documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
|
||||||
[attributeName, attributeValue]
|
[attributeName, attributeValue]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -2355,13 +2343,13 @@ function Ace2Inner(){
|
||||||
|
|
||||||
if (selectionAllHasIt)
|
if (selectionAllHasIt)
|
||||||
{
|
{
|
||||||
performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, [
|
documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
|
||||||
[attributeName, '']
|
[attributeName, '']
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, [
|
documentAttributeManager.setAttributesOnRange(rep.selStart, rep.selEnd, [
|
||||||
[attributeName, 'true']
|
[attributeName, 'true']
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -5400,8 +5388,8 @@ function Ace2Inner(){
|
||||||
|
|
||||||
|
|
||||||
// Init documentAttributeManager
|
// Init documentAttributeManager
|
||||||
|
|
||||||
documentAttributeManager = new AttributeManager(rep, performDocumentApplyChangeset);
|
documentAttributeManager = new AttributeManager(rep, performDocumentApplyChangeset);
|
||||||
|
editorInfo.ace_performDocumentApplyAttributesToRange = documentAttributeManager.setAttributesOnRange;
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
doc = document; // defined as a var in scope outside
|
doc = document; // defined as a var in scope outside
|
||||||
|
|
Loading…
Reference in a new issue