tbmatuka / editorjsbundle Goto Github PK
View Code? Open in Web Editor NEWSymfony bundle for Editor.js
License: MIT License
Symfony bundle for Editor.js
License: MIT License
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.
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!
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.
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>
Hi, @tbmatuka
The new version has a "Block tunes connection" setting.
I want create a PR that adds compatibility in your bundle.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.