Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onDrop(event, change, editor) {
const transfer = getEventTransfer(event);
const range = getEventRange(event, change.value);
switch (transfer.type) {
case 'text': {
const { text } = transfer;
if (!isUrl(text))
return;
if (text.endsWith("png?raw=1") || text.endsWith("png?raw=1")
|| text.endsWith("jpg?raw=1") || text.endsWith("JPG?raw=1") ) {
// a special URL from seafile server
var node = Inline.create({
type: 'image',
isVoid: true,
data: {
src: text
}
});
function onPaste(event, editor, next: (arg0: void) => void) {
event.preventDefault()
onProgress({status: 'start'})
const transfer = getEventTransfer(event)
const {fragment, html, text} = transfer
const {type} = transfer
if (type === 'fragment') {
onProgress({status: 'fragment'})
// Check if we have all block types in the schema,
// otherwise, use html version
const allSchemaBlockTypes = blockContentType.of
.map(ofType => ofType.name)
.concat('contentBlock')
const allBlocksHasSchemaDef = fragment.nodes
.map(node => node.type)
.every(nodeType => allSchemaBlockTypes.includes(nodeType))
if (allBlocksHasSchemaDef) {
ensureNoPlaceholder(editor)
const {focusBlock} = editor.value
const newNodesList = Block.createList(fragment.nodes.map(node => processNode(node, editor)))
onPaste = (e, change) => {
const transfer = getEventTransfer(e);
const { type } = transfer;
switch (type) {
// case 'files': return this.handleOnDrop(files);
case 'text': return onPasteText(e, change);
case 'html': return onPasteHtml(e, change);
default: break;
}
}
export default (event, editor, next) => {
const { value } = editor
if (value.selection.isCollapsed) return next()
const transfer = getEventTransfer(event)
const { type, text } = transfer
if (type !== 'text' && type !== 'html') return next()
if (!isURL(text)) return next()
if (editor.hasLinks()) {
editor.unwrapLink()
}
editor.wrapLink({ href: text })
}
onPaste: (event, change) => {
const transfer = getEventTransfer(event);
const { type, text } = transfer;
if (type !== "text" && type !== "html") {
return;
}
if (!isUrl(text)) {
return;
}
change
.insertText(text)
.extend(-text.length)
.call(wrapLink, text);
return false;
},
onPaste = (event, editor, next) => {
const transfer = getEventTransfer(event);
if (transfer.type !== "html") return next();
const { document } = html.deserialize(transfer.html);
editor.insertFragment(document);
};
handlePaste = (event, editor, next) => {
const { onImageUpload } = this.props;
const transfer = getEventTransfer(event);
const type = getPasteType(transfer);
const paste = paster[type];
if (paste) {
return paste({ editor, transfer, onImageUpload });
}
next();
};
const handleDrop = (
event: React.DragEvent<element>,
editor: Editor,
next: () => any
) => {
const target = editor.findEventRange(event);
if (!target && event.type === 'drop') return next();
const transfer: any = getEventTransfer(event);
const { type, files } = transfer;
if (type === 'files') {
addImageToEditor(editor, files);
return;
}
next();
};
</element>
onPaste = (event, change) => {
scrollToCursor();
const transfer = getEventTransfer(event);
if (transfer.type != "html") return;
const { document } = html.deserialize(transfer.html);
change.insertFragment(document);
return true;
};
onPaste(event, change) {
const transfer = getEventTransfer(event);
if (transfer.type !== "html") return;
if (transfer.isShift) return;
const { document } = html.deserialize(transfer.html);
change.insertFragment(document);
return true;
}
};