Skip to content

Commit

Permalink
feat: 在Markdown编辑器中为表格单元格添加编辑状态边框,禁用拖拽功能以提升用户体验
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Feb 18, 2025
1 parent c5960e2 commit 0e618c7
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/MarkdownEditor/editor/elements/Table/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const TableTdCell = (
backgroundColor: editing ? 'transparent' : undefined,
textAlign: justifyContent as 'left',
minWidth: minWidth,
border: editing ? '2px solid #42a642' : undefined,
maxWidth: '200px',
width: props.width,
}}
Expand Down
4 changes: 3 additions & 1 deletion tests/demo/__snapshots__/src/MarkdownEditor/demos/bug.snap
Original file line number Diff line number Diff line change
Expand Up @@ -201437,11 +201437,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -201546,6 +201547,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -516,6 +517,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -9009,11 +9011,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -9214,6 +9217,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
8 changes: 6 additions & 2 deletions tests/demo/__snapshots__/src/MarkdownEditor/demos/min.snap
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -548,6 +549,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -5977,11 +5979,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -6194,6 +6197,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -584,6 +585,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -3995,10 +3997,11 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -4295,6 +4298,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
8 changes: 6 additions & 2 deletions tests/demo/__snapshots__/src/MarkdownEditor/demos/ppt.snap
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -1248,6 +1249,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -11553,11 +11555,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -11770,6 +11773,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,11 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -1128,6 +1129,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -6382,10 +6384,11 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -6598,6 +6601,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
8 changes: 6 additions & 2 deletions tests/demo/__snapshots__/src/MarkdownEditor/demos/pure.snap
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -1029,6 +1030,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -6266,11 +6268,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -6483,6 +6486,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5669,11 +5669,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -5946,6 +5947,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
8 changes: 6 additions & 2 deletions tests/demo/__snapshots__/src/MarkdownEditor/demos/render.snap
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -544,6 +545,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -4433,10 +4435,11 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -4517,6 +4520,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -433,6 +434,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down Expand Up @@ -8416,11 +8418,12 @@
class="ant-md-editor-content-table-container"
data-be="table"
data-slate-node="element"
draggable="false"
style="overflow: hidden;"
tabindex="0"
>
<div
style="position: absolute; z-index: 999; outline: 3px solid #42a642; pointer-events: none; display: none; left: 0px; top: 0px;"
style="position: absolute; z-index: 999; outline: 3px solid transparent; pointer-events: none; display: none; left: 0px; top: 0px;"
/>
<div
class="ant-md-editor-drag-el"
Expand Down Expand Up @@ -8621,6 +8624,7 @@
</div>
<table
class="ant-md-editor-content-table-editor-table"
draggable="false"
>
<tbody
data-slate-node="element"
Expand Down
Loading

1 comment on commit 0e618c7

@vercel
Copy link

@vercel vercel bot commented on 0e618c7 Feb 18, 2025

Choose a reason for hiding this comment

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

Please sign in to comment.