basecamp / basecamp/trix

Paste all elements as plain unformatted text?

Open
#958 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
20k
Forks
1.1k
Avg merge
3d 12h
Merged PRs (30d)
13

Description

I am trying to convert everything that user pastes to sanitized plain text instead of having formatted elements. Based on Trix documentation I am using this code to convert pasted elements to string.

```
const element = document.querySelector("trix-editor")
element.addEventListener("trix-paste", function(e) {
element.editor.getDocument().toString()
console.log(element.editor.getDocument().toString())
})

```
In console, it shows correct plain text, but in the editor, all the elements are still formatted.

Is there a way I can convert everything in the editor to this sanitized text?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Trix documentation and the trix-paste event on the trix-editor element. Inspect how element.editor.getDocument().toString() relates to the editor's pasted content, then verify the behavior by pasting formatted elements. Done means pasted content appears as sanitized plain text in the editor rather than retaining formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.