editor-js / raw Goto Github PK
View Code? Open in Web Editor NEWRaw HTML tool for Editor.js
License: MIT License
Raw HTML tool for Editor.js
License: MIT License
This feature will be useful because it allows leaving a description of the inserted HTML fragments.
There's a weird bug on Firefox (v81) where movement keys jump to next/previous block and not next/previous character. This happens only if you dynamically load content to Editorjs and one of the blocks is a raw block.
Steps to reproduce:
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/raw@latest"></script>
<div id="editorjs"></div>
<script>
const editor = new EditorJS({
tools: {
raw: RawTool
},
data: {
blocks : [
{
type : "paragraph",
data : {
text : "Lorem ipsum"
}
},
{
type : "raw",
data : {
html : "Whatevs"
}
}
]
}
})
</script>
Whatevs
text with latest Firefox and press arrow left on keyboard. The cursor moves to previous block instead of moving to between letters v and s.If I create a new Editorjs without prepopulating data and recreate those fields, this does not happen and moving the cursor using arrow keys in raw textarea works as it should.
This bug is more than mere annoyance, because it happens also when using backspace to delete characters. The cursor jumps to previous block and consecutive key presses remove characters from there instead of the ones the user intended to remove.
I'm not sure if this is a bug in Editorjs or this plugin, but you can prevent this behaviour by adding the following to this plugin's drawView()
function:
textarea.addEventListener('keydown', function (event) {
const blockKeys = ['ArrowRight', 'ArrowLeft', 'Backspace'];
if (blockKeys.includes(event.key)) {
event.stopPropagation();
}
});
But this might have some unwanted side effects. There are some open bugs in Bugzilla related to Firefox's textarea that do not exist on other browsers, so the easier route might be using <div contenteditable="true">
instead of <textarea>
, like in paragraph plugin.
After page load, initial edits in the textarea do not trigger the EditorJS onChange
listener unless other blocks are modified first.
The Code
plugin does include it, could you include it in this package too?
Thank you.
raw plugin version: 2.1.1
(lastest)
editor.js version: 2.17.0
(lastest)
The raw plugin is not returning the HTML tags in the returned code after calling the save()
function of the editor. For example, the following code:
<b>CODE<b>
returns
{
"time" : 1584382663969,
"blocks" : [
{
"type" : "raw",
"data" : {
"html" : "CODE"
}
}
],
"version" : "2.17.0"
}
This issue maybe related to the editor's sanitizer.
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.