humhub icon indicating copy to clipboard operation
humhub copied to clipboard

Add dir element in <p> tag automatically

Open rezaervani opened this issue 2 years ago • 10 comments

How To Reproduce

Based on article at : https://www.w3.org/International/questions/qa-html-dir

I did some experience to my humhub, add dir element in p tag on stream, it make every RTL text (arabic) automatically start from Right side, and keep LTR text start from left side

Screenshot from 2022-05-04 07-02-54

With code is looked like this :

Screenshot from 2022-05-04 07-06-21

Expected Result

The Question is :

How to make dir element automatically shown in stream (after type a status from markdown editor) ?

Thank you

rezaervani avatar May 04 '22 00:05 rezaervani

See #4875

ArchBlood avatar May 04 '22 10:05 ArchBlood

Do I understand it correctly that with <p dir="auto"> everything is displayed correctly? And it's just a matter of adding the dir="auto" attribute at the e.g. P?

luke- avatar May 04 '22 13:05 luke-

Do I understand it correctly that with <p dir="auto"> everything is displayed correctly?

Yes. All this time all stream text display from left, include RTL language like arabic, add dir=auto will correct it.

Based on the same article, the solution should not be done through CSS

rezaervani avatar May 04 '22 16:05 rezaervani

Instead of adding an RTL attribute everywhere, could you not add here: https://github.com/humhub/humhub/pull/4875/files

luke- avatar May 05 '22 08:05 luke-

Instead of adding an RTL attribute everywhere, could you not add here: https://github.com/humhub/humhub/pull/4875/files

Wouldn't work on some bootstrap elements

ArchBlood avatar May 05 '22 13:05 ArchBlood

But on the Richtext?

luke- avatar May 06 '22 13:05 luke-

But on the Richtext?

Adding auto would work only on text, menu icons and such will not be changed Screenshot_1

Richtext is however changed with or without auto Screenshot_2

ArchBlood avatar May 07 '22 23:05 ArchBlood

It also happens with all RTL-supported languages of course.

Screenshot_3 Screenshot_4

ArchBlood avatar May 07 '22 23:05 ArchBlood

The only way I could think of fixing this without changing to a newer version of Bootstrap would be by making special containers for menus and dropdown menus where it would support the RTL functions.

ArchBlood avatar May 07 '22 23:05 ArchBlood

But on the Richtext?

I try this schema on prosemirror :

paragraph: {
    content: "inline*",
    group: "block",
    attrs: {
      dir: {default: "auto"},
    },
    parseDOM: [
      {
        tag: "p",
        getAttrs: (dom) => ({dir: dom.getAttribute("dir")}),
      },
    ],
    toDOM(node) {
      const {dir} = node.attrs;
      return ["p", {"dir": dir}, 0];
    },
  },

it will add attribute dir=auto automatically in paragraph tag

So when I type arabic, it will start from right side.

I put rough demo here : https://rezaervani.com/koding/prose.html

Screenshot from 2022-05-09 13-43-09

rezaervani avatar May 09 '22 06:05 rezaervani