當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ContentState.createFromText方法代碼示例

本文整理匯總了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'
         )
     );
 }
開發者ID:DevenLu,項目名稱:YourFukurou,代碼行數:9,代碼來源:tweet_editor.ts

示例2: closeEditor

 closeEditor() {
     GlobalKeyMaps.enable();
     return new TweetEditorState(
         EditorState.push(
             this.core,
             ContentState.createFromText(''),
             'remove-range'
         ),
         false,
         this.keymaps,
         null
     );
 }
開發者ID:DevenLu,項目名稱:YourFukurou,代碼行數:13,代碼來源:tweet_editor.ts

示例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);
}
開發者ID:jerome-poisson,項目名稱:superdesk-client-core,代碼行數:37,代碼來源:handlePastedText.ts

示例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,
  },
};
開發者ID:carlospaelinck,項目名稱:publications-js,代碼行數:30,代碼來源:new-shapes.ts


注:本文中的draft-js.ContentState.createFromText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。