Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_handleKeyCommand(command) {
// console.log("command",command);
const {editorState} = this.state;
const newState = RichUtils.handleKeyCommand(editorState, command);
if (command === 'editor-save'&&this.props.autoSave==true) {
// window.localDB//start20Text
// let Data=PRO_COMMON.localDB.getter("grab_news_data") || [];
let rawContentState = editorState.getCurrentContent()
let content = "",newText="";
const ConvertFormatProps = this.props.convertFormat;
if(ConvertFormatProps === 'html') {
content = stateToHTML(rawContentState);
newText=content.replace(/<[^>]*>|&[^;]*;/g, "");
}else if (ConvertFormatProps === 'markdown') {
content = stateToMD(rawContentState);
}else if(ConvertFormatProps === 'raw') {
const rawContent = convertToRaw(rawContentState);
content = JSON.stringify(rawContent);
handleKeyCommand(command:DraftEditorCommand) {
let new_state = RichUtils.handleKeyCommand(this.state.editor_state, command);
if (new_state) {
this.onChange(new_state, () => {
this.editor.focus()
})
return "handled"
}
return "not-handled"
}
handleKeyCommand = (command, editorState) => {
const newState = RichUtils.handleKeyCommand(editorState, command);
if (command === 'bold' || command === 'italic' || command === 'underline') {
const { content, style } = getKeyCommandData(command);
this.addContent(content, style);
return false;
}
if (newState && command !== 'backspace') {
this.onChange(newState);
return true;
}
return false;
};
_handleKeyCommand(commandName) {
const { editorState } = this.state;
const nextState = RichUtils.handleKeyCommand(editorState, commandName);
if (nextState) {
this.handleChange(nextState);
return 'handled';
}
return 'not handled';
}
handleKeyCommand = command => {
const { editorState } = this.props;
const newState = RichUtils.handleKeyCommand(editorState, command);
if (newState) {
this.onChange(newState);
return true;
}
return false;
};
export default function editorReducer(editorState = initialState, action) {
switch (action.type) {
case types.UPDATE_EDITOR:
return action.editorState
case types.TOGGLE_EDITOR_STYLE:
return RichUtils.toggleInlineStyle(editorState, action.style)
case types.EDITOR_KEY_COMMAND:
return RichUtils.handleKeyCommand(editorState, action.command) || editorState
case types.EDITOR_INSERT_LINK:
return RichUtils.toggleLink(
editorState,
action.selection ? action.selection : editorState.getSelection(),
Entity.create('LINK', 'IMMUTABLE', { url: action.url })
)
case types.EDITOR_REMOVE_LINK:
return RichUtils.toggleLink(
editorState,
action.selection ? action.selection : editorState.getSelection(),
null
)
handleKeyCommand = (command, editorState) => {
const newState = RichUtils.handleKeyCommand(editorState, command);
if (newState) {
this.setLocalState(newState, "note");
return 'handled';
}
return 'not-handled';
}
handleKeyCommand = (command: string) => {
const newState = RichUtils.handleKeyCommand(this.state.editorState, command);
if (newState) {
this.onChange(newState);
return 'handled';
}
return 'not-handled';
};
handleKeyCommand(command: string) {
const { editorState } = this.state
let newState = RichUtils.handleKeyCommand(editorState, command)
if (newState) {
this.onChange(newState)
return "handled"
}
return "not-handled"
}
_handleKeyCommand(command) {
const {editorState} = this.state;
const newState = RichUtils.handleKeyCommand(editorState, command);
if (newState) {
this.onChange(newState);
return true;
}
return false;
}
_scrollBar() {