html2canvas icon indicating copy to clipboard operation
html2canvas copied to clipboard

textarea cannot rendered correctly.

Open zhoujun494 opened this issue 5 years ago • 50 comments

Hi, I was faced that textarea cannot break line with capturing hopes give some help thanks!

Specifications:

  • html2canvas version tested with:1.0.0-rc.3
  • Browser & version:latest version
  • Operating system:win 10

zhoujun494 avatar Sep 17 '19 10:09 zhoujun494

Do you have an example?

niklasvh avatar Sep 26 '19 05:09 niklasvh

Do you have an example?

Just an ordinary textarea that goes wrong.You Can try it. image

Amber-372 avatar Sep 26 '19 09:09 Amber-372

MacOS 10.14

[email protected]

same behaviour as @HelenGiser's.

layik avatar Oct 01 '19 21:10 layik

+1

662 avatar Oct 23 '19 11:10 662

I was able to reproduce this here https://jsfiddle.net/a8st153g/

Text that would wrap is placed all on one line and becomes cut off Using @HelenGiser example with line breaks, it places text all on the same line (as in the screenshot)

CodaxD avatar Nov 14 '19 19:11 CodaxD

same problem.

byk04712 avatar Nov 15 '19 02:11 byk04712

Same problem

lucasvocos avatar Nov 21 '19 18:11 lucasvocos

same problem in rc5

RyoheiTomiyama avatar Dec 02 '19 15:12 RyoheiTomiyama

I have the same problem with rc5: The text is shown in one single line in the vertical middle of the text field.

mtreitinger avatar Dec 11 '19 15:12 mtreitinger

Same problem with rc5: The text is shown in one single line in the vertical middle of the text field.

toucail avatar Dec 17 '19 19:12 toucail

See pull request #2132

nidi3 avatar Feb 17 '20 22:02 nidi3

As long as this is not merged, a fixed version is available on npm as "@nidi/html2canvas": "1.0.0-rc.8"

nidi3 avatar Mar 19 '20 01:03 nidi3

As long as this is not merged, a fixed version is available on npm as "@nidi/html2canvas": "1.0.0-rc.8"

it works. thank you

pliao1996 avatar Mar 25 '20 07:03 pliao1996

Hello I have the same issue and I'd like to use this rc8 version in a pure js project asap. How can I make it? Thank you for your help

marcanw avatar Apr 06 '20 23:04 marcanw

As long as this is not merged, a fixed version is available on npm as "@nidi/html2canvas": "1.0.0-rc.8"

When textarea element show muti lines, it will lost '\n', like:


AAAAAA\n BBBB

finally, it shows:


AAAAAAB BBB

wsj195328 avatar May 07 '20 10:05 wsj195328

Please let me know how I can get rc8 version? I don't understand where to get - a fixed version is available on npm as "@nidi/html2canvas". I am working on an educational site that students are actually using for remote learning right now and I really need to get textarea working. Thanks for any help!

sstudebaker avatar May 08 '20 14:05 sstudebaker

add "@nidi/html2canvas": "1.0.0-rc.8" to the dependencies in package.json.

nidi3 avatar May 08 '20 17:05 nidi3

I was able to find html2canvas 1.0.0-rc.7 at https://www.npmjs.com/package/@nidi/html2canvas but not rc.8... Am I missing something?

sstudebaker avatar May 08 '20 18:05 sstudebaker

Hey @niklasvh , Any idea of merging #2132 request I see this is major PR for this repo as the existing functionality is broken somewhere and this patch is important for libraries which is dependent on this changes

Or please provide ETA for this changes to be released

thanks

J1445 avatar May 09 '20 12:05 J1445

I tried the rc.7 version today and was unable to save the file. Not sure why. Just got spinning wheel that never completed.

sstudebaker avatar May 11 '20 15:05 sstudebaker

I see rc.8 on npmjs.com and I'm using it in my project, so it really is there :) For the latest question: What exactly are you trying to do?

nidi3 avatar May 12 '20 16:05 nidi3

I searched npmjs.com for "@nidi/html2canvas": "1.0.0-rc.8" but it tells me 0 packages found so I guess I don't know how to find it...

sstudebaker avatar May 12 '20 16:05 sstudebaker

@wsj195328 here's an example with newlines: http://jsfiddle.net/3knhoL1a/

nidi3 avatar May 12 '20 16:05 nidi3

@sstudebaker just search for @nidi/html2canvas on npmjs.com or add "@nidi/html2canvas": "1.0.0-rc.8" to package.json.

nidi3 avatar May 12 '20 16:05 nidi3

Here is my confusion - when I open the js file it says html2canvas 1.0.0-rc.7. so I guess I have the right one but it is not working for my script.

Save function is on this page: https://piclits.com/piclit/79/

If you create a piclit in freestyle mode and then save under Options (you would need to register) but newlines are not captured. I tried the newer js and it would not save - just kept spinning.

// ON SAVE CREATE IMAGE AND SAVE WORDS $('.save').on(selectEvents, function() { var button = $(this); button.addClass('active');

        if (button.hasClass('active')) {
            disableFridge.addClass('active');
            focus_on_word_edit();
            html2canvas(document.querySelector(".fridge"), {
                onclone: function(document) {
                    document.querySelector(".fridge").style.borderRadius = "0px";
                }
            }).then(canvas => {
                var img = canvas.toDataURL('image/jpeg', 0.6);

                if ( piclitType === '2' ) {
                    var piclitWords = freestyleTextarea.val();
                } else if ( piclitType === '1' ) {
                    var piclitWords = [];
                    var wordCount = $('.fridge-word').length;
                    $('.fridge-word').each(function(){
                        var word = $(this);
                        var variants = [];
                        if ( word.find('.word-variants .variant-selector').length ) {
                            word.find('.word-variants .variant-selector').each(function() {
                                variants.push(
                                    $(this).find('span').text()
                                );
                            });
                        }
                        piclitWords.push({
                            current: word.find('.word-variants .variant-selector:first').find('span').text(),
                            part_of_speech: word.attr('data-partofspeech'),
                            variants: variants,
                            current_variant: word.attr('data-variant'),
                            capitalize: word.attr('data-capitalize'),
                            top: word.css('top'),
                            left: word.css('left')
                        });
                    });
                }

                var data = {
                    'action': 'save_piclit',
                    'img': img,
                    'post_type': ajax_object.post_type,
                    'post_id': ajax_object.post_id,
                    'piclit_type': piclitType,
                    'piclit_words': piclitWords,
                    'piclit_status': piclitStatus,
                    'piclit_id': piclitId
                };
                //console.log(data);
                $.post(ajax_object.ajax_url, data, function(response) {
                    window.location.href = response.data;
                    /*button.removeClass('active');
                    unfocus_edit_done();
                    disableFridge.removeClass('active');*/
                });
            });
        }
    });

piclit in edit mode using freestyle saved piclit

The two attached files show the piclit in edit mode and then when saved.

sstudebaker avatar May 12 '20 16:05 sstudebaker

You are right about the version. I published a new one 1.0.0-rc.11 which should work.

nidi3 avatar May 14 '20 20:05 nidi3

Happy to report that it worked! THANK YOU! On Firefox, Safari and Chrome all latest versions. I am getting a shadow where I believe the text area ends? Maybe I just need to set height and width of the area. Screen Shot 2020-05-15 at 8 04 38 AM

sstudebaker avatar May 15 '20 14:05 sstudebaker

As long as this is not merged, a fixed version is available on npm as "@nidi/html2canvas": "1.0.0-rc.8"

when will this version merge to niklasvh/html2canvas?

lifront avatar Aug 19 '20 01:08 lifront

@nidi3 Thanks for your support ! I have problem with string not space in Japanese like this image. In color textarea, when input, content auto break line, but on render, it show wrong. I also install version : @nidi/html2canvas@^1.0.0-rc.13 but it still error. Screen Shot 2020-10-05 at 08 44 53

ryantranvn avatar Oct 05 '20 01:10 ryantranvn

replace textarea to container contenteditable!!!

mamtou avatar Oct 14 '20 09:10 mamtou