Ich habe Probleme beim Aktualisieren meiner Bildblöcke in editorState in draft.js. Ich möchte atomare ändern: image src beim Speichern der Schaltfläche. So ist die src zum Beispiel jetzt Blob: http://localhost:3000/7661d307-871b-4039-b7dd-6efc2701b623 aber ich mag src zu zum Beispiel aktualisieren /uploads-from-my-server/test.pngDraft.js. Wie kann ich Block atomic aktualisieren: image src später zum Beispiel Artikel speichern?
onSave(e) {
e.preventDefault();
const { editorState } = this.state;
const contentState = editorState.getCurrentContent();
editorState.getCurrentContent().getBlockMap().map((block) => {
const type = block.getType();
if (type === 'atomic:image') {
const rangeToReplace = new SelectionState({
anchorKey: block.getKey(),
focusKey: block.getKey(),
});
Modifier.replaceText(contentState, rangeToReplace, '/uploads-from-my-server/test.png');
const newContentState = editorState.getCurrentContent();
this.setState({ editorState: newContentState });
}
return true;
});
Ich weiß, dass ich src String zugreifen kann mit block.getData(). get (‚src‘), aber ich kippe gesetzt obwohl
Sie für Ihren fantastischen Editor Vielen
Danke ich werde es versuchen – jonjonson