1
的jsfiddle丟失後:https://jsfiddle.net/wc4cxnvx/草案-JS:文本顏色轉換原始內容/ HTML回EditorState
我鍵入「這是非常有趣的事情」,並在編輯器中的正文綠色,然後保存爲原始內容使用convertToRaw:
{
"entityMap":{},
"blocks":[{"key":"5bbf7","text":"this is very interesting thing",
"type":"unstyled",
"depth":0,
"inlineStyleRanges":[{"offset":0,"length":30,"style":"color-rgb(26,188,156)"}],
"entityRanges":[],
"data":{}}]
}
的原始數據等同於HTML:
<p><span style="color: rgb(26,188,156);">this is very interesting thing</span></p>
我試圖同時使用原始內容以恢復狀態的編輯和HTML,在編輯器中既不顯示文字顏色。對於每種情況,只顯示沒有綠色的簡單「這是非常有趣的事情」。
我是用還原到editorstate代碼:
從原料:
editorState = EditorState.createWithContent(convertFromRaw(raw));
與HTML
let htmlBlocks = convertFromHTML(html);
let editorState = EditorState.createWithContent(ContentState.createFromBlockArray(htmlBlocks.contentBlocks, htmlBlocks.entityMap));
草案-JS版本是0.10。任何人都可以幫忙嗎?
有關修復Jason的其他信息?我遇到了類似的問題。知道哪個庫是你的問題可能會有很大的幫助 – shiggiddie