Paste mutil-lines to a cell in selection mode

Tags: #<Tag:0x00007efc64d3f7e0> #<Tag:0x00007efc64d3f4c0>

The current situation is that, when I am selecting a specific cell ( not edit mode yet ) , ex: A1 and paste a three-line text ( copied from some where else), say:
“Foo
Bar
Cuzz”
Then each line will spread respectively to cells in next row. That means:
A1: “Foo”
A2:“Bar”
A3:“Cuzz”
but what I expected:
A1:“Foo
Bar
Cuzz”.

How can I achieve that in selection mode. ( In edit mode, it work well ). Thank you

Hi @hungtv

This behavior is the same one as we have, for example, in Excel. If you would like to change the outcome you would need to apply some custom logic.

You may try to
*open cell editor before the paste so the whole data goes to one cell or,

  • use beforeChange hook to alter the destination of data to pint only that one single cell
1 Like

Thank you very much your supportive. beforePaste seem to work for me.

      beforePaste: (change: string[][]) => {
        const tmp = [change.map((item: string[]) => item[0]).join("\n")];

        change.splice(0, change.length, tmp);
        return true;
      },
1 Like

Great! I will close this thread as solved.

Please feel free to open a new one when needed.