Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const names = Arr.map(tabsFromSettings, (t) => {
if (typeof t === 'string') {
// Code below shouldn't care if a tab name doesn't have a spec.
// If we find it does, we'll need to make this smarter.
// CustomTabsTest has a case for this.
if (Obj.has(tabs, t)) {
newTabs[t] = tabs[t];
}
return t;
} else {
newTabs[t.name] = t;
return t.name;
}
});
return {tabs: newTabs, names};
return Obj.get(editor.settings, name).map(patchPipeConfig).getOrThunk(() => {
return Arr.filter(patchPipeConfig(defaultItems), (item) => Obj.has(contextMenus, item));
});
};
const isBlockFormatName = (name: string, formatter: Formatter): boolean => {
const formatSet = formatter.get(name);
return Type.isArray(formatSet) && Arr.head(formatSet).exists((format) => Obj.has(format as any, 'block'));
};
const isInlineFormat = (format: AllowedFormat): format is InlineStyleFormat => {
return Obj.has(format as Record, 'inline');
};
const isSelectorFormat = (format: AllowedFormat): format is SelectorStyleFormat => {
return Obj.has(format as Record, 'selector');
};
const translateCategory = (categories: Record, name: string) => {
return Obj.has(categories, name) ? categories[name] : name;
};
const isBlockFormat = (format: AllowedFormat): format is BlockStyleFormat => {
return Obj.has(format as Record, 'block');
};
const setMode = (editor: Editor, availableModes: Record, activeMode: Cell, mode: string) => {
if (mode === activeMode.get()) {
return;
} else if (!Obj.has(availableModes, mode)) {
throw new Error(`Editor mode '${mode}' is invalid`);
}
if (editor.initialized) {
switchToMode(editor, activeMode, availableModes, mode);
} else {
editor.on('init', () => switchToMode(editor, activeMode, availableModes, mode));
}
};
const setMode = (editor: Editor, availableModes: Record, activeMode: Cell, mode: string) => {
if (mode === activeMode.get()) {
return;
} else if (!Obj.has(availableModes, mode)) {
throw new Error(`Editor mode '${mode}' is invalid`);
}
if (editor.initialized) {
switchToMode(editor, activeMode, availableModes, mode);
} else {
editor.on('init', () => switchToMode(editor, activeMode, availableModes, mode));
}
};