fix(widget-markdown): cut/copy selection only in raw mode (#3024)

This commit is contained in:
Shawn Erquhart 2020-01-03 20:01:23 -05:00 committed by GitHub
parent 32f49683b1
commit 1b755b3be8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import styled from '@emotion/styled';
import { ClassNames } from '@emotion/core';
import { debounce } from 'lodash';
import { Value } from 'slate';
import { Editor as Slate, setEventTransfer } from 'slate-react';
import Plain from 'slate-plain-serializer';
import isHotkey from 'is-hotkey';
@ -52,7 +53,7 @@ export default class RawEditor extends React.Component {
handleCopy = async (event, editor) => {
event.persist();
const { getAsset, resolveWidget } = this.props;
const markdown = Plain.serialize(editor.value);
const markdown = Plain.serialize(Value.create({ document: editor.value.fragment }));
const html = await markdownToHtml(markdown, { getAsset, resolveWidget });
setEventTransfer(event, 'text', markdown);
setEventTransfer(event, 'html', html);