Skip to content

Commit

Permalink
having table notes above the table
Browse files Browse the repository at this point in the history
  • Loading branch information
950288 committed Nov 24, 2023
1 parent fa43936 commit a704314
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 50 deletions.
71 changes: 25 additions & 46 deletions BackEnd/testContent.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
{
"attrs": {
"class": null,
"textAlign": "left"
},
"content": [
Expand All @@ -36,9 +35,6 @@
"type": "paragraph"
},
{
"attrs": {
"class": "imagePro"
},
"content": [
{
"attrs": {
Expand All @@ -49,6 +45,9 @@
"type": "image"
},
{
"attrs": {
"textAlign": "left"
},
"content": [
{
"marks": [
Expand Down Expand Up @@ -88,7 +87,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "left"
},
"content": [
Expand All @@ -106,7 +104,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "left"
},
"content": [
Expand All @@ -124,7 +121,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "left"
},
"content": [
Expand All @@ -146,6 +142,27 @@
"allowGapCursor": null
},
"content": [
{
"attrs": {
"textAlign": "left"
},
"content": [
{
"marks": [
{
"type": "bold"
}
],
"text": "Table 1.",
"type": "text"
},
{
"text": " Also works well for table with note",
"type": "text"
}
],
"type": "paragraph"
},
{
"content": [
{
Expand All @@ -159,7 +176,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand All @@ -182,7 +198,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand All @@ -205,7 +220,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand Down Expand Up @@ -233,7 +247,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand All @@ -256,7 +269,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand All @@ -279,7 +291,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand Down Expand Up @@ -307,7 +318,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand All @@ -330,15 +340,8 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
"textAlign": "left"
},
"content": [
{
"text": "Francisco Chang",
"type": "text"
}
],
"type": "paragraph"
}
],
Expand All @@ -353,7 +356,6 @@
"content": [
{
"attrs": {
"class": null,
"textAlign": "center"
},
"content": [
Expand All @@ -372,28 +374,6 @@
}
],
"type": "table"
},
{
"attrs": {
"class": "tableNote",
"textAlign": "left"
},
"content": [
{
"marks": [
{
"type": "bold"
}
],
"text": "Table 1.",
"type": "text"
},
{
"text": " Also wokrs well for table with note",
"type": "text"
}
],
"type": "paragraph"
}
],
"type": "tablePro"
Expand All @@ -412,7 +392,6 @@
},
{
"attrs": {
"class": null,
"textAlign": "left"
},
"content": [
Expand Down
2 changes: 1 addition & 1 deletion FrontEnd/src/components/Note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default Paragraph.extend({
}
if (
tablePro &&
typeof tablePro.node.content.content[1]?.content.content[0]?.text ==
typeof tablePro.node.content.content[0]?.content.content[0]?.text ==
"undefined"
) {
console.log("delete TablePro");
Expand Down
6 changes: 3 additions & 3 deletions FrontEnd/src/components/TablePro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { createTable } from "@tiptap/extension-table";
* table with 3 rows, 3 columns, and no header row
* @renderHTML
* <table-pro>
* <p>add table note here</p>
* <table>
* ****
* </table>
* <p>add table note here</p>
* </table-pro>
*/

Expand All @@ -34,7 +34,7 @@ export default Node.create({

group: "block",

content: "table paragraph",
content: "paragraph",

defining: false,

Expand Down Expand Up @@ -72,7 +72,7 @@ export default Node.create({

const tableWithNoteNode = editor.schema.nodes.tablePro.createChecked(
{},
[table, noteNode],
[noteNode, table],
);
tr.insert(tr.selection.from - 1, tableWithNoteNode);
return true;
Expand Down
7 changes: 7 additions & 0 deletions FrontEnd/src/views/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ function replaceJson(data: { content: [any]; type: string }) {
if (data.type === "TablePro") {
data.type = "tablePro";
}
if (data.type === "tablePro") {
if ((data.content.length as any) == 2 && data.content[0] == "table") {
let temp = data.content[0];
data.content[0] = (data.content as any)[1];
(data.content as any)[1] = temp;
}
}
for (let key in data.content) {
if (typeof data.content[key] === "object") {
replaceJson(data.content[key]);
Expand Down

0 comments on commit a704314

Please sign in to comment.