plotly / plotly/dash

Copy only text data in DataTable cell

Open
#2,231 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

[Feature Request] Copy only text data in DataTable cell

Current

  • html tag of table to be copied
<td
  tabindex="-1"
  class="dash-cell column-13 cell--selected focused"
  data-dash-column="some column"
  data-dash-row="0"
>
  <div class="input-active unfocused dash-cell-value cell-markdown">
    <div class="center">
      0
    </div>
  </div>
</td>
  • Copied Results
<div class='center'>0</div>

Solution

Add parameter such as copyOnlyText that only text data are copied.
Or, it would be good to apply it when the presentation of the cell is markdown.

TableClipboardHelper.ts#L21

When calling the toClipboard function, it would be good to get an argument and remove the html tag using the regex.

  • To use a DataTable with an copyOnlyText argument
DataTable(
  df.to_dict('records'),
  [{"name": i, "id": i, presentation="markdown"} for i in df.columns],
  id='tbl',
  copyOnlyText=True,
)

If the html like the above behavior is rendered, if the copyOnlyText argument is passed, it seems that only 0 should be copied.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with components/dash-table/src/dash-table/utils/TableClipboardHelper.ts, especially the toClipboard call referenced in the issue, and trace how DataTable properties reach clipboard handling. Confirm the desired behavior for markdown cells and whether the option is exposed through the Python DataTable API. Done means copying a cell produces only its text rather than rendered HTML when the option is enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
data-visualization, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.