What is a good javascript HTML editor for adding custom HTML elements?

前端 未结 1 743
广开言路
广开言路 2021-01-23 05:09

I want to create a web-based WYSIWYG HTML editor that allows the user to insert pre-defined HTML elements with certain class or id attributes.

For example, any HTML edit

相关标签:
1条回答
  • 2021-01-23 05:44

    CKEditor provides a flexible styles system, with rules defined as follows (in styles.js or directly in the config):

    {
        name: 'My style',
        element: 'h2',
        attributes: {
            'class': 'customClass',
            id: 'someId'
        },
        styles: {
            'font-style': 'italic'
        }
    },
    

    Producing:

    <h2 class="customClass" id="someId" style="font-style:italic;">Custom element</h2>
    

    Once defined, styles are available directly from the Styles Combo Box, possible to apply either to the current selection or to new elements.

    Styles can be created dynamically, applied to ranges and elements with the API. The Stylesheet Parser plugin can extract styles directly from CSS files.

    Note: Defining custom styles may need a proper configuration of Advanced Content Filter (since CKEditor 4.1).

    0 讨论(0)
提交回复
热议问题