You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to figure out how to edit a note directly from the command line, unfortunately I can't delete text successfully.
So I leave here what I found, and if someone can make it work, it would be a great addition to this client.
First of all, let's authentificate cf #9. (Idk if it's necessary)
NOTEID=3_jUrZCYRTOtcEAJG6Oywg
# The socket url
URL=$CODIMD_SERVER/socket.io/?noteId=$NOTEID\&EIO=3\&transport=polling
# get the 'io' token
curl -c /tmp/codimd-cookies.txt \
-b /tmp/codimd-cookies.txt \
$URL\&t=$(python yeast.py) \
&> /dev/null
Then, all messages must be passed to $SERVER/socket.io/?noteId=$NOTEID&EIO=3&transport=polling&t=$(python yeast.py)&sid\=$TOKEN, TOKEN is the token we just picked up.
This payloads are working when I'm inspecting the network on my browser, but I can't reproduce it (text deletion) by using curl. Even if the socket returns ok to me every time.
I hope I can help, if someone can figure out how to do it.
This is the last thing before being able to edit notes from codimd-cli.
If it makes it easier @SISheogorath, the CLI only needs a way to update the entire note contents at once (so no need for OT or individual line/diff-based edits).
I'm trying to figure out how to edit a note directly from the command line, unfortunately I can't delete text successfully.
So I leave here what I found, and if someone can make it work, it would be a great addition to this client.
First of all, let's authentificate cf #9. (Idk if it's necessary)
Then, connecting to the socket.
Then, all messages must be passed to
$SERVER/socket.io/?noteId=$NOTEID&EIO=3&transport=polling&t=$(python yeast.py)&sid\=$TOKEN
, TOKEN is the token we just picked up.To do so:
This will send the data from the file
msg_0
to the socket.As an example, on a fresh new note:
With msg_4 containing
61:42["operation",0,["test"],{"ranges":[{"anchor":4,"head":4}]}]
Then, by analyzing the different possible messages I think the format is as follows:
$1:42["operation",$2,["$3",$4],{"ranges":[{"anchor":$5,"head":$5}]}]
:
For example:
61:42["operation",0,["test"],{"ranges":[{"anchor":4,"head":4}]}]
65:42["operation",0,["01234",-4],{"ranges":[{"anchor":5,"head":5}]}]
59:42["operation",0,[4,-1],{"ranges":[{"anchor":4,"head":4}]}]
This payloads are working when I'm inspecting the network on my browser, but I can't reproduce it (text deletion) by using curl. Even if the socket returns
ok
to me every time.I hope I can help, if someone can figure out how to do it.
This is the last thing before being able to edit notes from codimd-cli.
PS: here you can find the source file
The text was updated successfully, but these errors were encountered: