Giter VIP home page Giter VIP logo

react-headless-mde's Introduction

Hi there ๐Ÿ‘‹

๐Ÿ˜Ž I'm a Frontend developer with over 10 years of experience.

๐Ÿ”ญ My contacts and links to profiles here: webbrother.net

My current tech stack

GraphQL Apollo-GraphQL React Query Ant-Design TailwindCSS Axios

Webbrother's GitHub stats

Webbrother's languages stats

react-headless-mde's People

Contributors

hadimostafapour avatar webbrother avatar

Stargazers

 avatar

Watchers

 avatar

react-headless-mde's Issues

New API with command context

At the moment there is no way to pass command context which could be necessary for such a command like attachment to pass Promise to the command.

Current implementation: commandController.executeCommand('myCommandName');

1st Idea

The idea: commandController.executeCommand('myCommandName', commandContext);

To implement such functionality it is necessary

  • update the command type ICommand make it generic something like ICommand<CommandContext>
  • update CommandController so the instance could understand ICommand generic type
  const commandWithoutContext: ICommand = {...};
  const commandWithContext: ICommand<number> = {...};

  const { ref, commandController } = useTextAreaMarkdownEditor({
    commandMap: {
      commandName1: commandWithoutContext,
      commandName2: commandWithContext,
    },
  });

  commandController.executeCommand('commandName1'); // No error
  commandController.executeCommand('commandName1', 42); // Error: only 1 argument expected
  
  commandController.executeCommand('commandName2'); // Error: only 2 arguments expected
  commandController.executeCommand('commandName2', 42); // No error

2nd Idea

Current API can be changed this way:

  class CommandWithoutContext extends BaseCommand {...};
  class CommandWithContext extends BaseCommand<number> {...};

  const { ref, commands {
     commandName1,
     commandName2,
  }} = useTextAreaMarkdownEditor({
    commandMap: {
      commandName1: CommandWithoutContext,
      commandName2: CommandWithContext,
    },
  });

  commandName1(); // No error
  commandName1(42); // Error: 0 arguments expected
  
  commandName2(); // Error: 1 argument expected
  commandName2(42); // No error

Such changes require complex types inference logic wich I didn't implement at the moment.
If anyone has code examples of such type inference logic please share them here. Any idea will be highly appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.