-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat]: Extended Tables Support (#2596)
* migrated table to new project structure * fixed range errors while deleting table nodes with no nodes below and removed console logs * fixed css for rendering table menu * removed old table menu * added support for read only editors as well * text-black removed * added design colors --------- Co-authored-by: sriram veeraghanta <[email protected]>
- Loading branch information
1 parent
f033575
commit 14ac885
Showing
34 changed files
with
1,970 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
packages/editor/core/src/ui/extensions/table/table-cell.ts
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/editor/core/src/ui/extensions/table/table-cell/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as default } from "./table-cell" |
58 changes: 58 additions & 0 deletions
58
packages/editor/core/src/ui/extensions/table/table-cell/table-cell.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { mergeAttributes, Node } from "@tiptap/core" | ||
|
||
export interface TableCellOptions { | ||
HTMLAttributes: Record<string, any> | ||
} | ||
|
||
export default Node.create<TableCellOptions>({ | ||
name: "tableCell", | ||
|
||
addOptions() { | ||
return { | ||
HTMLAttributes: {} | ||
} | ||
}, | ||
|
||
content: "paragraph+", | ||
|
||
addAttributes() { | ||
return { | ||
colspan: { | ||
default: 1 | ||
}, | ||
rowspan: { | ||
default: 1 | ||
}, | ||
colwidth: { | ||
default: null, | ||
parseHTML: (element) => { | ||
const colwidth = element.getAttribute("colwidth") | ||
const value = colwidth ? [parseInt(colwidth, 10)] : null | ||
|
||
return value | ||
} | ||
}, | ||
background: { | ||
default: "none" | ||
} | ||
} | ||
}, | ||
|
||
tableRole: "cell", | ||
|
||
isolating: true, | ||
|
||
parseHTML() { | ||
return [{ tag: "td" }] | ||
}, | ||
|
||
renderHTML({ node, HTMLAttributes }) { | ||
return [ | ||
"td", | ||
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { | ||
style: `background-color: ${node.attrs.background}` | ||
}), | ||
0 | ||
] | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/editor/core/src/ui/extensions/table/table-header/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as default } from "./table-header" |
57 changes: 57 additions & 0 deletions
57
packages/editor/core/src/ui/extensions/table/table-header/table-header.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { mergeAttributes, Node } from "@tiptap/core" | ||
|
||
export interface TableHeaderOptions { | ||
HTMLAttributes: Record<string, any> | ||
} | ||
export default Node.create<TableHeaderOptions>({ | ||
name: "tableHeader", | ||
|
||
addOptions() { | ||
return { | ||
HTMLAttributes: {} | ||
} | ||
}, | ||
|
||
content: "paragraph+", | ||
|
||
addAttributes() { | ||
return { | ||
colspan: { | ||
default: 1 | ||
}, | ||
rowspan: { | ||
default: 1 | ||
}, | ||
colwidth: { | ||
default: null, | ||
parseHTML: (element) => { | ||
const colwidth = element.getAttribute("colwidth") | ||
const value = colwidth ? [parseInt(colwidth, 10)] : null | ||
|
||
return value | ||
} | ||
}, | ||
background: { | ||
default: "rgb(var(--color-primary-100))" | ||
} | ||
} | ||
}, | ||
|
||
tableRole: "header_cell", | ||
|
||
isolating: true, | ||
|
||
parseHTML() { | ||
return [{ tag: "th" }] | ||
}, | ||
|
||
renderHTML({ node, HTMLAttributes }) { | ||
return [ | ||
"th", | ||
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { | ||
style: `background-color: ${node.attrs.background}` | ||
}), | ||
0 | ||
] | ||
} | ||
}) |
1 change: 1 addition & 0 deletions
1
packages/editor/core/src/ui/extensions/table/table-row/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as default } from "./table-row" |
31 changes: 31 additions & 0 deletions
31
packages/editor/core/src/ui/extensions/table/table-row/table-row.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { mergeAttributes, Node } from "@tiptap/core" | ||
|
||
export interface TableRowOptions { | ||
HTMLAttributes: Record<string, any> | ||
} | ||
|
||
export default Node.create<TableRowOptions>({ | ||
name: "tableRow", | ||
|
||
addOptions() { | ||
return { | ||
HTMLAttributes: {} | ||
} | ||
}, | ||
|
||
content: "(tableCell | tableHeader)*", | ||
|
||
tableRole: "row", | ||
|
||
parseHTML() { | ||
return [{ tag: "tr" }] | ||
}, | ||
|
||
renderHTML({ HTMLAttributes }) { | ||
return [ | ||
"tr", | ||
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), | ||
0 | ||
] | ||
} | ||
}) |
55 changes: 55 additions & 0 deletions
55
packages/editor/core/src/ui/extensions/table/table/icons.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const icons = { | ||
colorPicker: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" style="transform: ;msFilter:;"><path fill="rgb(var(--color-text-300))" d="M20 14c-.092.064-2 2.083-2 3.5 0 1.494.949 2.448 2 2.5.906.044 2-.891 2-2.5 0-1.5-1.908-3.436-2-3.5zM9.586 20c.378.378.88.586 1.414.586s1.036-.208 1.414-.586l7-7-.707-.707L11 4.586 8.707 2.293 7.293 3.707 9.586 6 4 11.586c-.378.378-.586.88-.586 1.414s.208 1.036.586 1.414L9.586 20zM11 7.414 16.586 13H5.414L11 7.414z"></path></svg>`, | ||
deleteColumn: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="#e53e3e" d="M0 0H24V24H0z"/><path d="M12 3c.552 0 1 .448 1 1v8c.835-.628 1.874-1 3-1 2.761 0 5 2.239 5 5s-2.239 5-5 5c-1.032 0-1.99-.313-2.787-.848L13 20c0 .552-.448 1-1 1H6c-.552 0-1-.448-1-1V4c0-.552.448-1 1-1h6zm-1 2H7v14h4V5zm8 10h-6v2h6v-2z"/></svg>`, | ||
deleteRow: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="#e53e3e" d="M0 0H24V24H0z"/><path d="M20 5c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1 .628.835 1 1.874 1 3 0 2.761-2.239 5-5 5s-5-2.239-5-5c0-1.126.372-2.165 1-3H4c-.552 0-1-.448-1-1V6c0-.552.448-1 1-1h16zm-7 10v2h6v-2h-6zm6-8H5v4h14V7z"/></svg>`, | ||
insertLeftTableIcon: `<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={24} | ||
height={24} | ||
viewBox="0 -960 960 960" | ||
> | ||
<path | ||
d="M224.617-140.001q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21H360q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H224.617Zm375.383 0q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21h135.383q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H600Zm147.691-607.69q0-4.616-3.846-8.463-3.846-3.846-8.462-3.846H600q-4.616 0-8.462 3.846-3.847 3.847-3.847 8.463v535.382q0 4.616 3.847 8.463Q595.384-200 600-200h135.383q4.616 0 8.462-3.846 3.846-3.847 3.846-8.463v-535.382ZM587.691-200h160-160Z" | ||
fill="rgb(var(--color-text-300))" | ||
/> | ||
</svg> | ||
`, | ||
insertRightTableIcon: `<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={24} | ||
height={24} | ||
viewBox="0 -960 960 960" | ||
> | ||
<path | ||
d="M600-140.001q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21h135.383q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H600Zm-375.383 0q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21H360q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H224.617Zm-12.308-607.69v535.382q0 4.616 3.846 8.463 3.846 3.846 8.462 3.846H360q4.616 0 8.462-3.846 3.847-3.847 3.847-8.463v-535.382q0-4.616-3.847-8.463Q364.616-760 360-760H224.617q-4.616 0-8.462 3.846-3.846 3.847-3.846 8.463Zm160 547.691h-160 160Z" | ||
fill="rgb(var(--color-text-300))" | ||
/> | ||
</svg> | ||
`, | ||
insertTopTableIcon: `<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={24} | ||
height={24} | ||
viewBox="0 -960 960 960" | ||
> | ||
<path | ||
d="M212.309-527.693q-30.308 0-51.308-21t-21-51.307v-135.383q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307V-600q0 30.307-21 51.307-21 21-51.308 21H212.309Zm0 375.383q-30.308 0-51.308-21t-21-51.307V-360q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307v135.383q0 30.307-21 51.307-21 21-51.308 21H212.309Zm0-59.999h535.382q4.616 0 8.463-3.846 3.846-3.846 3.846-8.462V-360q0-4.616-3.846-8.462-3.847-3.847-8.463-3.847H212.309q-4.616 0-8.463 3.847Q200-364.616 200-360v135.383q0 4.616 3.846 8.462 3.847 3.846 8.463 3.846Zm-12.309-160v160-160Z" | ||
fill="rgb(var(--color-text-300))" | ||
/> | ||
</svg> | ||
`, | ||
insertBottomTableIcon:`<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={24} | ||
height={24} | ||
viewBox="0 -960 960 960" | ||
> | ||
<path | ||
d="M212.309-152.31q-30.308 0-51.308-21t-21-51.307V-360q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307v135.383q0 30.307-21 51.307-21 21-51.308 21H212.309Zm0-375.383q-30.308 0-51.308-21t-21-51.307v-135.383q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307V-600q0 30.307-21 51.307-21 21-51.308 21H212.309Zm535.382-219.998H212.309q-4.616 0-8.463 3.846-3.846 3.846-3.846 8.462V-600q0 4.616 3.846 8.462 3.847 3.847 8.463 3.847h535.382q4.616 0 8.463-3.847Q760-595.384 760-600v-135.383q0-4.616-3.846-8.462-3.847-3.846-8.463-3.846ZM200-587.691v-160 160Z" | ||
fill="rgb(var(--color-text-300))" | ||
/> | ||
</svg> | ||
`, | ||
}; | ||
|
||
export default icons; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as default } from "./table" |
Oops, something went wrong.
14ac885
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.
Successfully deployed to the following URLs:
plane-dev – ./web/
plane-dev.vercel.app
plane-dev-git-develop-plane.vercel.app
plane-dev-plane.vercel.app
crew42.plane.so