Skip to content

[pull] main from usememos:main #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/apidocs.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,8 @@ definitions:
cells:
type: array
items:
type: string
type: object
$ref: '#/definitions/v1Node'
UserRole:
type: string
enum:
Expand Down Expand Up @@ -3045,7 +3046,8 @@ definitions:
header:
type: array
items:
type: string
type: object
$ref: '#/definitions/v1Node'
delimiter:
type: array
items:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/usememos/gomark v0.0.0-20240630131948-9cc984646479
github.com/usememos/gomark v0.0.0-20240712135956-99d0ab9b9aa1
golang.org/x/crypto v0.25.0
golang.org/x/mod v0.19.0
golang.org/x/net v0.27.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/usememos/gomark v0.0.0-20240630131948-9cc984646479 h1:Agp+J1o5z1n67uG6IKgV/fE72Io1cUF4cfwxjDqW2GY=
github.com/usememos/gomark v0.0.0-20240630131948-9cc984646479/go.mod h1:7CZRoYFQyyljzplOTeyODFR26O+wr0BbnpTWVLGfKJA=
github.com/usememos/gomark v0.0.0-20240712135956-99d0ab9b9aa1 h1:4LuNOC1zgAk9K8kZjTBZ/yNJR9vgQTNAQFyWxLxJp5A=
github.com/usememos/gomark v0.0.0-20240712135956-99d0ab9b9aa1/go.mod h1:7CZRoYFQyyljzplOTeyODFR26O+wr0BbnpTWVLGfKJA=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
Expand Down
4 changes: 2 additions & 2 deletions proto/api/v1/markdown_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ message MathBlockNode {
}

message TableNode {
repeated string header = 1;
repeated Node header = 1;
repeated string delimiter = 2;

message Row {
repeated string cells = 1;
repeated Node cells = 1;
}
repeated Row rows = 3;
}
Expand Down
310 changes: 157 additions & 153 deletions proto/gen/api/v1/markdown_service.pb.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions server/router/api/v1/markdown_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ func convertFromASTNodes(rawNodes []ast.Node) []*v1pb.Node {

func convertTableFromASTNode(node *ast.Table) *v1pb.TableNode {
table := &v1pb.TableNode{
Header: node.Header,
Header: convertFromASTNodes(node.Header),
Delimiter: node.Delimiter,
}
for _, row := range node.Rows {
table.Rows = append(table.Rows, &v1pb.TableNode_Row{Cells: row})
table.Rows = append(table.Rows, &v1pb.TableNode_Row{Cells: convertFromASTNodes(row)})
}
return table
}
Expand Down Expand Up @@ -225,11 +225,11 @@ func convertToASTNodes(nodes []*v1pb.Node) []ast.Node {

func convertTableToASTNode(node *v1pb.TableNode) *ast.Table {
table := &ast.Table{
Header: node.Header,
Header: convertToASTNodes(node.Header),
Delimiter: node.Delimiter,
}
for _, row := range node.Rows {
table.Rows = append(table.Rows, row.Cells)
table.Rows = append(table.Rows, convertToASTNodes(row.Cells))
}
return table
}
2 changes: 1 addition & 1 deletion web/src/components/MemoContent/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
case NodeType.MATH_BLOCK:
return <Math {...(node.mathBlockNode as MathBlockNode)} block={true} />;
case NodeType.TABLE:
return <Table {...(node.tableNode as TableNode)} />;
return <Table index={index} {...(node.tableNode as TableNode)} />;
case NodeType.EMBEDDED_CONTENT:
return <EmbeddedContent {...(node.embeddedContentNode as EmbeddedContentNode)} />;
case NodeType.TEXT:
Expand Down
10 changes: 6 additions & 4 deletions web/src/components/MemoContent/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { TableNode_Row } from "@/types/proto/api/v1/markdown_service";
import { Node, TableNode_Row } from "@/types/proto/api/v1/markdown_service";
import Renderer from "./Renderer";

interface Props {
header: string[];
index: string;
header: Node[];
rows: TableNode_Row[];
}

Expand All @@ -12,7 +14,7 @@ const Table = ({ header, rows }: Props) => {
<tr className="divide-x divide-gray-300 dark:divide-zinc-600">
{header.map((h, i) => (
<th key={i} className="py-1 px-2">
{h}
<Renderer key={`${h.type}-${i}`} index={String(i)} node={h} />
</th>
))}
</tr>
Expand All @@ -22,7 +24,7 @@ const Table = ({ header, rows }: Props) => {
<tr key={i} className="divide-x divide-gray-300 dark:divide-zinc-600">
{row.cells.map((r, j) => (
<td key={j} className="py-1 px-2">
{r}
<Renderer key={`${r.type}-${i}-${j}`} index={String(j)} node={r} />
</td>
))}
</tr>
Expand Down
73 changes: 73 additions & 0 deletions web/src/locales/ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"auth": {
"create-your-account": "Crea el teu compte",
"host-tip": "T'estàs registrant com a amfitrió.",
"new-password": "Nova contrasenya",
"repeat-new-password": "Repeteix la contrasenya",
"sign-in-tip": "Ja tens un compte?",
"sign-up-tip": "Encara no tens un compte?"
},
"common": {
"about": "Quant a",
"admin": "Administrador",
"archive": "Arxivar",
"archived": "Arxivat",
"avatar": "Avatar",
"basic": "Bàsic",
"beta": "Beta",
"cancel": "Cancel·lar",
"change": "Canviar",
"clear": "Netejar",
"close": "Tanca",
"confirm": "Confirmar",
"create": "Crea",
"database": "Base de dades",
"days": "Dies",
"delete": "Esborra",
"description": "Descripció",
"edit": "Edita",
"email": "Correu electrònic",
"explore": "Explora",
"file": "Fitxer",
"filter": "Filtra",
"home": "Inici",
"image": "Imatge",
"inbox": "Bústia d'entrada",
"language": "Llenguatge",
"learn-more": "Saber-ne més",
"link": "Enllaç",
"mark": "Marca",
"memos": "Memos",
"name": "Nom",
"new": "Nou",
"nickname": "Sobrenom",
"null": "Nul",
"or": "o",
"password": "Contrasenya",
"pin": "Enganxa",
"pinned": "Enganxat",
"preview": "Previsualitza",
"profile": "Perfil",
"remember-me": "Recorda'm",
"rename": "Reanomena",
"reset": "Reinicia",
"resources": "Recursos",
"restore": "Restaura",
"role": "Rol",
"save": "Guarda",
"search": "Cerca",
"select": "Selecciona",
"settings": "Configuració",
"share": "Comparteix",
"sign-in": "Identifica't",
"sign-in-with": "Identifica't via {{provider}}",
"sign-out": "Surt",
"sign-up": "Registra't",
"statistics": "Estadístiques",
"tags": "Etiquetes",
"title": "Títol",
"type": "Tipus",
"unpin": "Desenganxa",
"update": "Actualitza"
}
}
2 changes: 1 addition & 1 deletion web/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"copy-link": "Copier le lien",
"count-memos-in-date": "{{count}} memos le {{date}}",
"delete-confirm": "Êtes-vous sûr de vouloir supprimer ce memos ? CETTE ACTION EST IRRÉVERSIBLE",
"delete-memo": "Supprimer Memo",
"delete-memo": "Supprimer Memos",
"embed": "Intégrer",
"fetch-more": "Cliquez pour en savoir plus",
"fetching-data": "Récupération des données…",
Expand Down