editor.js
editor.js copied to clipboard
The best text editor! Good job! But there is a small problem. enableLineBreaks does not remove lines
When enableLineBreaks is true in a text block, it adds a new line when you press enter, and this is correct behavior. But when I try to delete these lines using backspace, they are not deleted, and the cursor simply moves up (without deleting the line)
// Quote block code
export class Quote {
constructor({data, api, config, readOnly}) {
this.data = data
this.api = api
this.config = config
this.readOnly = readOnly
}
static get enableLineBreaks() {
return true;
}
static get isReadOnlySupported() {
return true;
}
static get toolbox() {
return {
title: 'Quote',
icon: '',
};
}
render() {
this.wrapper = document.createElement('div')
this.quote = document.createElement('div')
if (!this.readOnly) {
this.quote.contentEditable = true
}
this.quote.classList.add('quote')
this.quote.placeholder = '...'
this.quote.innerHTML = (this.data && this.data.quoteText) ? this.data.quoteText : ''
this.wrapper.appendChild(this.quote)
return this.wrapper
}
static get sanitize() {
return {
quoteText: true,
};
}
validate(data) {
if (!data.quoteText) {
return false
}
return true
}
save(blockContent) {
const quote = blockContent.querySelector('.quote')
return {
quoteText: quote.innerHTML,
}
}
}
export const quote = Quote
I will be very grateful for your help