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

Is it possible to edit the raw HTML code and write it back into the editor #246

Open
RebeccaIsCoding opened this issue Jul 5, 2018 · 1 comment

Comments

@RebeccaIsCoding
Copy link

RebeccaIsCoding commented Jul 5, 2018

Hello :)

I am currently trying to implement the quill-editor into my app.
So far the basic functionalities work really well.

Now I wanted to add a custom button to the editor options that opens up a model in which it is possible to edit the HTML code that the editor creates and when clicking "ok" it should be written back into the editor via the v-model attribute.

Everything works so far BUT the editor kind of "ignores" the new tags written in the modal and just inserts the content into the old (for example 'p') tags.

Here is my HTML code:

<div>
            <quill-editor v-model="mail.messageContent"
                      :options="editorOption"
                      :disabled="disabled"
                      :class=" { readOnly: editorIsReadOnly }"
                      @blur="onEditorBlur($event)"
                      @focus="onEditorFocus($event)"
                      @ready="onEditorReady($event)">
                <div id="toolbar" slot="toolbar">
                    <!-- Custom Button -->
                    <button id="custom-button" :disabled="disabled" @click="setCodeContent(mail.messageContent, messageContentHTML)" v-b-modal.modal-center><span class="fas fa-code"></span></button>
                </div>
            </quill-editor>
            <b-modal id="modal-center" size="lg" centered title="HTML Code" @ok="setMailMessageContent(mail, messageContentHTML)">
                <b-form-textarea type="text"
                      placeholder="Enter HTML Code in here."
                      v-model="messageContentHTML"
                      rows="10">
                </b-form-textarea>
            </b-modal>
</div>
@Component({
    components: {
        quillEditor
    },
    props: {
        mail: Object
    },
    methods: {
        setCodeContent(messageContent: string, messageContentHTML: string) {
            messageContentHTML = messageContent;
        },
        setMailMessageContent(mail, messageContentHTML: string) {
            mail.messageContent = messageContentHTML;
        }
    },
    computed: {
        messageContent() {
            return this.messageContentHTML;
        }
    },
    watch: {
        'mail.messageContent'(oldValue) {
            this.messageContentHTML = oldValue;
        }
    }
})
@fabiooliveira1
Copy link

fabiooliveira1 commented Sep 18, 2018

I think it's related to this: slab/quill#128
I'm having the same problem, Quill removes table and div tags.

I'm trying to avoid JQuery, but this might be the only free solution: https://medium.com/@ScriptMint/a-simple-vue-js-summernote-component-4797e1f463c2

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

2 participants