-
Notifications
You must be signed in to change notification settings - Fork 882
Rich text copy/cut/paste #237
base: master
Are you sure you want to change the base?
Conversation
Thanks for this! I'll take a look and review it when I get a chance. Unfortunately I'm pretty busy with other projects at the moment, so there may be a bit of a delay. |
CodeMirror 5.12 now supports copy & cut events which makes the firepad code simpler. I have updated the PR accordingly and also enhanced some styles support. New plnkr in http://plnkr.co/edit/fMroiV79FvkCJF590dpj Obviously you need CodeMirror 5.12 |
Please hold on with merging this. There may be a better way, see https://discuss.codemirror.net/t/clipboarddata-setdata/695 |
I have updated the PR again with much better results for mac OSX and better style handling on paste. I think I will leave this for now unless any issues are found. I hope this can be merged soon. Updated http://plnkr.co/edit/PgMKReE64a8Nc4HiTx4I?p=preview Rember this PR requires Codemirror > 5.13 |
@kofifus - we have a fork of firepad for some customizations we are making to it for our learning/therapy application. this copy/paste functionality is something we'd love to have. if you are open to it, I'd love to pull this branch into our fork and I can do some experimentation and further code review. https://github.com/presencelearning/firepad |
yeah sure do I need to do anything ? |
@@ -90,7 +90,6 @@ firepad.Firepad = (function(global) { | |||
} | |||
this.client_ = new EditorClient(this.firebaseAdapter_, this.editorAdapter_); | |||
|
|||
var self = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleting this definition of 'self' breaks a lot of things later on
@kofifus - this is not working for me. After I fixed the missing 'self' definition, I now run into an issue where onCodeMirrorPaste_ quits early because it gets no 'html'. The clipboardData in the event it receives has an empty 'types' array. So then I went to look at what happens in onCodeMirrorCopyCut_. If I log the final e.clipboardData, it monetarily has a 'types' array of length 1, but it becomes length 0 shortly after the call exits, so something is wiping it out. (Using Chrome 50 on OS X.) |
apologies the removed 'self' crept in from another PR I'm working on, fixed. The other problem you specify may be a mac OS problem, can you check with http://plnkr.co/edit/PgMKReE64a8Nc4HiTx4I?p=preview and see how it goes there and let me know pls ? |
The Plunker demo works in Firefox (45) but fails in Chrome (50). I'm on OS X 10.10.5. |
ok, this may be related to https://bugs.chromium.org/p/chromium/issues/detail?id=552975 I should have access to a mac in the next few days and will have a look thx |
jbrecht, I am checking on MacBook Pro / OS X Yosemite 10.10.1 / Chrome version 50.0.2661.86 (64-bit) using the plunkr. Everything seems to work ok, that is copy/paste of text with rich text attributes (bold etc) works properly. Can you test again ? what exact computer / OSX version / Chrome version you're using ? |
further commits to fix a problem in parseHtml that resulted in buggy behavior when pasting a line with leading spaces new plunkr: http://plnkr.co/edit/MqAdtT1eNCdyheWaKnGO?p=preview |
This works for me, although a unit test is currently failing |
Thx John, the unit auto build system has issues with npm package versioning etc .. if you feel like helping that will be great:) PS there still seems to be issues with rich text copy/paste in mac Chrome which I'm looking into |
Updated the code to correctly remove sentinels when doing plain text copy/cut No further known issues at this stage :) |
I also interested in this pull request, I squashed it and merged into my version (1 year old, needed to be updated), after solving few minor conflicts it's working fine. But it's not working in Edge due to lack of 'text/html' support for Clipboard API. When I replaced it with 'text' in setData/getData it started working in Edge and continued working in Chrome. I haven't tested it extensively yet so not sure if that can be kept, but maybe it can detect if after using setData clipboard contains something, and if not, then re-try with 'text' instead of 'text/html'? |
thx ... interesting in https://html.spec.whatwg.org/multipage/interaction.html#dom-datatransfer-getdata I find: 'If format equals "text", change it to "text/plain".' Do you find that you still get rich text copy/paste (ie bold/italics/etc) with that change ? I find that strange .. |
Yes, I think it's working because you only using Clipboard API for storing text, not actually for copy/pasting it (I'm new to it and haven't read docs yet, so not sure if there other ways to working with it and what clipboard contains when you copy html) |
ha you're right, this will work within firepad, but it will not paste rich text outside (for example into a gmail msg), or the other way around .. can you check ? |
Yes, you're right, that's the difference! It's pasting raw html ('<span ...') in case of 'text' and decorated text in case of 'text/html', so seems not the best option to use that by default. |
another win for microsoft ... still you can test for edge and use 'text' in that case which will give you rich copy text inside firepad which is much better than nothing |
…nd added changes for copy/cut/paste buttons using same functionality
Michael, I'm about to update this with a few more changes and want to use the new FireBase version. As this PR seems to be important and needs a lot of testing this will be very helpful. Thx! |
Since we don't need authentication / security rules, you should actually be able to just use https://firepad.firebaseio-demo.com as the databaseURL and set the other fields to dummy values (empty string or whatever). |
I committed further updates to the code - I removed the surrounding span around the copied clip that had 'default' styles like font family/size/etc. This span caused issues when pasting into rich text editors (ie openoffice) and is not essential. FireFox for example does not add such default attributes into a copy clip (chrome does). This made the code much cleaner and works better when pasting outside FP. The original FP code serializeHTML replaced all leading trailing and consecutive spaces with nbsp .. this had a negative effect of creating hard spaces when pasting into for example open office. I now removed that code and instead serializeHTML adds Also the copy clip will now be saved in the clipboard in both html and text formats. This allows copying rich text from FP and pasting into non rich text editors or rich text editors that cannot read html clips from the clipboard (ie wordpad). Plunkr: plunkr |
Awesome. Those sound like good improvements. :-) On Thu, Jun 23, 2016 at 4:45 PM, Kofifus [email protected] wrote:
|
Thanks for the work @kofifus! I'm not able to get any of the plunkr to work, copying from the editor and pasting into gmail/slack. Using Google Chrome (Version 90.0.4430.212 (Official Build) (64-bit) (Ubuntu/Linux)) Is there any update on this PR? This feature would be highly valuable to my team! |
well it's been 5 years and TBH I totally gave up in firepad as it's not really supported .. you can find projects binding the amazing ProseMirror to FireBase .. sorry can't help |
@kofifus I am sorry this PR was not given the attention it deserved when you originally filed it. If anyone wants to try and revive this PR I would be happy to review it. We've tried to clarify the state of this project in the README since then: https://github.com/FirebaseExtended/firepad#status Basically we (Firebase) are not actively working on this project however we're happy to accept Pull Requests and release new updates when required. There are many people who depend on Firepad and we believe it to be a mostly healthy library as-is. |
This comment has been minimized.
This comment has been minimized.
Ah whoops! I meant this link: https://github.com/FirebaseExtended/firepad#status |
Demo:
plunker
Notes: