Skip to content

Support for conventional, form based usage #17

@Padam87

Description

@Padam87

Hi,

Users (admins really) became accustomed to this editor and there were scenarios (especially on our backend system), when a form based editor was needed. Eg editing a product desctiption on the admin instead of the frontend.

Also, using another, standard WYSIWYG editor led to some conflicts due to the HTML generated, so I had to cobble up a solution.

        $('.js-content-tools-form').submit(function (event) {
            let editor = ContentTools.EditorApp.get();
            editor.removeEventListener('saved');
            editor.stop(true);

            let $form = $(event.target);

            $form.find('[data-editable]').each(function (i, element) {
                let $element = $(element);

                let $input = $('<input type="hidden"></input>');
                $input
                    .attr('name', $element.data('name'))
                    .val($element.html())
                ;

                $form.append($input);
            });
        });

        $('.form-content-tools').click(function () {
            let editor = ContentTools.EditorApp.get();

            if (!editor.isEditing()) {
                editor.start();
            }
        });

It would be nice to have some kind of form support built in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    on roadmapAccepted on to the roadmap for the given milestone

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions