lint & refactor PR #187

This commit is contained in:
Kevin Jahns
2020-04-01 23:39:27 +02:00
parent 195b26d90f
commit c87caafeb6
3 changed files with 28 additions and 22 deletions

View File

@@ -800,27 +800,24 @@ export class YText extends AbstractType {
str += /** @type {ContentString} */ (n.content).str
break
}
case ContentEmbed:
case ContentEmbed: {
packStr()
/**
* @type {Object<string,any>}
*/
const attributes = {}
let addAttributes = false;
for (const [key, value] of currentAttributes) {
addAttributes = true;
attributes[key] = value
}
/**
* @type {Object<string,any>}
*/
const op = {
insert: /** @type {ContentEmbed} */ (n.content).embed
}
if(addAttributes) {
op.attributes = attributes
if (currentAttributes.size > 0) {
const attrs = /** @type {Object<string,any>} */ ({})
op.attributes = attrs
for (const [key, value] of currentAttributes) {
attrs[key] = value
}
}
ops.push(op)
break
}
case ContentFormat:
if (isVisible(n, snapshot)) {
packStr()