Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getClipboardContent = (editor: Editor, clipboardEvent: ClipboardEvent) => {
const content = getDataTransferItems(clipboardEvent.clipboardData || (editor.getDoc() as any).dataTransfer);
// Edge 15 has a broken HTML Clipboard API see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11877517/
return Utils.isMsEdge() ? Tools.extend(content, { 'text/html': '' }) : content;
};
const processSelector = function (selector: string, group: StyleGroup) {
if (isUniqueSelector(editor, selector, group, globallyUniqueSelectors)) {
markUniqueSelector(editor, selector, group, globallyUniqueSelectors);
const format = convertSelectorToFormat(editor, editor.plugins.importcss, selector, group);
if (format) {
const formatName = format.name || DOMUtils.DOM.uniqueId();
editor.formatter.register(formatName, format);
// NOTE: itemDefaults has been removed as it was not supported by bridge and its concept
// is handled elsewhere.
return Tools.extend({}, {
title: format.title,
format: formatName
});
}
}
return null;
};
return Future.nu((completer) => {
const handler = (value: string, meta?: Record) => {
if (!Type.isString(value)) {
throw new Error('Expected value to be string');
}
if (meta !== undefined && !Type.isObject(meta)) {
throw new Error('Expected meta to be a object');
}
const r: UrlData = { value, meta };
completer(r);
};
const meta = Tools.extend({ filetype }, Option.from(entry.meta).getOr({}));
// file_picker_callback(callback, currentValue, metaData)
picker.call(editor, handler, entry.value, meta);
});
};
start (name, attrs) {
if (!data.source1 && name === 'param') {
data.source1 = attrs.map.movie;
}
if (name === 'iframe' || name === 'object' || name === 'embed' || name === 'video' || name === 'audio') {
if (!data.type) {
data.type = name;
}
data = Tools.extend(attrs.map, data);
}
if (name === 'script') {
const videoScript = getVideoScriptMatch(prefixes, attrs.map.src);
if (!videoScript) {
return;
}
data = {
type: 'script',
source1: attrs.map.src,
width: String(videoScript.width),
height: String(videoScript.height)
};
}
return Tools.map(groups, function (group) {
return Tools.extend({}, group, {
original: group,
selectors: {},
filter: compileFilter(group.filter),
item: {
text: group.title,
menu: []
}
});
});
};
handler(blobInfo, resolve, reject, Fun.noop);
} catch (ex) {
reject(ex.message);
}
});
};
const isDefaultHandler = (handler: Function) => {
return handler === defaultHandler;
};
const upload = (blobInfo: BlobInfo): Promise => {
return (!settings.url && isDefaultHandler(settings.handler)) ? Promise.reject('Upload url missing from the settings.') : uploadBlob(blobInfo, settings.handler);
};
settings = Tools.extend({
credentials: false,
handler: defaultHandler
}, settings);
return {
upload
};
};
const dataToHtml = function (editor: Editor, dataIn: MediaData) {
const data: MediaData = Tools.extend({}, dataIn);
if (!data.source1) {
Tools.extend(data, HtmlToData.htmlToData(Settings.getScripts(editor), data.embed));
if (!data.source1) {
return '';
}
}
if (!data.source2) {
data.source2 = '';
}
if (!data.poster) {
data.poster = '';
}