From d0d169ec2103e18768bffd33b2867961ad4b46a0 Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Thu, 14 Sep 2023 13:14:06 +0200 Subject: [PATCH 1/6] feat: add Tab --- src/Tab.res | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/Tab.res diff --git a/src/Tab.res b/src/Tab.res new file mode 100644 index 0000000..3303ebd --- /dev/null +++ b/src/Tab.res @@ -0,0 +1,2 @@ +@module("docx") @new +external make: unit => TextRun.children = "Tab" From 3bc8f3b5f866bba25f878f1762c8cae75fad0249 Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Thu, 14 Sep 2023 13:18:14 +0200 Subject: [PATCH 2/6] feat: add PositionalTab --- src/PositionalTab.res | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/PositionalTab.res diff --git a/src/PositionalTab.res b/src/PositionalTab.res new file mode 100644 index 0000000..320a2ba --- /dev/null +++ b/src/PositionalTab.res @@ -0,0 +1,9 @@ +/** @see https://docx.js.org/api/classes/PositionalTab.html */ +type option = { + alignment: [#left | #center | #rigth], + relativeTo: [#margin | #indent], + leader: [#none | #dot | #hyphen | #underscore | #middleDot], +} + +@module("docx") @new +external make: option => TextRun.children = "PositionalTab" From acf6d08fa8fe2a08a9b83e69a0c34f7e3964c7d3 Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Thu, 14 Sep 2023 13:21:47 +0200 Subject: [PATCH 3/6] refactor: factorize with the LeaderType enum --- src/LeaderType.res | 7 +++++++ src/PositionalTab.res | 2 +- src/TabStopDefinition.res | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/LeaderType.res diff --git a/src/LeaderType.res b/src/LeaderType.res new file mode 100644 index 0000000..0edb037 --- /dev/null +++ b/src/LeaderType.res @@ -0,0 +1,7 @@ +type t = [ + | #dot + | #hyphen + | #middleDot + | #none + | #underscore +] diff --git a/src/PositionalTab.res b/src/PositionalTab.res index 320a2ba..70b091c 100644 --- a/src/PositionalTab.res +++ b/src/PositionalTab.res @@ -2,7 +2,7 @@ type option = { alignment: [#left | #center | #rigth], relativeTo: [#margin | #indent], - leader: [#none | #dot | #hyphen | #underscore | #middleDot], + leader: LeaderType.t, } @module("docx") @new diff --git a/src/TabStopDefinition.res b/src/TabStopDefinition.res index 37d0f96..34557f8 100644 --- a/src/TabStopDefinition.res +++ b/src/TabStopDefinition.res @@ -6,5 +6,5 @@ type numberOrTabStopPosition = Number(float) | TabStopPosition(tabStopPosition) type t = { @as("type") type_: [#left | #right | #center | #bar | #clear | #decimal | #end | #num | #start], position: numberOrTabStopPosition, - leader?: [#dot | #hyphen | #middleDot | #none | #underscore], + leader?: LeaderType.t, } From d5a662c1139a9b381ff8360122b8728652a3049e Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Thu, 14 Sep 2023 13:23:35 +0200 Subject: [PATCH 4/6] docs: update the doc --- README.md | 4 ++-- src/LeaderType.res | 1 + src/Tab.res | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c33a42..4999397 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,8 @@ List of supported features: * ✅ Hyperlinks * ✅ Numbering * ✅ Tables -* ❌ Tabs -* ❌ Table Of Contents +* ✅ Tabs +* ✅ Table Of Contents * ✅ Page Numbers * ❌ Change Tracking * ❌ Math diff --git a/src/LeaderType.res b/src/LeaderType.res index 0edb037..dcc0291 100644 --- a/src/LeaderType.res +++ b/src/LeaderType.res @@ -1,3 +1,4 @@ +/** @see https://docx.js.org/api/enums/LeaderType.html */ type t = [ | #dot | #hyphen diff --git a/src/Tab.res b/src/Tab.res index 3303ebd..c500522 100644 --- a/src/Tab.res +++ b/src/Tab.res @@ -1,2 +1,4 @@ -@module("docx") @new +/** @see https://docx.js.org/api/classes/Tab.html */ +@module("docx") +@new external make: unit => TextRun.children = "Tab" From 1f4c8b3ca416b12fd21169fb870870d35b1a8405 Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Thu, 14 Sep 2023 13:42:05 +0200 Subject: [PATCH 5/6] syntax: #rigth -> #right --- src/PositionalTab.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PositionalTab.res b/src/PositionalTab.res index 70b091c..dcf08ad 100644 --- a/src/PositionalTab.res +++ b/src/PositionalTab.res @@ -1,6 +1,6 @@ /** @see https://docx.js.org/api/classes/PositionalTab.html */ type option = { - alignment: [#left | #center | #rigth], + alignment: [#left | #center | #right], relativeTo: [#margin | #indent], leader: LeaderType.t, } From 5e8847890f90179a8890c0afba10d14fc83314e1 Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Thu, 14 Sep 2023 13:50:32 +0200 Subject: [PATCH 6/6] refactor: use int in TabStopDefinition --- src/TabStopDefinition.res | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/TabStopDefinition.res b/src/TabStopDefinition.res index 34557f8..6c2cfd4 100644 --- a/src/TabStopDefinition.res +++ b/src/TabStopDefinition.res @@ -1,10 +1,7 @@ -type tabStopPosition = | @as("9026") Max - -@unwrap -type numberOrTabStopPosition = Number(float) | TabStopPosition(tabStopPosition) +let maxPosition = 9026 type t = { @as("type") type_: [#left | #right | #center | #bar | #clear | #decimal | #end | #num | #start], - position: numberOrTabStopPosition, + position: int, leader?: LeaderType.t, }