-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2492 from zetkin/issue-2394/paste-into-email-editor
Add pasting logic for spans in email editor
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/features/emails/components/EmailEditor/tools/paragraphWithSpanPaste.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
//@ts-ignore | ||
import Paragraph from '@editorjs/paragraph'; | ||
import { BlockTool, HTMLPasteEvent } from '@editorjs/editorjs'; | ||
|
||
//@ts-ignore | ||
export default class ParagraphWithSpanPaste | ||
extends Paragraph | ||
implements BlockTool | ||
{ | ||
onPaste(event: HTMLPasteEvent) { | ||
const text = event.detail.data.textContent; | ||
event.detail.data = document.createElement('div'); | ||
event.detail.data.textContent = text; | ||
return super.onPaste(event); | ||
} | ||
|
||
static get pasteConfig() { | ||
return { | ||
tags: ['P', 'SPAN'], | ||
}; | ||
} | ||
} |