I am not sure whether this place is appropriate for posting this quasi-PR, but I feel hesitant to write directly in Github because I want to listen to the community’s opinions, so…

I see that many people consider that the cross-platform syncing of the custom CSS file across desktop and mobile devices is important and that the inline tag <link rel="stylesheet" href="..."> is sufficient for their use cases. However, to me, having to append inline CSS links to every single note does not feel great.

Mimicking the current implementation in the desktop app (e.g., reading %HOMEPATH%/.config/joplin/userstyle.css in Windows), I have implemented the following in my github fork supporting custom CSS in mobile devices:

  1. On the startup of the application, it reads ${RNFS.ExternalDirectoryPath}/userstyle.css and passes the CSS string to the Markdown-to-HTML renderer.
    In Android, ${RNFS.ExternalDirectoryPath} is /Android/data/net.cozic.joplin/files/ if the app is installed in the internal storage.

  2. I have added to the <body> tag class="mobile android" attribute in Android, and "mobile iOS" in iOS.
    This attributes can help to create a CSS file applicable to multiple platforms.

Do you think this commit can make it to upstream, or is it too tailored to my own use case?


In the long run, I agree that a proper implementation should support the features discussed earlier, for example cross-platform syncing and selecting a file from filesystem mentioned by @tessus and @CalebJohn. In the mean time, however, it would be great if we can use custom CSS files in mobile devices using the above way, similar to the current implementation in the desktop app.

3 Likes