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

How can I add command button then render it? #10

Closed
danvim opened this issue Jun 13, 2015 · 5 comments
Closed

How can I add command button then render it? #10

danvim opened this issue Jun 13, 2015 · 5 comments

Comments

@danvim
Copy link

danvim commented Jun 13, 2015

I have the following code:

woofmark(document.querySelector('#ta'), {
        parseMarkdown: megamark,
        parseHTML: domador,
        render: {
            commands: function (button, id) {
                button.className = 'btn';
                var n = {
                    "bold": 'B',
                    "italic": 'I',
                    "quote": 'Q',
                    "code": 'C',
                    "ol": 'OL',
                    "ul": 'UL',
                    "heading": 'H',
                    "link": 'A',
                    "image": 'IMG'
                };
                button.innerHTML = n[id];
            },
            modes: function (button, id) {
                button.className = 'btn';
                var n = {
                    "markdown": "MarkDown",
                    "html": "HTML",
                    "wysiwyg": "WYSIWYG"
                }
                button.innerHTML = n[id];
            }
        }
    }).addCommandButton("Jump", function jump() {});

Is there is not a built-in way to render added command buttons? Or do I have to do it outside woofmark?

@danvim danvim closed this as completed Jun 13, 2015
@tobigit
Copy link

tobigit commented Dec 13, 2016

@danvim How do you solved the Problem?
I would like to disallow the features "link" and "image". It would be nice when the regarding buttons won't be rendered.
And on top i would like to implement the features "underline" and "line trough".

@jywarren
Copy link
Collaborator

Hi, add commands with: https://github.com/bevacqua/woofmark#editoraddcommandbuttonid-combo-fn

For hiding features, that's probably a separate issue -- but I did so using JavaScript after initializing woofmark, which is not so clean but definitely works: https://github.com/publiclab/PublicLab.Editor/blob/master/src/adapters/PublicLab.Woofmark.js#L278-L281

@danvim
Copy link
Author

danvim commented Dec 13, 2016

@tobigit I forgot since it was long ago, but it was through looking through the source code. I eventually went for another editor.

@tobigit
Copy link

tobigit commented Dec 14, 2016

@jywarren @danvim Ok, thank you. If woofmark will take part of our software i will need an configurable and clean way to handle command-buttons.

@bevacqua, is there something in your pipeline regarding configurable command-buttons?

@jywarren
Copy link
Collaborator

I think there's a possibility of adding a new options param for rendered buttons, but it'd a bit complex to implement. Currently, buttons are referred to:

I guess to create this feature, you'd have to provide an opportunity to add new items to the strings, and new commands that correspond to them, before render occurs.

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

No branches or pull requests

3 participants