cooklang / cooklang-obsidian

Edit and display CookLang recipes in Obsidian
MIT License
204 stars 16 forks source link

No line wrap #25

Open johanbaaij opened 1 year ago

johanbaaij commented 1 year ago
image

Wrapping works fine in my .md files. Perhaps it is an issue introduced in a newer Obsidian version since this plugin was released?

SYSTEM INFO:
    Obsidian version: v1.0.3
    Installer version: v0.15.9
    Operating system: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 21.6.0
    Login status: logged in
    Catalyst license: none
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: adapt to system
    Community theme: none
    Snippets enabled: 0
    Restricted mode: off
    Plugins installed: 4
    Plugins enabled: 4
        1: Dataview v0.5.47
        2: CookLang Editor v0.3.0
        3: Templater v1.14.3
        4: Tasks v1.16.0

RECOMMENDATIONS:
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.
shayaknyc commented 1 year ago

Came here looking to see if someone else has this issue and I'm glad someone else posted it. When in writing mode, there doesn't appear to be any line-wrapping for files ending in .cook - which would "activate" the Cooklang spec in read mode. Read mode renders fine, but when in writing mode, the line keeps scrolling off the right past the pane edge, which makes things difficult to work with directly in Obsidian. My workaround has been to manually edit or create .cook files in the vault with a text editor.

codingkoi commented 1 year ago

Looks like something might have changed in Obsidian that's causing this issue. I found if I changed this line in cookView.ts^code-link like this, it fixes the issue:

- lineWrapping: (this.app.vault as any).getConfig('lineWrap'),
+ lineWrapping: true,

From what I can uncover, it looks like this used to be a configurable setting but it was removed in 1.0^word-wrap. I could create a pull request to apply this fix, or alternatively add the setting into the Cooklang plugin settings so it's still an option if people want it, but it's not clear to me that this project is being closely maintained.

shayaknyc commented 1 year ago

Honestly, the path of least resistance, as I'm not a developer and would have difficulty getting an environment set up sufficiently to apply the fix myself, and then build the plugin myself, and install it. Thank you for debugging this and finding a solution!

Edit: I've discovered where to patch this if you already have it installed as a plugin.

  1. Close down obsidian

  2. Find the main.js file in [VAULT_FOLDER]/.obsidian/plugins/cooklang-obsidian/main.js. For example, I'm on Windows, so mine is saved in: Documents\Obsidian Vault\Recipes\.obsidian\plugins\cooklang-obsidian\main.js Recipes in the path above is my [VAULT_FOLDER]

  3. Open the main.js file in your favorite text editor and find the string lineWrapping. Mine is on line 3642, which should contain the string: lineWrapping: this.app.vault.getConfig('lineWrap'),

  4. If you comment it out (with // right in front) just to keep it there just in case, and then add a new line underneath with the modified string @codingkoi suggested: lineWrapping: true,

It should look something like this: image (see highlighted areas)

  1. Save the file, close it, then reload Obsidian, and the source view should now properly display cooklang files.