Skip to content

#421 Add experiment function RTL support - #439

Merged
Jocs merged 5 commits into
marktext:masterfrom
enyaxu:feature/421
Aug 12, 2018
Merged

Jocs merged 5 commits into
marktext:masterfrom
enyaxu:feature/421

Conversation

@enyaxu

@enyaxu enyaxu commented Jul 25, 2018 •

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
New tests added? not needed
Fixed tickets #421
License MIT

Description

Add experiment function for text direction RTL support

--

@Jocs
Jocs requested review from Jocs and fxha July 25, 2018 07:52

@fxha fxha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@enyaxu Is it normal that the scrollbar is on the left?

:style="{ 'color': theme === 'dark' ? darkColor : lightColor, 'lineHeight': lineHeight, 'fontSize': fontSize,
'font-family': editorFontFamily ? `${editorFontFamily}, ${defaultFontFamily}` : `${defaultFontFamily}` }"
'font-family': editorFontFamily ? `${editorFontFamily}, ${defaultFontFamily}` : `${defaultFontFamily}`,
'direction': textDirection }"

@fxha fxha Jul 25, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the HTML dir attribute instead of css style. Please see https://stackoverflow.com/a/5375907.

@enyaxu enyaxu Jul 26, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fxha OK, I'll use dir attribute for this. Any suggestion about scrollbar position?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrg0lden @mohsenkhanpour What's the default scrollbar side? Is it on the left or right side?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fxha @enyaxu The scrollbar is on the default right side on most (almost all) of rtl pages that I have seen. Similar to ltr.
Right is also better because it gives you a unified experience when working with texts of several languages.
You don't want to look again for your scrollbar when you switch between files written in different languages.

@Jocs

Jocs commented Jul 26, 2018

Copy link
Copy Markdown
Member

Nice PR, great thanks for you , I'll review this evening.

@enyaxu

enyaxu commented Jul 26, 2018 via email

Copy link
Copy Markdown
Contributor Author

@mohsenkhanpour

Copy link
Copy Markdown

Does using the HTML dir attribute instead of css style also change the position of the slidebar and scrollbar?

@Jocs

Jocs commented Jul 26, 2018

Copy link
Copy Markdown
Member

@mohsenkhanpour You can pull down this PR, and test locally.

@fxha

fxha commented Jul 26, 2018

Copy link
Copy Markdown
Contributor

Yes,when set up dir attitube to rtl, It’s deafult change sildebar position to left!

@enyaxu I think you can set the scrollbar direction via css to the right.

@mohsenkhanpour

mohsenkhanpour commented Jul 26, 2018 •

Copy link
Copy Markdown

@Jocs @fxha @enyaxu
I downloaded the PR to test and here is what I found:
✅ 1. First of all the text itself is aligned to right as it should and adding English words doesn't break the style.
screenshot_1

✅ 2. The scrollbar is to the left and the slidebar is to the left.
screenshot_2
It doesn't look unusual at all. ✅

❎ 3. The line direction argument applies to the next opened file rather than the open document.
2018-07-26_15-34-42

❎ 4. The source code viewer still in ltr, (this can be done and very useful if implemented)

2018-07-26_15-58-11

❎ 5. No padding makes the first words in each line difficult to read:

2018-07-26_15-52-10

@Jocs

Jocs commented Jul 26, 2018

Copy link
Copy Markdown
Member

@enyaxu @mohsenkhanpour @fxha

  1. The source code viewer still in ltr, (this can be done and very useful if implemented)

Maybe you need to look up codemirror's documents and to see weather it support rtl and ltr options.

@enyaxu

enyaxu commented Jul 26, 2018

Copy link
Copy Markdown
Contributor Author

@Jocs @mohsenkhanpour
I pull a request for source code viewer RTL support. please test, Thanks.

@enyaxu

enyaxu commented Jul 26, 2018

Copy link
Copy Markdown
Contributor Author

@mohsenkhanpour
Can you upload markdown file for me used for testing?

@enyaxu

enyaxu commented Jul 26, 2018 •

Copy link
Copy Markdown
Contributor Author

@Jocs @fxha

  1. The line direction argument applies to the next opened file rather than the open document.

For now I'm reading the source code. I can't find a way to attach and save attribute with each single file. So I just used preference to save textDirection value. This cause all document default applying textDirection value when changed.

@enyaxu

enyaxu commented Jul 26, 2018

Copy link
Copy Markdown
Contributor Author

@Jocs @fxha @mohsenkhanpour

  1. The scrollbar is to the left and the slidebar is to the left.

Should we need to change this to left or remain it?

@Jocs

Jocs commented Jul 27, 2018

Copy link
Copy Markdown
Member

I pull a request for source code viewer RTL support. please test, Thanks.

ok

Should we need to change this to left or remain it?

I usually don't use right-to-left writing, so I'm not sure about the position of the scrollbar. I can only give some suggestions on the code. can @mohsenkhanpour give some advice?

@Jocs

Jocs commented Jul 27, 2018

Copy link
Copy Markdown
Member

@enyaxu

For now I'm reading the source code. I can't find a way to attach and save attribute with each single file. So I just used preference to save textDirection value. This cause all document default applying textDirection value when changed.

As we discussed in the issue before, the textdirection in the edit menu only affects the current document, should not be written to the user preferences, and this does not need to be stored. I suggest you refer to the implementation of line ending.

@mohsenkhanpour

Copy link
Copy Markdown

@enyaxu This is the markdown file that I used. You can find more files in the same repository.

Should we need to change this to left or remain it?

The scroll bar is already at the left side. And it is fine.

I pull a request for source code viewer RTL support. please test, Thanks.

Sure.

@mohsenkhanpour

Copy link
Copy Markdown

@enyaxu I tested the pull request. Here is what I found:

  1. Source code view still in ltr.
  2. The menu option still applies to the next document rather than the active document.
  3. Improved readability due to added margins.

@enyaxu

enyaxu commented Jul 28, 2018

Copy link
Copy Markdown
Contributor Author

@mohsenkhanpour
Thank you for feedback. I'll fixed asap.

@enyaxu

enyaxu commented Aug 1, 2018 •

Copy link
Copy Markdown
Contributor Author

@mohsenkhanpour @Jocs
First, I reimplement all RTL functions.

  1. Source code view still in ltr.
  2. The menu option still applies to the next document rather than the active document.

Above bugs are fixed.

  1. Improved readability due to added margins.

For this, you can see my upload image, I think don't need to added margins. I tested from mac.

Also, I found Travis CI check failed, I check error like below.

appimage.AppImageConfiguration.FileAssociations: []appimage.FileAssociation: appimage.FileAssociation.Ext: ReadString: expects " or n, but found [, error found in #10 byte of ...|:[{"ext":["md","mark|..., bigger context ...|on.png","size":1025}],"fileAssociations":[{"ext":["md","markdown","mmd","mdown","mdtxt","mdtext"],"r|...

@Jocs Seems ext config for macosx has some error.

Thanks for review and testing.
kapture 2018-08-01 at 22 54 04

@mohsenkhanpour

Copy link
Copy Markdown

Beautiful. I will pull and test as soon as I can. Thanks for your time and effort.

@mohsenkhanpour

mohsenkhanpour commented Aug 1, 2018 •

Copy link
Copy Markdown

@enyaxu @Jocs I tested the new version:
The direction changes instantly.
Source code viewer can be changed to RTL.

I can confirm it is working flawlessly on Windows.

@fxha

fxha commented Aug 5, 2018

Copy link
Copy Markdown
Contributor

@enyaxu If you change the direction from LTR to RTL and back the direction attribute has conflicting values and stays RTL.

mt_rtl_bug

@enyaxu

enyaxu commented Aug 7, 2018

Copy link
Copy Markdown
Contributor Author

@fxha The el-dialog direction value is manual set by default to ltr, it will not changed with text direction in editor.

@fxha

fxha commented Aug 7, 2018

Copy link
Copy Markdown
Contributor

@enyaxu OK then the problem lies somewhere else because you cannot change the direction after setting it to RTL at runtime.

@Jocs

Jocs commented Aug 12, 2018

Copy link
Copy Markdown
Member

@enyaxu Sorry, this PR has dragged on for so long. One reason is that I don't know much about RTL input. Another reason is that I am really busy recently. I just reviewed the code and ran it locally, with some questions.

  • is header tag right?
    1534063754098

  • @mohsenkhanpour Can you help with this PR, And under the full test, is it running normally?

@mohsenkhanpour

Copy link
Copy Markdown

@Jocs I have been using this PR for some days and I have also given a copy to one of my friends who writes rtl text for his Jekyll blog.
Regarding the direction and style I haven't encountered any bugs so far.

What's that header tag? I haven't noticed it in my texts?

@Jocs

Jocs commented Aug 12, 2018

Copy link
Copy Markdown
Member

@mohsenkhanpour If you cursor is in the active header paragraph, and the header tag will be shown on the left (ltr).

@mohsenkhanpour

mohsenkhanpour commented Aug 12, 2018 •

Copy link
Copy Markdown

@Jocs It looks all good.
screenshot_1

If there is anything specific that you want me to test I can do that.

@Jocs

Jocs commented Aug 12, 2018

Copy link
Copy Markdown
Member

@mohsenkhanpour @enyaxu @fxha thank you all for this new feature, 👍

@Jocs
Jocs merged commit c01c65c into marktext:master Aug 12, 2018
Jocs added a commit that referenced this pull request Jun 21, 2026
* chore(deps): bump dompurify to ^3.4.9 across desktop/muya/muyajs

Updates the HTML sanitizer from ^3.4.3/^3.4.5 to ^3.4.9 (resolves to
3.4.11), deduping the two installed versions (3.4.3 + 3.4.7) into one.
Clears Dependabot alerts #443/#451/#452/#453/#454/#455/#456.

MarkText calls DOMPurify.sanitize() only with string input and
RETURN_TRUSTED_TYPE: false (no IN_PLACE/RETURN_DOM/addHook/
SAFE_FOR_TEMPLATES), so none of these CVEs were reachable; the bump is
defense-in-depth for the editor's HTML sanitization path.

DOMPurify 3.4.8+ hardened cross-realm namespace validation, which the
happy-dom test environment does not satisfy: under happy-dom it strips
every element, even default-allowed tags like <p>/<h1>. Real
Chromium/Electron is unaffected (verified: jsdom, which matches production
DOM behavior, sanitizes correctly). Move the five DOMPurify-dependent muya
specs to the jsdom environment and declare jsdom as a muya devDependency.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore(deps): bump happy-dom to ^20.8.9 in muya

Updates muya's vitest DOM test environment from ^15.11.7 to ^20.8.9
(resolves to 20.10.6). Clears Dependabot alerts
#426/#427/#428/#434/#437/#438 (2 critical "VM context escape / RCE",
4 high).

happy-dom is a devDependency used only as the unit-test DOM; it is never
bundled into the shipped app, and the muya suites run trusted fixtures, so
these CVEs were not reachable. The bump keeps the test toolchain current and
clears the critical badges. The full muya unit suite (143 files) passes on
20.x — the DOMPurify-dependent specs already moved to jsdom in the previous
commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore(deps): update vite to patched 7.3.5 / 8.0.16

Bumps vite to the patched releases across the workspace (desktop ^7.3.5,
muya + muya-e2e ^8.0.16), updating the declared floors so installs can't
regress below the fix. Clears Dependabot alerts #441/#442/#447/#448
(server.fs.deny bypass + launch-editor NTLMv2 disclosure — both Windows
dev-server only; vite is build tooling, never shipped to users).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore(deps): pin transitive deps to patched versions via pnpm overrides

Adds range-scoped pnpm.overrides to force patched releases of the transitive
dependencies Dependabot flagged, while leaving unaffected older majors in
place (undici 6.x, esbuild 0.25.x, js-yaml 3.x):

  form-data   4.0.5      -> 4.0.6   (#450 CRLF injection)
  tmp         0.2.5      -> 0.2.6   (#411 path traversal)
  tar         7.5.15     -> 7.5.16  (#449 PAX file smuggling)
  ws          8.20.1     -> 8.21.0  (#444 memory-exhaustion DoS)
  undici      7.24/7.25  -> 7.28.0  (#457 SOCKS5 TLS bypass; keeps 6.25.0)
  esbuild     0.27/0.28.0-> 0.28.1  (#439 dev-server file read; keeps 0.25.x)
  @babel/core 7.29.0     -> 7.29.6  (#445 sourceMappingURL file read)
  js-yaml     4.1.1      -> 4.2.0   (#446 merge-key DoS; keeps 3.14.2)

All are build/test/website tooling reachable only on developer/CI machines,
never bundled into the shipped app. js-yaml 3.14.2 remains via the website's
gray-matter (no 3.x patch exists); it parses only trusted first-party
content, so #446 is not exploitable there and will be dismissed on GitHub.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
thimbleberrysystems pushed a commit to thimbleberrysystems/WordBird that referenced this pull request Jun 21, 2026
* feature: Add experiment RTL support

* fix: binding to currentfile textdirection

* feature: add sourcecode RTL support

* feature: add text direction menu upgrade

* fix sourceCode does't change from menu switch text direction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants