slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.93k stars 3.41k forks source link

Error when font family name include space #3785

Open plantain-00 opened 1 year ago

plantain-00 commented 1 year ago

Steps for Reproduction

  1. Visit [quilljs.com, jsfiddle.net, codepen.io]](https://quilljs.com/docs/formats/)
  2. Input 'a'
  3. Open browser console, input:
let Font = Quill.import('formats/font')
Font.whitelist = ['Source Han Sans CN']
quill.formatText(0,1,'font','Source Han Sans CN')

Expected behavior:

No Error

Actual behavior:

 Failed to execute 'add' on 'DOMTokenList': The token provided ('ql-font-Source Han Sans CN') contains HTML space characters, which are not valid in tokens.
    at e.add (https://cdn.quilljs.com/1.3.6/quill.min.js:7:88192)
    at t.attrib

Platforms:

Include browser, operating system and respective versions

Version:

1.3.6

toothbrush7777777 commented 1 year ago

Use dashes instead:

let Font = Quill.import('formats/font')
Font.whitelist = ['source-han-sans-cn']
quill.formatText(0,1,'font','source-han-sans-cn')
.ql-font-source-han-sans-cn {
  font-family: 'Source Han Sans CN';
}
benbro commented 10 months ago

Related https://github.com/quilljs/quill/issues/3292