|
@@ -48,36 +48,20 @@ export default {
|
|
|
},
|
|
|
customPaste: (editor, event) => {
|
|
|
const text = event.clipboardData.getData('text/plain');
|
|
|
- // if (text) {
|
|
|
- // let html = text.split(/\n/).map(line => {
|
|
|
- // line = line.replace(/\r/, '');
|
|
|
- // return `<p>${line}</p>`;
|
|
|
- // }).join('\n');
|
|
|
- // console.log(html, 'html');
|
|
|
- // html = html.replace(/>(\s{2,})[^\s]/g, (all, $1, $2) => {
|
|
|
- // if ($1.charAt(0) == '\n' || $1.charAt(0) == '\r' || $1.charAt(0) == '\x20') return all;
|
|
|
- // //  
|
|
|
- // return all.replace($1, Array($1.length).fill(' ').join(''));
|
|
|
- // });
|
|
|
- // const gethtml = editor.getHtml();
|
|
|
- // // console.log(`${gethtml}${html}`);
|
|
|
- // editor.setHtml(`${gethtml}${html}`);
|
|
|
- // // 阻止默认的粘贴行为
|
|
|
- // event.preventDefault();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- const nodeList = [];
|
|
|
- text.split(/\n/).map(line => {
|
|
|
- line = line.replace(/\r/, '');
|
|
|
- line = line.replace(/(\s{2})/, (all, $1) => {
|
|
|
- if ($1.charAt(0) == '\n' || $1.charAt(0) == '\r' || $1.charAt(0) == '\x20') return all;
|
|
|
- return all.replace($1, Array($1.length).fill(' ').join(''));
|
|
|
- });
|
|
|
- nodeList.push({ type: 'paragraph', children: [{ text: line }] });
|
|
|
- }).join('\n');
|
|
|
- SlateTransforms.insertNodes(editor, nodeList);
|
|
|
- event.preventDefault();
|
|
|
- return false;
|
|
|
+ if (text) {
|
|
|
+ const nodeList = [];
|
|
|
+ text.split(/\n/).map(line => {
|
|
|
+ line = line.replace(/\r/, '');
|
|
|
+ line = line.replace(/(\s{2})/, (all, $1) => {
|
|
|
+ if ($1.charAt(0) == '\n' || $1.charAt(0) == '\r' || $1.charAt(0) == '\x20') return all;
|
|
|
+ return all.replace($1, Array($1.length).fill(' ').join(''));
|
|
|
+ });
|
|
|
+ nodeList.push({ type: 'paragraph', children: [{ text: line }] });
|
|
|
+ }).join('\n');
|
|
|
+ SlateTransforms.insertNodes(editor, nodeList);
|
|
|
+ event.preventDefault();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
},
|
|
|
MENU_CONF: {
|
|
|
uploadImage: {
|