codex-team / codex-team/editor.js

The best text editor! Good job! But there is a small problem. enableLineBreaks does not remove lines

Open
#2,685 0 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

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)

![image](https://github.com/codex-team/editor.js/assets/167006215/031e67e5-2c23-4998-b115-0149d3114e64)

```

// 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.