Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const appendItems = (values, output?: Types.SelectBox.ExternalSelectBoxItem[]) => {
output = output || [];
Tools.each(values, (item) => {
const menuItem: any = { text: item.text || item.title };
// TODO TINY-2236 - this implies table_class_list supports nested menus, but bridge doesn't, so this either needs to be supported or deleted
if (item.menu) {
menuItem.menu = appendItems(item.menu);
} else {
menuItem.value = item.value;
if (itemCallback) {
itemCallback(menuItem);
}
}
output.push(menuItem);
});
const sanitizeList = (list, extractValue: (item) => string): ListItem[] => {
const out: ListItem[] = [];
Tools.each(list, function (item) {
const text: string = Type.isString(item.text) ? item.text : Type.isString(item.title) ? item.title : '';
if (item.menu !== undefined) {
const items = sanitizeList(item.menu, extractValue);
out.push({ text, items }); // list group
} else {
const value = extractValue(item);
out.push({ text, value }); // list value
}
});
return out;
};
}
});
}
Tools.each(editor.contentCSS, function (url) {
contentCSSUrls[url] = true;
});
if (!fileFilter) {
fileFilter = function (href: string, imported: string) {
return imported || contentCSSUrls[href];
};
}
try {
Tools.each(doc.styleSheets, function (styleSheet: string) {
append(styleSheet);
});
} catch (e) {
// Ignore
}
return selectors;
};
editor.on('ObjectResized', function (e) {
const targetElm = e.target;
if (isTable(targetElm)) {
const table = targetElm;
if (percentageBasedSizeRegex.test(startRawW)) {
const percentW = parseFloat(percentageBasedSizeRegex.exec(startRawW)[1]);
const targetPercentW = e.width * percentW / startW;
editor.dom.setStyle(table, 'width', targetPercentW + '%');
} else {
const newCellSizes: CellSize[] = [];
Tools.each(table.rows, function (row: HTMLTableRowElement) {
Tools.each(row.cells, function (cell: HTMLTableCellElement) {
const width = editor.dom.getStyle(cell, 'width', true);
newCellSizes.push({
cell,
width
});
});
});
Tools.each(newCellSizes, function (newCellSize: CellSize) {
editor.dom.setStyle(newCellSize.cell, 'width', newCellSize.width);
editor.dom.setAttrib(newCellSize.cell, 'width', null);
});
}
}
});
const percentW = parseFloat(percentageBasedSizeRegex.exec(startRawW)[1]);
const targetPercentW = e.width * percentW / startW;
editor.dom.setStyle(table, 'width', targetPercentW + '%');
} else {
const newCellSizes: CellSize[] = [];
Tools.each(table.rows, function (row: HTMLTableRowElement) {
Tools.each(row.cells, function (cell: HTMLTableCellElement) {
const width = editor.dom.getStyle(cell, 'width', true);
newCellSizes.push({
cell,
width
});
});
});
Tools.each(newCellSizes, function (newCellSize: CellSize) {
editor.dom.setStyle(newCellSize.cell, 'width', newCellSize.width);
editor.dom.setAttrib(newCellSize.cell, 'width', null);
});
}
}
});
const destroyStates = (states: BlobState[]): void => {
Tools.each(states, destroyState);
};
Tools.each(table.rows, function (row: HTMLTableRowElement) {
Tools.each(row.cells, function (cell: HTMLTableCellElement) {
const width = editor.dom.getStyle(cell, 'width', true);
newCellSizes.push({
cell,
width
});
});
});
const buildMenuItems = function (listName: string, languageValues) {
const items = [];
Tools.each(languageValues, function (languageValue) {
items.push({
selectable: true,
text: languageValue.name,
data: languageValue.value
});
});
return items;
};