Skip to content

Commit

Permalink
fix/clipboard: use docsSoap to prepare html from google doc
Browse files Browse the repository at this point in the history
fix #365 [Editor] - Texts become bold when copy and paste from Google doc

References:
- facebookarchive/draft-js#393 (comment)
- https://github.com/superdesk/superdesk-client-core/blob/develop/scripts/core/editor3/html/from-html/index.ts#L60
- slab/quill#2462 has some dirty fix with side effects
- ProseMirror/prosemirror#459 (comment)
  this fix mentioned ProseMirror/prosemirror-schema-basic@cbbdc1a691
  in ProseMirror looks much cleaner
  • Loading branch information
tomasc authored and Tomas.C committed Oct 5, 2021
1 parent 7bc2b93 commit c504bb7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dependencies": {
"autosize": "^4.0.2",
"classnames": "^2.2.6",
"docs-soap": "^1.2.1",
"react-quill": "^1.3.3"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion src/modules/clipboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Quill } from 'react-quill'

import { docsSoap } from 'docs-soap'

import createImageMatcher from '../matchers/createImage'
import { isSafari } from '../utils/browser'
import { dom } from '../utils/dom'
Expand Down Expand Up @@ -46,7 +48,8 @@ class RemadeClipboard extends Clipboard {
event.stopPropagation()

const formats = this.quill.getFormat(this.quill.selection.savedRange.index)
const html = event.clipboardData.getData('text/html')
const htmlRaw = event.clipboardData.getData('text/html')
const html = docsSoap(htmlRaw) // Needed for Google docs
const text = event.clipboardData.getData('text/plain')

let delta = new Delta().retain(range.index)
Expand Down

0 comments on commit c504bb7

Please sign in to comment.