is it possible to style custom gutter on right side?

As the title suggests I want to display a custom gutter on the right side in CM6. Is this possible and if yes then how? any examples would be appreciated.

With the @codemirror/gutter package, only if you set your entire editor’s text direction to be right-to-left. But it should be possible to write a plugin similar to the gutter extension that does this by adding a new DOM element next to the content element.

1 Like

For future people, I followed @marijn suggestion and essentially copied this entire file:

Changing line 180 to:

view.scrollDOM.insertBefore(this.dom, view.contentDOM.nextSibling);

Which simply appends the gutter after the main editor area, placing it neatly on the right side.

3 Likes

For even more future people who use @codemirror/view as of version 6.3.2, after cloning the file and patching the gutterView’s constructor as mentioned above, you also need to patch it’s syncGutters method

on line 191, from:

    if (detach) this.view.scrollDOM.insertBefore(this.dom, after)

to:

    if (detach) {
      if (after) {
        this.view.scrollDOM.insertBefore(this.dom, after)
      } else {
        this.view.scrollDOM.appendChild(this.dom)
      }
    }