mirror of https://github.com/vector-im/riot-web
Reflect API change for decorator strategy
parent
fb5dc295aa
commit
1d1cd5f691
|
@ -165,18 +165,16 @@ export default class MessageComposerInput extends React.Component {
|
||||||
this.client = MatrixClientPeg.get();
|
this.client = MatrixClientPeg.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
getLinkFindingStrategy(contentState: ContentState) {
|
findLinkEntities(contentBlock: ContentBlock, callback, contentState: ContentState) {
|
||||||
return (contentBlock, callback) => {
|
contentBlock.findEntityRanges(
|
||||||
contentBlock.findEntityRanges(
|
(character) => {
|
||||||
(character) => {
|
const entityKey = character.getEntity();
|
||||||
const entityKey = character.getEntity();
|
return (
|
||||||
return (
|
entityKey !== null &&
|
||||||
entityKey !== null &&
|
contentState.getEntity(entityKey).getType() === 'LINK'
|
||||||
contentState.getEntity(entityKey).getType() === 'LINK'
|
);
|
||||||
);
|
}, callback,
|
||||||
}, callback,
|
);
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -188,7 +186,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
const decorators = richText ? RichText.getScopedRTDecorators(this.props) :
|
const decorators = richText ? RichText.getScopedRTDecorators(this.props) :
|
||||||
RichText.getScopedMDDecorators(this.props);
|
RichText.getScopedMDDecorators(this.props);
|
||||||
decorators.push({
|
decorators.push({
|
||||||
strategy: this.getLinkFindingStrategy(contentState),
|
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} = contentState.getEntity(entityProps.entityKey).getData();
|
||||||
|
@ -727,7 +725,6 @@ export default class MessageComposerInput extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const findLinkEntities = this.getLinkFindingStrategy(contentState);
|
|
||||||
// Use the original contentState because `contentText` has had mentions
|
// Use the original contentState because `contentText` has had mentions
|
||||||
// stripped and these need to end up in contentHTML.
|
// stripped and these need to end up in contentHTML.
|
||||||
|
|
||||||
|
@ -738,7 +735,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
const pt = contentState.getBlocksAsArray().map((block) => {
|
const pt = contentState.getBlocksAsArray().map((block) => {
|
||||||
let blockText = block.getText();
|
let blockText = block.getText();
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
findLinkEntities(block, (start, end) => {
|
this.findLinkEntities(block, (start, end) => {
|
||||||
const entity = contentState.getEntity(block.getEntityAt(start));
|
const entity = contentState.getEntity(block.getEntityAt(start));
|
||||||
if (entity.getType() !== 'LINK') {
|
if (entity.getType() !== 'LINK') {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue