Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createItem = (scope: Document, attr: Record, content: Element[]): Element => {
const item = Element.fromTag('li', scope);
Attr.setAll(item, attr);
InsertAll.append(item, content);
return item;
};
editor.undoManager.transact(() => {
const element = SugarElement.fromTag(forcedRootBlock);
Attr.setAll(element, Settings.getForcedRootBlockAttrs(editor));
Insert.append(element, SugarElement.fromTag('br'));
if (down) {
Insert.after(SugarElement.fromDom(table), element);
} else {
Insert.before(SugarElement.fromDom(table), element);
}
const rng = editor.dom.createRng();
rng.setStart(element.dom(), 0);
rng.setEnd(element.dom(), 0);
moveToRange(editor, rng);
});
} else {
const makeAnnotation = (eDoc: Document, { uid = Id.generate('mce-annotation'), ...data }, annotationName: string, decorate: Decorator): Element => {
const master = Element.fromTag('span', eDoc);
Class.add(master, Markings.annotation());
Attr.set(master, `${Markings.dataAnnotationId()}`, uid);
Attr.set(master, `${Markings.dataAnnotation()}`, annotationName);
const { attributes = { }, classes = [ ] } = decorate(uid, data);
Attr.setAll(master, attributes);
Classes.add(master, classes);
return master;
};
Arr.last(segments).each((segment) => {
Attr.setAll(segment.list, entry.listAttributes);
Attr.setAll(segment.item, entry.itemAttributes);
InsertAll.append(segment.item, entry.content);
});
};
Arr.last(segments).each((segment) => {
Attr.setAll(segment.list, entry.listAttributes);
Attr.setAll(segment.item, entry.itemAttributes);
InsertAll.append(segment.item, entry.content);
});
};
const insertBlock = (root: Element, forward: boolean, blockName: string, attrs: Record) => {
const block = Element.fromTag(blockName);
const br = Element.fromTag('br');
Attr.setAll(block, attrs);
Insert.append(block, br);
insertElement(root, block, forward);
return rangeBefore(br);
};
const normalizeSegment = (segment: Segment, entry: Entry): void => {
if (Node.name(segment.list) !== entry.listType) {
segment.list = Replication.mutate(segment.list, entry.listType);
}
Attr.setAll(segment.list, entry.listAttributes);
};