wymeditor: Adds paste listener to strip superfluous code #345
No reviewers
Labels
No labels
Component: User interface
Component: Wymeditor
Help wanted
Level: Difficult
Level: Easy
Level: Moderate
Pagetype: Festival
Pagetype: Mailinglist
Pagetype: Peer reviewed article
Pagetype: Text
Privacy GDPR AVG
status: has conflicts
Status: Needs changes
Status: Needs discussion
Status: Needs review
Status: Ready to merge
Status: Waiting for response
Type: Bug
Type: Enhancement
Type: Question
Usecase: De Stadsbron
Usecase: Koppelting
Usecase: MeetjeStad
Value: Coders
Value: Security
Value: Users
Value: Visitors
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
harmen/hypha!345
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "hypha-66"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #66
Based on the #314 by @RoukePouw and processed comments by @matthijskooijman
In #66, I wrote:
I don't think this is addressed in this PR, right? But I think it should be somehow adressed?
Good point! I've raised question as well and talked to @giplt about this. His reaction, and I agree, is that is more preferable to implement this feature now, with the downside that all pastes are stripped and later fix it so that it only targets Word-like code.
A "copy" event handler exists: https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event which can probably manually retrieve the selected content, customize it to mark it as "from inside hypha" so that the paste event handler can recognize it and skip the format-stripping.
One way I thought we could mark the data as being "from inside hypha" could be to tweak the "format" on the clipboard. The clipboard typically contains multiple versions (e.g. "text/plain" and "text/html"), and I hoped we could just add an "application/hypha-html" or something in addition to the default types, with identical content to the "text/html" version. However, reading the spec, I think that the formats that can be written from "untrusted" scripts is limited: https://w3c.github.io/clipboard-apis/#writing-to-clipboard.
So I guess adding some wrapper or marker inside the "text/html" version should be done instead. This marker should ideally be invisible and unobtrusive, for the case that this HTML is pasted elsewhere.
We should probably also try to generate a "text/plain" version, to allow copy-pasting from Wymeditor into a plain textarea or so.
Rebased and updated the commit message, merging next.
I created #348 for some followup improvements.