cosmocode / dokuwiki-plugin-prosemirror

A modern WYSIWYG editor for DokuWiki
https://wysiwyg.wiki.cosmocode.de/
54 stars 20 forks source link

keymap: change to support bold and italic keyboard shortcuts. #204

Open gyger opened 4 months ago

gyger commented 4 months ago

This adds the function to use CTRL + B and CTRL + I to toggle between bold and italic.

gyger commented 4 months ago

Together with PR https://github.com/cosmocode/dokuwiki-plugin-prosemirror/pull/203 they solve #122.

If you want I can also merge the two pull requests into one. We could also add other commands easily.

As an inspiration from the sample file (https://github.com/ProseMirror/prosemirror-example-setup/blob/master/src/keymap.ts) the following shortcuts are implemented (Dont think we need all, just as inspiration).

splitbrain commented 4 months ago

I'm not a mac user, how does this map to macos and does it make sense there?

gyger commented 4 months ago

I am neither, but according to documentation Mod- matches to CTRL on Win/Lin and Command on Mac.

Only italic and bold is implemented in this pull request, the test is just a list from the example implementation.

StefanP74 commented 1 month ago

Is this only working with a special browser in windows 10? I tried with edge and firefox. I copied the code from https://github.com/cosmocode/dokuwiki-plugin-prosemirror/pull/204/files to /var/www/html/dokuwiki/lib/plugins/prosemirror/script/plugins/Keymap/keymap.js ... but nothing happened. Ctrl+z is the only working short-cut. Is there something left to do ... or ist the code only working on a special OS or browser? ... or is it not realy implemented in the currently downloadable "build"?

pgschk commented 1 month ago

@StefanP74 it's been a while since I applied this PR to my installation (a shame it's not been merged yet :cry:). If I remember correctly this code ends up in bundle.js after building. I thought it would be enough to yarn build this branch and replace bundle.js, but what did work for me at the end was:

StefanP74 commented 1 month ago

Hello,

what i did:

Ther are some warnings while running yarn build but no errors. So I tried it again to do Shift+Enter in dokuwiki at visual editor… but still not working ☹

Should it work with above steps? Did I something wrong?

Thx for your help.

pgschk commented 1 month ago

@StefanP74 I can't test your approache, but if you are working directly on the system the easiest approach would be:

Afterwards make sure to refresh the dokuwiki page in your browser, ideally clearing cache, and try a different browser, to make sure you are not experiencing a cached javascript.

StefanP74 commented 1 month ago

Hallo,

yarn build ….. …. ERROR in ./script/plugins/Keymap/keymap.js Module Error (from ./node_modules/eslint-loader/index.js):

/var/www/html/dokuwiki/lib/plugins/prosemirror/script/plugins/Keymap/keymap.js 4:32 error 'exitCode' is defined but never used no-unused-vars

✖ 1 problem (1 error, 0 warnings)

@ ./script/main.js 17:14-48 error Command failed with exit code 2.

pgschk commented 1 month ago

@StefanP74 You're right, this branch does not build on it's own, it is dependend on #203.

I failed to mention yarn install, in case you did not run it before yarn build, but I think you did.

You need to actually apply both changes, #203 and #204:

Afterwards make sure to refresh the dokuwiki page in your browser, ideally clearing cache, and try a different browser, to make sure you are not experiencing a cached javascript.

@gyger I think you need to remove exitCode from line 4 for this PR, as it is only used by PR #203.

StefanP74 commented 1 month ago

Hello,

YESS!! It’s working now. 🙂 Thank you very much for your help. Prosemirror now works perfectly with Shift+Enter.

We are very happy about this well-functioning and simple to use WYSIWYG editor... as ckgedit does not do its job particularly well due to instability and extreme problems with ....

Don’t know you know it, … but this is an example what happens with ckgedit:

for %%f in ("%folder%*") do ( set filename=%%~nxf set newname=%timestamp%_!filename! ren "%%f" "!newname!" )

... and this is what it becomes after saving:

for f in ("%folder%\*") do (

set filename=~nxf set newname=%timestamp%_!filename! ren "f" "!newname!" )

And there’s no way to disable that code-chaos from my side. Prosemirror can handle this perfectly without any code transformation inside -tag. Perfect!

I will say thank you to all developers of prosemirror for that fantastic dokuwiki-plugin. 👍👍

Best regards

Stefan