Skip to content

Commit

Permalink
Add back font support, execCommand still uses it
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jan 13, 2015
1 parent 8f61dc9 commit f8582bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/core/normalizer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class Normalizer
'STRIKE' : 'S'
}

@ATTRIBUTES: {
'color': 'color'
'face' : 'fontFamily'
'size' : 'fontSize'
}

constructor: ->
@whitelist =
styles: {}
Expand All @@ -41,6 +47,13 @@ class Normalizer

normalizeNode: (node) ->
return node if dom(node).isTextNode()
_.each(Normalizer.ATTRIBUTES, (style, attribute) ->
if node.hasAttribute(attribute)
value = node.getAttribute(attribute)
value = dom.convertFontSize(value) if attribute == 'size'
node.style[style] = value
node.removeAttribute(attribute)
)
this.whitelistStyles(node)
return this.whitelistTags(node)

Expand Down
6 changes: 6 additions & 0 deletions test/unit/core/normalizer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ describe('Normalizer', ->
expect(@container).toEqualHTML('<b style="color: red;">Test</b>')
)

it('convert size attribute', ->
@container.innerHTML = '<font size="3">Test</font>'
Quill.Normalizer.normalizeNode(@container.firstChild)
expect(@container).toEqualHTML('<span style="font-size: 16px;">Test</span>')
)

it('text node', ->
@normalizer = new Quill.Normalizer()
@container.innerHTML = 'Test'
Expand Down

0 comments on commit f8582bd

Please sign in to comment.