本文整理汇总了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
);
}
示例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
}
}
示例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;
示例4: beforeEach
beforeEach(() => {
e.key = "Enter"
editorState = Draft.EditorState.createEmpty()
e.preventDefault = jest.fn()
})
示例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();
},
},
});
示例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',
});
示例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
);