• 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
JavaScript $ReadOnlyArray<CompositeDecorator>
Hello together,

I'm trying to get some code working which will highlight links automatically in an rich text editor. This is not my own written code this is from draft js and is provided by many different web pages because this is the absolutlly basic how it should work out.
My major problem is that when I deifinine the linkDecorator of the type CompositeDecorator the compiler tells me that the linkDecorator is $ReadOnlyArray<DraftDecorator> which can't handle the provided input. I have absolutly no idea what I'm doing wrong because for people on about 10 different websites exactly this code works out well. Even in an [online compiler][1] were you can compile the code yourself it works.
Also practically the programm won't throw errors but it simply won't do anything anymore after this line.

Thanks in advance for any help!!!

    function findLinkEntities(contentBlock, callback, contentState){
        contentBlock.findEntityRanges((character) => {
            const entityKey = character.getEntity();
                entityKey !== null &&
                    contentState.getEntity(entityKey).getElementById() === 'LINK'
        }, callback);

    const Link = (props) => {
        const { url,linkText} = props.contentState
        return (
            <a style={{color: '#006cb7', textDecoration: 'underline'}}
                {linkText || props.children}

    const linkDecorator = new CompositeDecorator([
            strategy: findLinkEntities,
            component: Link,

Unfortunately I can't help you like that either.
Do you have online where you can test it exactly? I can't get any further there now, I would have to install them all myself first so that I can continue. If rzscout can't help you, you should ask the websites that created it and such.

Sorry, my English is very shit
Hier sind alle meine Lösungen aus allen Foren. Ich helfe auch in Facebook-chat
Hi Tim,
the problem is that, i can't help you, because i use only native/vanilla JavaScript and not React.

You have to ask your question in a special forum for React. Sorry, the question is too specific. Programming a RichTextEditor in JS is very, very complex as some functions like execCommand() are deprecated.


Gehe zu:

Benutzer, die gerade dieses Thema anschauen:
1 Gast/Gäste