本文整理汇总了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,
},
};