当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript EditorState.createEmpty方法代码示例

本文整理汇总了TypeScript中draft-js.EditorState.createEmpty方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EditorState.createEmpty方法的具体用法?TypeScript EditorState.createEmpty怎么用?TypeScript EditorState.createEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在draft-js.EditorState的用法示例。


在下文中一共展示了EditorState.createEmpty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: clearEditor

 clearEditor() {
     return new TweetEditorState(
         EditorState.createEmpty(editorDecolator),
         this.is_open,
         this.keymaps,
         null
     );
 }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:8,代码来源:tweet_editor.ts

示例2: getCurrentComment

} from '../../actions/document'
import {modifyInlineStyle, updateStyles} from '../ui/editor-syntax-highlighting'
import {Comment} from '../entities'

export type DocumentState = {
  creatingComment: SelectionState
  focusedComment: Comment
  comments: Comment[]
  editor: EditorState
  markdown: string
}
const initialState = {
  creatingComment: null,
  focusedComment: null,
  comments: [],
  editor: EditorState.createEmpty(),
  markdown: '',
}

function getCurrentComment(selection: SelectionState, content: ContentState) {
  if (!selection.isCollapsed()) return

  const block = content.getBlockForKey(selection.getAnchorKey())
  const metadata = block.getCharacterList().get(selection.getAnchorOffset())
  if (!metadata) return
  const entityKey = metadata.getEntity()
  const entity = entityKey && Entity.get(entityKey)
  if (entity && entity.getType() === 'Comment') {
    return entity.getData().id
  }
}
开发者ID:Pajn,项目名称:meltdown,代码行数:31,代码来源:document.ts

示例3: current

import { LOAD_NOTE, UPDATE_CURRENT_TITLE, UPDATE_CURRENT_BODY, UPDATE_CURRENT_FILENAME } from '../constants/ActionTypes.ts';
import { EditorState } from 'draft-js';

const initialState = {
  title: 'Untitled',
  body: EditorState.createEmpty(),
  filename: null
};

export default function current(state = initialState, action) {
  switch (action.type) {
    case UPDATE_CURRENT_TITLE:
      return Object.assign({}, state, {
        title: action.title,
      });
    case UPDATE_CURRENT_BODY:
      return Object.assign({}, state, {
        body: action.body
      });
    case UPDATE_CURRENT_FILENAME:
      return Object.assign({}, state, {
        filename: action.filename
      });
    case LOAD_NOTE:
      return Object.assign({}, state, {
        title: action.payload.title,
        body: action.payload.body,
        filename: action.payload.filename
      });
    default:
      return state;
开发者ID:zakarhino,项目名称:noam,代码行数:31,代码来源:current.ts

示例4: beforeEach

 beforeEach(() => {
   e.key = "Enter"
   editorState = Draft.EditorState.createEmpty()
   e.preventDefault = jest.fn()
 })
开发者ID:artsy,项目名称:positron,代码行数:5,代码来源:shared.test.ts

示例5: stateToHTML

import {EditorState, ContentBlock} from 'draft-js';
import {stateToHTML} from 'draft-js-export-html';

const state = EditorState.createEmpty();

let res: string = stateToHTML(state);
res = stateToHTML(state, {
    inlineStyles: {
        // Override default element (`strong`).
        BOLD: {element: 'b'},
        ITALIC: {
            // Add custom attributes. You can also use React-style `className`.
            attributes: {class: 'foo'},
            // Use camel-case. Units (`px`) will be added where necessary.
            style: {fontSize: 12}
        },
        // Use a custom inline style. Default element is `span`.
        RED: {style: {color: '#900'}},
    },
});
res = stateToHTML(state, {
    blockRenderers: {
        ATOMIC: (block) => {
            let data = block.getData();
            return data.toString();
        },
    },
});
开发者ID:joshdover,项目名称:draft-js-export-html,代码行数:28,代码来源:draft-js-export-html-tests.ts

示例6: stateToHTML

import {EditorState, ContentBlock} from 'draft-js';
import {stateToHTML} from 'draft-js-export-html';

const state = EditorState.createEmpty().getCurrentContent();

let res: string = stateToHTML(state);
res = stateToHTML(state, {
    inlineStyles: {
        // Override default element (`strong`).
        BOLD: {element: 'b'},
        ITALIC: {
            // Add custom attributes. You can also use React-style `className`.
            attributes: {class: 'foo'},
            // Use camel-case. Units (`px`) will be added where necessary.
            style: {fontSize: 12}
        },
        // Use a custom inline style. Default element is `span`.
        RED: {style: {color: '#900'}},
    },
});
res = stateToHTML(state, {
    blockRenderers: {
        ATOMIC: (block) => {
            let data = block.getData();
            return data.toString();
        },
    },
});
res = stateToHTML(state, {
    defaultBlockTag: 'div',
});
开发者ID:sstur,项目名称:draft-js-export-html,代码行数:31,代码来源:draft-js-export-html-tests.ts

示例7: closeEditor

            null
        );
    }

    closeEditor() {
        GlobalKeyMaps.enable();
        return new TweetEditorState(
            EditorState.push(
                this.core,
                ContentState.createFromText(''),
                'remove-range'
            ),
            false,
            this.keymaps,
            null
        );
    }

    toggleEditor() {
        return this.is_open ?  this.closeEditor() : this.openEditor();
    }
}

export const DefaultTweetEditorState =
    new TweetEditorState(
        EditorState.createEmpty(editorDecolator),
        false,
        new EditorKeymaps(),
        null
    );
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:30,代码来源:tweet_editor.ts


注:本文中的draft-js.EditorState.createEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。