Copy All Text

This plugin will be responsible of clearing the terminal, done with the key combination cntrl + w, but temporarly done with cntrl + m, since control w closes the chrome tab, and we haven't found a way to override it .

The following code creates a function that does not work as one of the Editor's props per se but instead relies on the key_bindings_plugin (which uses one of such props) to assign a keycode to a command. This function is made visible to the other plugins through the return statement.

const getKeys = () => ({
    // keyCode: 87,
    keyCode: 77,
    keyWord: 'erase',
    hasCommandModifier: true,
    altKey: false,
  });

Next we use one of the props handleKeyCommand to start overwriting the default Editor's behaviour.

const handleKeyCommand = (command, obj) => {
    if (command === 'erase') {
      // Execute the code to ERASE
     return 'handled'; 
    }
    return 'not-handled';
  };

Then we create a new contentStte created from text, using the function createFromText, and pushing it to the current EditorState

const editorState = EditorState.push(obj.getEditorState(), ContentState.createFromText(initLineChar));

At last we set our new EditorState using obj.setEditorState.

obj.setEditorState(editorState);

results matching ""

    No results matching ""