Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

I/5802: Handle clipboard properly in restricte editing mode. #13

Merged
merged 23 commits into from
Jan 3, 2020
Merged

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Dec 30, 2019

Suggested merge commit message (convention)

Feature: Allow pasting content into exception areas in restricted editing mode. Closes ckeditor/ckeditor5#5802.


Additional information

  • I've added a configuration for the text attributes that are allowed inside clipboard holder.

@jodator jodator requested a review from Mgsy December 30, 2019 15:43
@jodator
Copy link
Contributor Author

jodator commented Dec 30, 2019

@Mgsy - it's an optimistic approach but should work. Could you check this PR with pasting in Restricted Editing mode?

  • Only configured attributes should be allowed to be pasted (bold, italic, link by default).
  • Paste (cut - also) should only occur when selection is fully inside exception.
  • Copy should not be blocked.
  • Pasting anything other than the text should be stripped down to basic text nodes (or stripped down entirely) - so only text content from tables, no images etc

@Mgsy
Copy link
Member

Mgsy commented Dec 31, 2019

@FilipTokarski, please check Chrome and Safari, I'll take Firefox.

@Mgsy
Copy link
Member

Mgsy commented Dec 31, 2019

Steps to reproduce

  1. Go to http://localhost:8125/ckeditor5-restricted-editing/tests/manual/restrictedediting.html
  2. Enter the restricted editing mode
  3. Copy some link
  4. Paste it to the exception marker

Current result

The plain text is pasted.

Expected result

The link is pasted.

@FilipTokarski
Copy link
Member

FilipTokarski commented Dec 31, 2019

The same in Chrome and Safari. Apart from this, seems to work fine.

@Reinmar
Copy link
Member

Reinmar commented Jan 2, 2020

Do we need the configuration for allowed attributes? Can't we have all text attributes allowed? Then, if I'm correct, it will be enough to add a callback allowing only $text in the $clipboardHolder. You won't need the other callback for attribute names. Schema works on the model so we can be very specific here allowing <$clipboardHolder>$text with all its attributes</$clipboardHolder> and nothing else. No reason for stuff like Array.from( context.getNames() ).includes( '$clipboardHolder' ) – it's enough to check the first item or add the ctx.startsWith() method.

Copy link
Member

@Reinmar Reinmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented.

@jodator
Copy link
Contributor Author

jodator commented Jan 3, 2020

Do we need the configuration for allowed attributes?

In another way, we will get minor WTF if bold is allowed by command and you can bold text inside the non-restricted area but you can't paste it.

But we can also add this configuration later if requested so I can remove this from the PR.

@jodator
Copy link
Contributor Author

jodator commented Jan 3, 2020

@Reinmar: I've added the SchemaContext.startsWith() and fixed link attribute name used in default config.

@jodator jodator requested a review from Reinmar January 3, 2020 11:29
@Reinmar
Copy link
Member

Reinmar commented Jan 3, 2020

Lookin' good 🍬!

@Reinmar Reinmar merged commit 6704d21 into master Jan 3, 2020
@Reinmar Reinmar deleted the i/5802 branch January 3, 2020 13:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable copy & paste in restricted editing mode
4 participants