Prechádzať zdrojové kódy

Fixed: 富文本预览时/,插入的超链接不能打开新窗口

洪海涛 3 rokov pred
rodič
commit
24dd88b133

+ 7 - 2
src/components/searchInput/components/editor/index.js

@@ -78,8 +78,8 @@ class EditorInput extends React.Component {
         [0x2601, 'cloud'],
       ],
       images_upload_credentials: true,
-      plugins: 'fullscreen lists table textcolor wordcount contextmenu codesample link imagetools charmap', // 引入插件
-      toolbar: 'fullscreen bold italic underline strikethrough | fontsizeselect | forecolor backcolor link codesample | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent table | undo redo | removeformat formatselect charmap',
+      plugins: 'fullscreen lists table textcolor wordcount contextmenu codesample link imagetools charmap autolink paste', // 引入插件
+      toolbar: 'fullscreen bold italic underline strikethrough | fontsizeselect | forecolor backcolor link codesample | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent table | undo redo | removeformat formatselect charmap paste',
       table_toolbar: 'tableprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells',
       relative_urls: false,
       images_upload_url: 'http://star.xiaojukeji.com/upload/img.node',
@@ -90,6 +90,11 @@ class EditorInput extends React.Component {
         font-size: 14px;
       }
     `,
+      paste_preprocess: function(plugin, args) {
+        if ( args.content.search(/<a\ href/g) > -1) {
+          args.content = args.content.replace(/<a\ href/g, '<a target="_blank" href')
+        }
+      },
       images_upload_handler: (blobInfo, success, failure) => {
         //这里写你上传图片的方法
         console.log(11111, blobInfo, success, failure)