Skip to content

Commit a776e60

Browse files
committed
feat: h1,h2,h3,h4,h5,h6 State mapping
1 parent 6982ca7 commit a776e60

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
#1.7.0
3+
### Added
4+
- Add h1,h2,h3,h4,h5,h6 State mapping
5+
36
### Fix
47
- [Toolbar active/inactive](https://github.com/wxik/react-native-rich-editor/issues/141)
58
- Adjust the format of `insertImage` to solve the bug that the picture cannot be deleted

src/editor.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ function createHTML(options = {}) {
242242
italic: { state: function() { return queryCommandState('italic'); }, result: function() { return exec('italic'); }},
243243
underline: { state: function() { return queryCommandState('underline'); }, result: function() { return exec('underline'); }},
244244
strikeThrough: { state: function() { return queryCommandState('strikeThrough'); }, result: function() { return exec('strikeThrough'); }},
245-
heading1: { result: function() { return exec(formatBlock, '<h1>'); }},
246-
heading2: { result: function() { return exec(formatBlock, '<h2>'); }},
247-
heading3: { result: function() { return exec(formatBlock, '<h3>'); }},
248-
heading4: { result: function() { return exec(formatBlock, '<h4>'); }},
249-
heading5: { result: function() { return exec(formatBlock, '<h5>'); }},
250-
heading6: { result: function() { return exec(formatBlock, '<h6>'); }},
251-
paragraph: { result: function() { return exec(formatBlock, '<p>'); }},
245+
heading1: { state: function() { return queryCommandState(formatBlock) === 'h1'; }, result: function() { return exec(formatBlock, '<h1>'); }},
246+
heading2: { state: function() { return queryCommandState(formatBlock) === 'h2'; }, result: function() { return exec(formatBlock, '<h2>'); }},
247+
heading3: { state: function() { return queryCommandState(formatBlock) === 'h3'; }, result: function() { return exec(formatBlock, '<h3>'); }},
248+
heading4: { state: function() { return queryCommandState(formatBlock) === 'h4'; }, result: function() { return exec(formatBlock, '<h4>'); }},
249+
heading5: { state: function() { return queryCommandState(formatBlock) === 'h5'; }, result: function() { return exec(formatBlock, '<h5>'); }},
250+
heading6: { state: function() { return queryCommandState(formatBlock) === 'h6'; }, result: function() { return exec(formatBlock, '<h6>'); }},
251+
paragraph: { state: function() { return queryCommandState(formatBlock) === 'p'; }, result: function() { return exec(formatBlock, '<p>'); }},
252252
quote: { result: function() { return exec(formatBlock, '<blockquote>'); }},
253253
removeFormat: { result: function() { return exec('removeFormat'); }},
254254
orderedList: {

0 commit comments

Comments
 (0)