-
Notifications
You must be signed in to change notification settings - Fork 244
Links not showing #24
Comments
Could this in any way be related to the issue with CSS for placeholder? Because the default CSS that comes with Do you want to set your own value of If you want to use your own link component - import { CompositeDecorator, Entity } from 'draft-js';
import { findLinkEntities, createEditorState } from 'medium-draft';
// create your link component however you like
const MyLinkComponent = (props) => {
const { url } = Entity.get(props.entityKey).getData();
return (
<a
href={url}
target="whatever"
>{props.children}</a>
);
};
const decorators = new CompositeDecorator([{
strategy: findLinkEntities,
component: MyLinkComponent,
}]);
// set editorState in your component like this -
// if you have initial empty data
const editorState = createEditorState(null, decorators);
// if you have some initial data in `initialData`
const editorState = createEditorState(initialData, decorators); |
I have definitely some CSS issues that i'm trying to solve, but i don't understand what is going on when i add a link. This is what i see:
|
I don't know if it can help, but the other inline buttons work correctly. |
This is what i get, as you can see there is no anchor element..
|
What version are you using? Can you try the latest version if its not ? |
I'm using the latest version (0.3.12). |
I think i found something interesting: the issue occurs only when i retrieve data from the database. Unfortunately right now i'm still persisting the html markup instead of the JSON.
It works perfectly for everything but the links. |
With the way you are creating import {stateFromHTML} from 'draft-js-import-html';
import {EditorState, CompositeDecorator} from 'draft-js';
import { findLinkEntities, Link } from 'medium-draft';
const decorators = new CompositeDecorator([{
strategy: findLinkEntities,
component: Link,
}]);
editorState = EditorState.createWithContent(stateFromHTML(markup), decorators); |
It works! |
When i add a link to any piece of text i don't see any style effects applied on that text. The link is saved correctly btw.
And more, is it possible to set the
target
attribute of the link?The text was updated successfully, but these errors were encountered: