phibr0 / obsidian-emoji-shortcodes

Emoji Shortcodes - Obsidian Plugin | Adds Support for Emoji Shortcodes to Obsidian
MIT License
178 stars 15 forks source link

Some bugs #13

Closed tswwe closed 3 years ago

tswwe commented 3 years ago

Hi. I like this handy plugin but I ran into some bugs in using it. Here are the reports (in the given example below, the cursor position is symbolized by ▊):

  1. If the text after the cursor contains :, the Immediate Emoji Replace function will fail in recognizing the emoji shortcodes at the cursor.

    e.g., it fails turning [:link:▊Title](https://aaa.com) into [🔗▊Title](https://aaa.com)

  2. If the text after the cursor contains :, the Emoji Suggester will fail in inserting selected emoji correctly.

    e.g., if we type [:▊Title](https://aaa.com) to trigger the Emoji Suggester board, then click to select an emoji (say 🔗), the text will become [🔗▊//aaa.com), which is not what we expect to be.

  3. If the preceeding charactor right before the cursor is a `, an alphabet or a number, you can't trigger the Emoji Suggester board by inputting a :.

    e.g., given TryToTriggerThat▊, then input a :, the Emoji Suggester board will not pop up.

  4. If the preceeding charactor right before the cursor is an alphabet or a number, and the cursor is not at the end of the line, the Immediate Emoji Replace function will fail in recognizing the emoji shortcodes at the cursor.

    e.g., it fails turning TryToTurn:link:▊That into TryToTurn🔗▊That

  5. If the text before the cursor contains :non-shortcode, you can't feed a new line by just pressing Enter.

    e.g., given ShowCase:PressEnter▊, then press Enter and nothing will happen. There is a workaround: input a space or press Esc before press Enter.

  6. If the whole line is a single :▊ with your cursor at the end of the line, you can't feed a new line by just pressing Enter.
  7. The plugin seems not to check if the cursor is in an inline-code/inline-math/codeblock/mathblock. This may cause the emoji shortcodes in the inline-code/inline-math/codeblock/mathblock be turned into an emoji symbol.

    e.g., `console.log(":link:")` is at a risk of being turned into `console.log("🔗")` (both in edit mode and preview mode)

Hopefully, I have read the source code (.obsidian/plugins/emoji-shortcodesmain.js) and I think I can fork the repo and help fixing these problems. If things go well, I will submit a pull request in next 2-3 days.

phibr0 commented 3 years ago

What you are looking at is the transpiled javascript file. The source code is written in Typescript and available here on Github. Looking forward to your PR 😄

tswwe commented 3 years ago

What you are looking at is the transpiled javascript file. The source code is written in Typescript and available here on Github. Looking forward to your PR 😄

Thanks for reminding. I do not have a typescript compiler on my computer (and don't know how to deploy one currently 😂). So I made these changes based on my local modified .obsidian/plugins/emoji-shortcodes/main.js file, because the .ts file seems to be similar to .js file. The .js file work on my computer, and I hope the patch for .ts also works, which may need more tests.