From fe99e9901cb1c9171f72fcf4e41af1d20fabb935 Mon Sep 17 00:00:00 2001 From: Siam Ahmed Date: Sat, 31 Aug 2024 21:19:54 +0600 Subject: [PATCH 1/2] added the dir auto property for RTL text support --- src/components/AnnotationPage.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/AnnotationPage.vue b/src/components/AnnotationPage.vue index 1cceb909..622ec12b 100644 --- a/src/components/AnnotationPage.vue +++ b/src/components/AnnotationPage.vue @@ -4,6 +4,7 @@
Date: Sat, 14 Sep 2024 04:17:42 +0600 Subject: [PATCH 2/2] fixed annotation block creating issue and added support of mix of rtl and ltr --- package.json | 3 +- src/components/AnnotationPage.vue | 46 ++++++++++++++- src/components/AnnotationSidebar.vue | 3 + src/components/StartPage.vue | 4 +- src/components/TokenBlock.vue | 10 +++- .../sidebar/TextDirectionSelector.vue | 56 +++++++++++++++++++ src/store/index.js | 4 ++ yarn.lock | 5 ++ 8 files changed, 124 insertions(+), 7 deletions(-) create mode 100644 src/components/sidebar/TextDirectionSelector.vue diff --git a/package.json b/package.json index b02ed0fd..d3f83e91 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@quasar/extras": "^1.16.2", "@tauri-apps/api": "^1.0.0-beta.8", "core-js": "^3.30.1", + "direction": "^2.0.1", "es6-promise": "^4.2.8", "quasar": "^2.11.10", "treebank-tokenizer": "^0.0.1", @@ -27,12 +28,12 @@ "vuex": "^4.1.0" }, "devDependencies": { + "@babel/eslint-parser": "^7.21.3", "@tauri-apps/cli": "^1.0.0-beta.10", "@vue/cli-plugin-babel": "~5.0.8", "@vue/cli-plugin-eslint": "~5.0.8", "@vue/cli-service": "~5.0.8", "@vue/compiler-sfc": "^3.2.47", - "@babel/eslint-parser": "^7.21.3", "eslint": "^8.38.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.0.1", diff --git a/src/components/AnnotationPage.vue b/src/components/AnnotationPage.vue index 622ec12b..aa172d75 100644 --- a/src/components/AnnotationPage.vue +++ b/src/components/AnnotationPage.vue @@ -3,8 +3,8 @@
[spans[i][0], spans[i][1], t]); this.tm = new TokenManager(this.classes); this.tm.setTokensAndAnnotation(combined, this.currentAnnotation); }, + + /*if ltr and rtl text both exist in the same file + then the tokens are generated in one direction based on users input + which causes one direction(ltr or rtl) of the texts to be in reverse. + To handle that the tokens that should be in the opposite direction is reversed*/ + handleRtlAndLtrMix(tokens){ + /* initialize an empty map where key will be start index + and the value will be total number of consecutive opposite direction texts*/ + const indexMap = new Map(); + + for(let i = 0; i +
- + {{ token.label }} diff --git a/src/components/sidebar/TextDirectionSelector.vue b/src/components/sidebar/TextDirectionSelector.vue new file mode 100644 index 00000000..a2d815c4 --- /dev/null +++ b/src/components/sidebar/TextDirectionSelector.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/store/index.js b/src/store/index.js index 9c7ba0ec..5924bc15 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -73,6 +73,9 @@ export const mutations = { setAnnotationPrecision(state, payload) { state.annotationPrecision = payload; }, + setTextDirection(state, payload) { + state.textDirection = payload; + }, setKeyboardShortcuts(state, payload) { state.enableKeyboardShortcuts = payload; }, @@ -189,6 +192,7 @@ export default { separator: "\n", enableKeyboardShortcuts: false, annotationPrecision: "word", + textDirection: "ltr", // current state currentAnnotation: {}, currentClass: tags && tags[0] || {}, diff --git a/yarn.lock b/yarn.lock index 0e36b19a..60ab9275 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4371,6 +4371,11 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" +direction@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/direction/-/direction-2.0.1.tgz#71800dd3c4fa102406502905d3866e65bdebb985" + integrity sha512-9S6m9Sukh1cZNknO1CWAr2QAWsbKLafQiyM5gZ7VgXHeuaoUwffKN4q6NC4A/Mf9iiPlOXQEKW/Mv/mh9/3YFA== + dns-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"