Skip to content

Specifying script type when using @bassetBlock #157

@jargoud

Description

@jargoud

Hello,

I'm overriding the CKEditor field, following this documentation, where they mention the use of several particular kind of scripts:

<script type="importmap">
    {
        "imports": {
            "ckeditor5": "../../assets/vendor/ckeditor5.js",
            "ckeditor5/": "../../assets/vendor/"
        }
    }
</script>
<script type="module">
    import {
        ClassicEditor,
        Essentials,
        Paragraph,
        Bold,
        Italic,
        Font
    } from 'ckeditor5';

    ClassicEditor
        .create( document.querySelector( '#editor' ), {
            licenseKey: '<YOUR_LICENSE_KEY>', // Or 'GPL'.
            plugins: [ Essentials, Paragraph, Bold, Italic, Font ],
            toolbar: [
                'undo', 'redo', '|', 'bold', 'italic', '|',
                'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor'
            ]
        } )
        .then( editor => {
            window.editor = editor;
        } )
        .catch( error => {
            console.error( error );
        } );
</script>

In addition, I have a script with the bpFieldInitCKEditorElement function:

<script>
    async function bpFieldInitCKEditorElement(element) {
        // …
    }
</script>

If I wrap this portion of code with @bassetBlock directive, it'll remove the type attribute:

@bassetBlock('backpack/pro/fields/ckeditor-import-map.js')
<script type="importmap">
    {
        "imports": {
            "ckeditor5": "{{ asset('vendor/ckeditor5/ckeditor5.js') }}",
            "ckeditor5/": "{{ asset('vendor/ckeditor5/') }}/"
        }
    }
</script>
@endBassetBlock

will result into:

<script src="/back/storage/basset/backpack/pro/fields/ckeditor-import-map-9dc70859.js" ></script>

Is there a way to do this?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions