Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挕TOOL: Add an autocomplete tool type #1623

Open
jeremyVignelles opened this issue Apr 5, 2021 · 11 comments
Open

馃挕TOOL: Add an autocomplete tool type #1623

jeremyVignelles opened this issue Apr 5, 2021 · 11 comments

Comments

@jeremyVignelles
Copy link

  1. Describe a problem.
    When typing a text, I'm used to the github workflow where I can type # to refer to an issue, @ to mention someone or : to open the emoji panel. These kind of interactions are widely used in modern forums/chat, but as far as I've seen, are not possible with editor.js right now.

  2. Describe the solution you'd like. Mockups are welcome.
    Autocomplete tools would be triggered by typing its marker, and can be discarded using the escape key.
    The autocomplete tool API could look something like this : (10 seconds thinking, might need some adjustments)

class MentionTool {

    static get isAutocomplete() {
        return true;
    }

    static get trigger() {
        return '@';
    }

    complete(text) {
        return [
            {// Each auto complete item has a free form, and is given as-is to the makeListItem/itemSelected functions
               id: 16060815,
               text: "CodeX-Team",
               profilePicture: "https://avatars.githubusercontent.com/u/16060815?s=200&v=4"
            }
        ].filter(i => i.text.startsWith(text));
    }

    makeListItem(item) { // Creates a list item to show in the autocomplete list
         return `<img src="${item.profilePicture}" /> ${item.text}`;
    }

    itemSelected(selectedItem) { // Creates the code to put in the editor
          return `<a class="mention" href="/user/${selectedItem.id}">#${selectedItem.text}</a>`;
    } 
    
}
  1. Are there any alternatives?
    There is the "inline tool" type, but you need to select a text and apply the inline tool, which breaks the natural flow of typing.
@zegenie
Copy link

zegenie commented Apr 6, 2021

I want to add a suggestion to allow the complete() method, or other methods to populate the list to be async, so that it can also be used for things like inline suggestions based on a server response, such as looking up related documents, linking to things and searching for users.

Apart from that, 馃憤 on this one.

@jeremyVignelles
Copy link
Author

Indeed, I didn't make it clear, but ajax responses are indeed on top of the wishlist 馃槃

@gohabereg gohabereg added this to Needs triage in Issues triage Mar 21, 2022
@Voloshchenko
Copy link

Hi, any news on this feature?

@ludusrusso
Copy link

ludusrusso commented Jan 5, 2023

I need it too!

@giuppidev
Copy link

I really need this solution too!

@thijskuilman
Copy link

I agree; this would be really useful!

@neSpecc neSpecc removed the feature label Jan 28, 2023
@geekyayush
Copy link

Upvoting for this

@bettysteger
Copy link
Contributor

bettysteger commented Jan 10, 2024

I hope i can help someone with this: https://gist.github.com/bettysteger/d8f660030849ae85211d51d93e736a3b

My solution of getting this to work:

  1. Listening to paragraphs for inputting @
  2. Replace @ with <a rel="tag">@</a> and select the new anchor tag to trigger the custom mention inline tool
  3. Mention inline tool opens up an user list, where you can search and select the user to tag!

Inline output will be <a href="#${user.id}" rel="tag">${user.name}</a>.

Feedback is highly appreciated!

@poojaramanigc
Copy link

I hope i can help someone with this: https://gist.github.com/bettysteger/d8f660030849ae85211d51d93e736a3b

My solution of getting this to work:

  1. Listening to paragraphs for inputting @
  2. Replace @ with <a rel="tag">@</a> and select the new anchor tag to trigger the custom mention inline tool
  3. Mention inline tool opens up an user list, where you can search and select the user to tag!

Inline output will be <a href="#${user.id}" rel="tag">${user.name}</a>.

Feedback is highly appreciated!

this is not working for me can you provide full working codesendbox link. i really want to implement this feature

@bettysteger
Copy link
Contributor

this is not working for me can you provide full working codesendbox link. i really want to implement this feature

here you go: https://codesandbox.io/p/sandbox/editorjs-mentions-37fl8x

@artfxx
Copy link

artfxx commented Mar 18, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Issues triage
Needs triage
Development

No branches or pull requests