toolbox-team / reddit-moderator-toolbox-legacy

LEGACY VERSION do not use
http://www.reddit.com/r/toolbox
Apache License 2.0
66 stars 40 forks source link

Mod macros: allow insert mode for macro text (currently overwriting initial reply box contents) #809

Open multubunu opened 7 years ago

multubunu commented 7 years ago

This is a feature request, I have more as a matter of fact, will open them separately.

Consider the following scenario:

This could be avoided if the macro text would be inserted after the existing text in the reply box, rather than overwriting the existing comments.This is a feature request, I have more as a matter of fact, will open them separately.

Consider the following scenario:

This could be avoided if the macro text would be inserted after the existing text in the reply box, rather than overwriting the existing comments.

eritbh commented 7 years ago

Hmm, maybe we could introduce a token for any text that's already in the reply box? That way you could set macros up to include that text wherever it's relevant, and you could type out the custom part before confirming the rest of the macro.

Would probably end up extending info around macros.js:433 - maybe name the new token something like replytext, could just insert something like:

info.replytext = $this.closest('.usertext-edit').find('textarea').text()

@creesch thoughts?

creesch commented 7 years ago

The thing is, the macro doesn't overwrite whatever is in there... It opens up a popup you can move.

Having said that, a token for existing text is a good idea since in new modmail the macro will actually replace whatever is in the reply box...

We probably want the token to be part of TBUtils.getThingInfo if at all possible.

eritbh commented 7 years ago

Is putting it in there a good idea? The reply text isn't really a property of the link/comment in a strict sense.

creesch commented 7 years ago

Hrm, that is true. It might indeed be more appropriate in the macro itself.

I am not even sure it should be a token to be honest, maybe "prepend/append text from textarea" as a button. Though rereading the use case he can probably simply use {body} as token most of the times.

Ah well... Let's go for a token at first in the macro module itself it is simplest thing to do.

eritbh commented 7 years ago

Eh, if you're quoting multiple lines of the body, just doing

> {body}

wouldn't work because it would only quote the first line and have the rest trailing off. So for this specific case, it makes sense to let Reddit do the quoting and then insert that.

I do like the idea of adding a button though - we could even make it "insert at current cursor position" or something so there's easier control over it.