Giter Club home page Giter Club logo

editorjsbundle's People

Contributors

davidgorges avatar mzukiewicz avatar robindev avatar tbmatuka avatar yellowphoenix18 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

editorjsbundle's Issues

Support Symfony 6

Hello,

Are you planning upgrade this bundle to support Symfony 6?

Problem 1 - Root composer.json requires tbmatuka/editorjs-bundle ^0.1.5 -> satisfiable by tbmatuka/editorjs-bundle[v0.1.5]. - tbmatuka/editorjs-bundle v0.1.5 requires symfony/config ^4.0|^5.0 -> found symfony/config[v4.0.0, ..., v4.4.37, v5.0.0, ..., v5.4.3] but the package is fixed to v6.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Update composer.json to work with Symfony 5.

I've tested this bundle with Symfony 5 and it is working fine with:

symfony/config v5.1.3
symfony/dependency-injection v5.1.3
symfony/form v5.1.3
symfony/framework-bundle v5.1.3
symfony/http-foundation v5.1.3
symfony/http-kernel v5.1.3
symfony/options-resolver v5.1.3
symfony/property-access v5.1.3
symfony/routing v5.1.3
symfony/twig-bundle v5.1.3

Thanks!

Stimulus / Symfony UX compatibility

Hi @tbmatuka

the project I am currently working on uses Stimulus / Turbo (part of symfony/ux).
I added a stimulus controller and some glue code to make it work, but it requires a slightly different setup (different form theme, editorJS initialisation would be inside the stimulus controller).

I can work on a PR that adds Symfony UX compatibility if you are willing to have it in your bundle.

require php ^7.2 -> your php version (8.2.18)

  • tbmatuka/editorjs-bundle[v0.1.0, ..., v0.1.3] require php ^7.2 -> your php version (8.2.18) does not satisfy that requirement.
    please just remove "php": ">=7.2",
    I think it will work on php 8

I don't see the form. (Encore/webpack)

Hello, how to integrate this bundle with Symfony 5 and Encore/webpack?
I'm building a js with Encore but I don't see the form.

Form

            ->add(
                'content',
                EditorjsType::class,
                [
                    'label' => 'generic.content',
                ]
            )

webpack.config.js
.addEntry('editorjs', './assets/js/editorjs-init.js')

editorjs-init.js

import EditorJS from '@editorjs/editorjs';
import Header from '@editorjs/header';
import List from '@editorjs/list';

let editorjsToolsScoped = [];
if (typeof editorjsTools !== 'undefined') {
    // eslint-disable-next-line no-undef
    editorjsToolsScoped = editorjsTools;
}

editorjsToolsScoped.Header = Header;
editorjsToolsScoped.List = List;

let editorjsConfigsScoped = [];
if (typeof editorjsConfigs !== 'undefined') {
    // eslint-disable-next-line no-undef
    editorjsConfigsScoped = editorjsConfigs;
}

const editors = [];

async function editorjsSave(holderId) {
    const editorHolder = document.getElementById(holderId);
    const editorInput = document.getElementById(editorHolder.getAttribute('data-input-id'));
    const editor = editors[holderId];

    const savePromise = editor.save().then((outputData) => {
        editorInput.value = JSON.stringify(outputData);
    });

    await savePromise;
}

if (typeof editorjsConfigsScoped !== 'undefined') {
    editorjsConfigsScoped.forEach((config) => {
        if (typeof config.tools !== 'undefined') {
            // set tool classes
            Object.keys(config.tools).forEach((toolName) => {
                // eslint-disable-next-line no-param-reassign
                config.tools[toolName].class = editorjsToolsScoped[config.tools[toolName].className];
            });
        }

        // eslint-disable-next-line no-param-reassign,func-names
        config.onChange = async function () {
            await editorjsSave(this.holder);
        };

        const editorHolder = document.getElementById(config.holder);
        const editorForm = editorHolder.closest('form');

        if (!editorForm.hasEditorjsListener) {
            editorForm.addEventListener('submit', (event) => {
                event.preventDefault();

                const form = event.target;
                form.hasEditorjsListener = true;

                // save all editors in form
                const editorHolders = form.querySelectorAll('.editorjs-holder');
                const savePromises = [];
                editorHolders.forEach((holder) => {
                    savePromises.push(editorjsSave(holder.id));
                });

                Promise.all(savePromises).then(() => {
                    form.submit();
                });
            });
        }

        editors[config.holder] = new EditorJS(config);
    });
}

Web page form HTML

<div class="form-group"><label for="create_article_content" class="required">Content</label>      <input type="hidden" data-editorjs="editorjs_create_article_content" id="create_article_content" name="create_article[content]" required="required" value="[]" data-np-checked="1">
  <div id="editorjs_create_article_content" data-input-id="create_article_content" class="editorjs-holder editorjs-config-default"></div>

  <script>
    if (typeof editorjsConfigs === 'undefined') {
      var editorjsConfigs = [];
    }

    editorjsConfigs.push({"name":"default","initialBlock":"paragraph","placeholder":"Editor","tools":{"header":{"name":"header","className":"Header","config":{"something":true}}},"logLevel":"ERROR","holder":"editorjs_create_article_content"});
  </script>
</div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.