diff --git a/src/RichTextEditor.js b/src/RichTextEditor.js index 51e212ef..4d16b749 100644 --- a/src/RichTextEditor.js +++ b/src/RichTextEditor.js @@ -42,6 +42,7 @@ export default class RichTextEditor extends Component { this.state = { selectionChangeListeners: [], onChange: [], + titleOnChange: [], showLinkDialog: false, linkInitialUrl: '', linkTitle: '', @@ -187,6 +188,11 @@ export default class RichTextEditor extends Component { this.state.onChange.map((listener) => listener(content)); break; } + case messages.TITLE_CHANGE: { + const {title} = message.data; + this.state.titleOnChange.map((listener) => listener(title)); + break; + } case messages.SELECTED_TEXT_CHANGED: { const selectedText = message.data; this._selectedTextChangeListeners.forEach((listener) => { @@ -364,6 +370,12 @@ export default class RichTextEditor extends Component { }); } + registerTitleChangeListener(listener) { + this.setState({ + titleOnChange: [...this.state.titleOnChange, listener] + }); + } + setTitleHTML(html) { this._sendAction(actions.setTitleHtml, html); } diff --git a/src/const.js b/src/const.js index 653b43f8..88add502 100644 --- a/src/const.js +++ b/src/const.js @@ -67,6 +67,7 @@ export const messages = { CONTENT_FOCUSED: 'CONTENT_FOCUSED', SELECTION_CHANGE: 'SELECTION_CHANGE', CONTENT_CHANGE: 'CONTENT_CHANGE', + TITLE_CHANGE: 'TITLE_CHANGE', SELECTED_TEXT_RESPONSE: 'SELECTED_TEXT_RESPONSE', LINK_TOUCHED: 'LINK_TOUCHED', SELECTED_TEXT_CHANGED: 'SELECTED_TEXT_CHANGED' diff --git a/src/editor.html b/src/editor.html index 1b30f937..051f6fcc 100644 --- a/src/editor.html +++ b/src/editor.html @@ -1383,6 +1383,12 @@ data: {content: getHtml("zss_editor_content")} })) }); + $('#zss_editor_title').on('input', function(){ + WebViewBridge.send(JSON.stringify({ + type: 'TITLE_CHANGE', + data: {title: getHtml("zss_editor_title")} + })) + }); } zss_editor.hideTitle = function() {