Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setActive: (state: boolean) => {
// Note: We can't use the toggling behaviour here, as the dropdown for the menu also relies on it.
// As such, we'll need to do this manually
const elm = component.element();
if (state) {
Class.add(elm, ToolbarButtonClasses.Ticked);
Attr.set(elm, 'aria-pressed', true);
} else {
Class.remove(elm, ToolbarButtonClasses.Ticked);
Attr.remove(elm, 'aria-pressed');
}
},
isActive: () => Class.has(component.element(), ToolbarButtonClasses.Ticked)
Arr.each(nodeList, (n) => {
const parent = n.dom().parentNode;
if (isWrappedNbsp(parent)) {
Class.add(SugarElement.fromDom(parent), Data.nbspClass);
} else {
const withSpans = Nodes.replaceWithSpans(editor.dom.encode(SugarNode.value(n)));
const div = editor.dom.create('div', null, withSpans);
let node: any;
while ((node = div.lastChild)) {
editor.dom.insertAfter(node, n.dom());
}
editor.dom.remove(n.dom());
}
});
};
const toggleClass = (elm: Element, cls: string, state: boolean) => {
if (Class.has(elm, cls) && state === false) {
Class.remove(elm, cls);
} else if (state) {
Class.add(elm, cls);
}
};
AlloyEvents.run(NativeEvents.focusin(), runOnItem((comp, se, tgt) => {
SelectorFind.descendant(comp.element(), '.' + ItemClasses.activeClass).each((currentActive) => {
Class.remove(currentActive, ItemClasses.activeClass);
});
Class.add(tgt, ItemClasses.activeClass);
})),
AlloyEvents.run(NativeEvents.focusout(), runOnItem((comp) => {
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;
};
const updateEditorClasses = (editor: Editor, docked: boolean) => {
const editorContainer = Element.fromDom(editor.getContainer());
if (docked) {
Class.add(editorContainer, editorStickyOnClass);
Class.remove(editorContainer, editorStickyOffClass);
} else {
Class.add(editorContainer, editorStickyOffClass);
Class.remove(editorContainer, editorStickyOnClass);
}
};
const toggleClass = (elm: Element, cls: string, state: boolean) => {
if (Class.has(elm, cls) && state === false) {
Class.remove(elm, cls);
} else if (state) {
Class.add(elm, cls);
}
};
const updateEditorClasses = (editor: Editor, docked: boolean) => {
const editorContainer = Element.fromDom(editor.getContainer());
if (docked) {
Class.add(editorContainer, editorStickyOnClass);
Class.remove(editorContainer, editorStickyOffClass);
} else {
Class.add(editorContainer, editorStickyOffClass);
Class.remove(editorContainer, editorStickyOnClass);
}
};