mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Changeset: Migrate to the new attribute API
This commit is contained in:
parent
f40d285109
commit
f1eb7a25a6
15 changed files with 175 additions and 210 deletions
|
@ -26,6 +26,7 @@ const makeCSSManager = require('./cssmanager').makeCSSManager;
|
|||
const domline = require('./domline').domline;
|
||||
const AttribPool = require('./AttributePool');
|
||||
const Changeset = require('./Changeset');
|
||||
const attributes = require('./attributes');
|
||||
const linestylefilter = require('./linestylefilter').linestylefilter;
|
||||
const colorutils = require('./colorutils').colorutils;
|
||||
const _ = require('./underscore');
|
||||
|
@ -114,20 +115,18 @@ const loadBroadcastJS = (socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
},
|
||||
|
||||
getActiveAuthors() {
|
||||
const authors = [];
|
||||
const seenNums = {};
|
||||
const alines = this.alines;
|
||||
for (let i = 0; i < alines.length; i++) {
|
||||
Changeset.eachAttribNumber(alines[i], (n) => {
|
||||
if (seenNums[n]) return;
|
||||
seenNums[n] = true;
|
||||
if (this.apool.getAttribKey(n) !== 'author') return;
|
||||
const a = this.apool.getAttribValue(n);
|
||||
if (a) authors.push(a);
|
||||
});
|
||||
const authorIds = new Set();
|
||||
for (const aline of this.alines) {
|
||||
const opIter = Changeset.opIterator(aline);
|
||||
while (opIter.hasNext()) {
|
||||
const op = opIter.next();
|
||||
for (const [k, v] of attributes.attribsFromString(op.attribs, this.apool)) {
|
||||
if (k !== 'author') continue;
|
||||
if (v) authorIds.add(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
authors.sort();
|
||||
return authors;
|
||||
return [...authorIds].sort();
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue