Update decorator strategy API in accordance with recent changes to 0.11.0
See 590cdc6c54
, which is a change to the API not mentioned in the migration to v0.10 notes https://draftjs.org/docs/v0-10-api-migration.html
This commit is contained in:
parent
1d1cd5f691
commit
901cbf495d
2 changed files with 5 additions and 5 deletions
|
@ -90,7 +90,7 @@ function findWithRegex(regex, contentBlock: ContentBlock, callback: (start: numb
|
||||||
|
|
||||||
// Workaround for https://github.com/facebook/draft-js/issues/414
|
// Workaround for https://github.com/facebook/draft-js/issues/414
|
||||||
let emojiDecorator = {
|
let emojiDecorator = {
|
||||||
strategy: (contentBlock, callback) => {
|
strategy: (contentState, contentBlock, callback) => {
|
||||||
findWithRegex(EMOJI_REGEX, contentBlock, callback);
|
findWithRegex(EMOJI_REGEX, contentBlock, callback);
|
||||||
},
|
},
|
||||||
component: (props) => {
|
component: (props) => {
|
||||||
|
@ -119,7 +119,7 @@ export function getScopedRTDecorators(scope: any): CompositeDecorator {
|
||||||
export function getScopedMDDecorators(scope: any): CompositeDecorator {
|
export function getScopedMDDecorators(scope: any): CompositeDecorator {
|
||||||
let markdownDecorators = ['HR', 'BOLD', 'ITALIC', 'CODE', 'STRIKETHROUGH'].map(
|
let markdownDecorators = ['HR', 'BOLD', 'ITALIC', 'CODE', 'STRIKETHROUGH'].map(
|
||||||
(style) => ({
|
(style) => ({
|
||||||
strategy: (contentBlock, callback) => {
|
strategy: (contentState, contentBlock, callback) => {
|
||||||
return findWithRegex(MARKDOWN_REGEX[style], contentBlock, callback);
|
return findWithRegex(MARKDOWN_REGEX[style], contentBlock, callback);
|
||||||
},
|
},
|
||||||
component: (props) => (
|
component: (props) => (
|
||||||
|
@ -130,7 +130,7 @@ export function getScopedMDDecorators(scope: any): CompositeDecorator {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
markdownDecorators.push({
|
markdownDecorators.push({
|
||||||
strategy: (contentBlock, callback) => {
|
strategy: (contentState, contentBlock, callback) => {
|
||||||
return findWithRegex(MARKDOWN_REGEX.LINK, contentBlock, callback);
|
return findWithRegex(MARKDOWN_REGEX.LINK, contentBlock, callback);
|
||||||
},
|
},
|
||||||
component: (props) => (
|
component: (props) => (
|
||||||
|
|
|
@ -165,7 +165,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
this.client = MatrixClientPeg.get();
|
this.client = MatrixClientPeg.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
findLinkEntities(contentBlock: ContentBlock, callback, contentState: ContentState) {
|
findLinkEntities(contentState: ContentState, contentBlock: ContentBlock, callback) {
|
||||||
contentBlock.findEntityRanges(
|
contentBlock.findEntityRanges(
|
||||||
(character) => {
|
(character) => {
|
||||||
const entityKey = character.getEntity();
|
const entityKey = character.getEntity();
|
||||||
|
@ -189,7 +189,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
strategy: this.findLinkEntities.bind(this),
|
strategy: this.findLinkEntities.bind(this),
|
||||||
component: (entityProps) => {
|
component: (entityProps) => {
|
||||||
const Pill = sdk.getComponent('elements.Pill');
|
const Pill = sdk.getComponent('elements.Pill');
|
||||||
const {url} = contentState.getEntity(entityProps.entityKey).getData();
|
const {url} = entityProps.contentState.getEntity(entityProps.entityKey).getData();
|
||||||
if (Pill.isPillUrl(url)) {
|
if (Pill.isPillUrl(url)) {
|
||||||
return <Pill url={url} room={this.props.room} offsetKey={entityProps.offsetKey}/>;
|
return <Pill url={url} room={this.props.room} offsetKey={entityProps.offsetKey}/>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue