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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar button for mentions and references #443

Open
vanillajonathan opened this issue May 16, 2022 · 4 comments
Open

Toolbar button for mentions and references #443

vanillajonathan opened this issue May 16, 2022 · 4 comments

Comments

@vanillajonathan
Copy link
Contributor

EasyMDE could provide toolbar buttons for mentions and references.
These buttons would only provide icons, tooltips and insert the character @ and # into the editor. Nothing more.

It would be up to the user to implement hooks such as:

easyMDE.codemirror.on('change', function(cm, change) {
    if (change.text === '@') {
        alert('Your mention picker here');
    }
});
easyMDE.codemirror.on('change', function(cm, change) {
    if (change.text === '#') {
        alert('Your references picker here');
    }
});
@Ionaru
Copy link
Owner

Ionaru commented May 17, 2022

Easily doable using custom toolbar buttons.

const easyMDE = new EasyMDE({
    toolbar: [
        {
            name: 'mention-hashtag',
            title: "Mention",
            action: (editor) => {
                const cm = editor.codemirror;
                const text = cm.getSelection(); // You can also implement your reference picker here.
                cm.replaceSelection('#' + text);
            },
            className: "fa fa-hashtag",
        }
    ]
});

@vanillajonathan vanillajonathan changed the title Toolbar button for mentions and referenes Toolbar button for mentions and references May 17, 2022
@vanillajonathan
Copy link
Contributor Author

Yes, but this would be easier to do using a built-in button. It would also be better to hook in the reference picker on input so it also works when the user types @ into the editor.

@Ionaru
Copy link
Owner

Ionaru commented May 17, 2022

I agree that would be easier, but I'm trying to keep new configuration options tot a minimum until I have had the chance to rewrite the editor and get a better system for built-in buttons and plugins. ( I should make an issue tracking all that ) #447

I'll mark it as improvement and keep this open.

@vanillajonathan
Copy link
Contributor Author

Alright, sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants