Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const unwrap = (data: DialogData): MediaData => {
const unwrapped = Merger.merge(data, {
source1: data.source1.value,
source2: Obj.get(data, 'source2').bind((source2) => Obj.get(source2, 'value')).getOr(''),
poster: Obj.get(data, 'poster').bind((poster) => Obj.get(poster, 'value')).getOr('')
});
// Add additional size values that may or may not have been in the data
Obj.get(data, 'dimensions').each((dimensions) => {
Arr.each([ 'width', 'height' ] as ('width' | 'height')[], (prop) => {
Obj.get(dimensions, prop).each((value) => unwrapped[prop] = value);
});
});
return unwrapped;
};
const wrap = (data: MediaData): DialogData => {
const wrapped = Merger.merge(data, {
source1: { value: Obj.get(data, 'source1').getOr('') },
source2: { value: Obj.get(data, 'source2').getOr('') },
poster: { value: Obj.get(data, 'poster').getOr('') }
});
// Add additional size values that may or may not have been in the html
Arr.each([ 'width', 'height' ] as (keyof MediaData)[], (prop) => {
Obj.get(data, prop).each((value) => {
const dimensions = wrapped.dimensions || {};
dimensions[prop] = value;
wrapped.dimensions = dimensions;
});
});
return wrapped;
};
const unwrap = (data: DialogData): MediaData => {
const unwrapped = Merger.merge(data, {
source1: data.source1.value,
source2: Obj.get(data, 'source2').bind((source2) => Obj.get(source2, 'value')).getOr(''),
poster: Obj.get(data, 'poster').bind((poster) => Obj.get(poster, 'value')).getOr('')
});
// Add additional size values that may or may not have been in the data
Obj.get(data, 'dimensions').each((dimensions) => {
Arr.each([ 'width', 'height' ] as ('width' | 'height')[], (prop) => {
Obj.get(dimensions, prop).each((value) => unwrapped[prop] = value);
});
});
return unwrapped;
};
const getBorder = () => {
const borderWidth = style['border-width'];
if (shouldStyleWithCss(editor) && borderWidth) {
return { border: borderWidth };
}
return Obj.get(attrs, 'border').fold( () => ({}), (border) => ({ border }));
};
const extractAdvancedStyleData = (dom) => {
const rgbToHex = (value: string) => Strings.startsWith(value, 'rgb') ? dom.toHex(value) : value;
const borderStyle = Obj.get(style, 'border-style').getOr('');
const borderColor = Obj.get(style, 'border-color').getOr('');
const bgColor = Obj.get(style, 'background-color').getOr('');
return {
borderstyle: borderStyle,
bordercolor: rgbToHex(borderColor),
backgroundcolor: rgbToHex(bgColor)
};
};
const getCellPaddingCellSpacing = () => {
const spacing = Obj.get(style, 'border-spacing').or(Obj.get(attrs, 'cellspacing')).fold( () => ({}), (cellspacing) => ({ cellspacing }));
const padding = Obj.get(style, 'border-padding').or(Obj.get(attrs, 'cellpadding')).fold( () => ({}), (cellpadding) => ({ cellpadding }));
return {
...spacing,
...padding
};
};
Arr.each([ 'width', 'height' ] as (keyof MediaData)[], (prop) => {
Obj.get(data, prop).each((value) => {
const dimensions = wrapped.dimensions || {};
dimensions[prop] = value;
wrapped.dimensions = dimensions;
});
});
const foundTabs: Option[] = Arr.map(names, (name) => {
return Obj.get(tabs, name);
});
const dialogTabs: Types.Dialog.TabApi[] = Options.cat(foundTabs);