forked from slab/quill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS native toolbar formatting inserts <b> and <i> nodes
- Loading branch information
Showing
4 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
import Inline from '../blots/inline'; | ||
|
||
class Bold extends Inline { } | ||
class Bold extends Inline { | ||
static create(value) { | ||
return super.create(); | ||
} | ||
|
||
static formats(domNode) { | ||
return true; | ||
} | ||
|
||
optimize() { | ||
super.optimize(); | ||
if (this.domNode.tagName !== this.statics.tagName[0]) { | ||
this.replaceWith(this.statics.blotName); | ||
} | ||
} | ||
} | ||
Bold.blotName = 'bold'; | ||
Bold.tagName = 'STRONG'; | ||
Bold.tagName = ['STRONG', 'B']; | ||
|
||
export default Bold; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import Inline from '../blots/inline'; | ||
import Bold from './bold'; | ||
|
||
class Italic extends Inline { } | ||
class Italic extends Bold { } | ||
Italic.blotName = 'italic'; | ||
Italic.tagName = 'EM'; | ||
Italic.tagName = ['EM', 'I']; | ||
|
||
export default Italic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Scroll from '../../../blots/scroll'; | ||
|
||
|
||
describe('Bold', function() { | ||
it('optimize and merge', function() { | ||
let scroll = this.initialize(Scroll, '<p><strong>a</strong>b<strong>c</strong></p>'); | ||
let bold = document.createElement('b'); | ||
bold.appendChild(scroll.domNode.firstChild.childNodes[1]); | ||
scroll.domNode.firstChild.insertBefore(bold, scroll.domNode.firstChild.lastChild); | ||
scroll.update(); | ||
expect(scroll.domNode).toEqualHTML('<p><strong>abc</strong></p>'); | ||
}); | ||
}); |