tinymce-svelte icon indicating copy to clipboard operation
tinymce-svelte copied to clipboard

Svelte support for editor.setContent

Open staadecker opened this issue 2 years ago • 1 comments

Hi there!

My apologies if this is a basic question, I'm still learning Svelte and TinyMCE.

Say I have some custom Svelte component

MyComponent.svelte

<script lang="ts">
    ...
</script>
<div>
   ...
</div>

And I want to add it inside a TinyMCE editor using a button in the toolbar. Something like this:

<script lang="ts">
    import Editor from '@tinymce/tinymce-svelte';
    import MyComponent from "../components/MyComponent.svelte";

    let conf = {
        menubar: false,
        branding: false,
        statusbar: false,
        toolbar: "undo redo | styles | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | add_my_component",
        setup: (editor) => {
            editor.ui.registry.addButton("add_my_component", {
                text: "Add custom component",
                onAction: (_) => {
                    // Something like this
                    editor.setContent("<MyComponent/>")
                }
            })
        }
    }
</script>

<main>
    <Editor
            scriptSrc="tinymce/tinymce.min.js"
            {conf}
    >
    </Editor>
</main>

This doesn't work, so I was wondering if what I am trying to achieve is even possible.

Thank you very much! Martin

staadecker avatar May 22 '23 05:05 staadecker

Ref: INT-3181

TinyITAdmin avatar May 22 '23 08:05 TinyITAdmin

This issue is stale because it has been open 30 days with no activity. Please comment if you wish to keep this issue open or it will be closed in 7 days.

tiny-stale-bot avatar Jul 09 '24 00:07 tiny-stale-bot

This issue was closed because it has been stalled for 7 days with no activity.

tiny-stale-bot avatar Jul 16 '24 00:07 tiny-stale-bot