本文整理匯總了TypeScript中draft-js.ContentState.createFromText方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ContentState.createFromText方法的具體用法?TypeScript ContentState.createFromText怎麽用?TypeScript ContentState.createFromText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類draft-js.ContentState
的用法示例。
在下文中一共展示了ContentState.createFromText方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: setTextToEditor
setTextToEditor(text: string) {
return EditorState.moveSelectionToEnd(
EditorState.push(
this.core,
ContentState.createFromText(text),
'insert-characters'
)
);
}
示例2: closeEditor
closeEditor() {
GlobalKeyMaps.enable();
return new TweetEditorState(
EditorState.push(
this.core,
ContentState.createFromText(''),
'remove-range'
),
false,
this.keymaps,
null
);
}
示例3: handlePastedText
export function handlePastedText(text: string, _html: string): DraftHandleValue {
const author = getCurrentAuthor();
let html = _html;
if (typeof html === 'string') {
html = removeMediaFromHtml(html);
}
const {editorState, suggestingMode, onPasteFromSuggestingMode, onChange, editorFormat} = this.props;
if (!html && !text) {
return 'handled';
}
if (suggestingMode) {
if (!Suggestions.allowEditSuggestionOnLeft(editorState, author)
&& !Suggestions.allowEditSuggestionOnRight(editorState, author)) {
return 'handled';
}
const content = html ? getContentStateFromHtml(html) : ContentState.createFromText(text);
onPasteFromSuggestingMode(content);
return 'handled';
}
if (html &&
pasteContentFromOpenEditor(html, editorState, onChange, editorFormat) === 'handled') {
return 'handled';
}
if (htmlComesFromDraftjsEditor(html)) {
return 'not-handled';
}
return processPastedHtml(html || text, editorState, onChange, editorFormat);
}
示例4:
y: 0.25,
r: 0,
z: 0,
width: 1,
height: 1,
fill: "#609eeb",
stroke: "#4e8bda",
strokeWidth: 1,
strokeOpacity: 1.0,
fillOpacity: 1.0,
},
Text: {
id: "0",
type: PubShapeType.Text,
x: 0.25,
y: 0.25,
r: 0,
z: 0,
editorState: EditorState.createWithContent(
ContentState.createFromText("Double click to insert text")
),
fill: "",
fillOpacity: 1,
stroke: "",
strokeOpacity: 0,
strokeWidth: 0,
width: 2,
height: 1,
},
};