Page MenuHomePhabricator

[TUX] Improve insertables insertion to replace selected text
Closed, ResolvedPublic

Description

Currently with using insertables their codes is inserted at left of the cursor or selected text. Selection thus canceled.
See example

pasted_file (328×912 px, 46 KB)

and current result (highlighted)
pasted_file (85×279 px, 8 KB)

Proposal: when insertion to replace selected text by a insertable code. Target results may be look as:

pasted_file (79×215 px, 6 KB)

This would more user-friendly behavior.

Also reported on https://translatewiki.net/wiki/Thread:Support/Editing_in_the_AJAX_tool_-_using_klick_point_in_the_lower_left_edge.

Event Timeline

Kaganer assigned this task to Nikerabbit.
Kaganer raised the priority of this task from to Needs Triage.
Kaganer updated the task description. (Show Details)
Kaganer added subscribers: Kaganer, Pginer-WMF, Nemo_bis and 2 others.
Kaganer renamed this task from [TUX] Update insertables insertion to replace selected text to [TUX] Improve insertables insertion to replace selected text.Sep 29 2015, 12:31 PM
Kaganer updated the task description. (Show Details)
Kaganer set Security to None.

How would you know when to replace the existing selection and when to wrap the selection (for example {{PLURAL:$1|_}} wraps the selection at _)?

I don't see problem.

  1. "simple" insertables, as variables $1 or $name etc. should be replace the selection
  2. "complicated" insertables (currently this only {{PLURAL:$1|+}} and {{GENDER:$1|+}}. not?) should be wrap the selection

Difference - presence or absence of brackets.

Nikerabbit subscribed.

I am not currently working on this.

Pols12 subscribed.

I am proposing a patch which assumes “pre” value should fully replace selection as soon as there is no “post” value. That seems to fit with provided Insertables types.

Some user-developped Insertables can rely on current behavior, but from a final-user, that seems to be a strange expectation: the final user can place its carret before the world instead of selecting it, if they want to insert the Insertable before the word.

Change 822193 had a related patch set uploaded (by Pols12; author: Pols12):

[mediawiki/extensions/Translate@master] Make Insertable without post content to replace selection

https://gerrit.wikimedia.org/r/822193

Change 822193 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Make Insertable without post content to replace selection

https://gerrit.wikimedia.org/r/822193

abi_ changed the task status from Open to In Progress.Aug 23 2022, 4:50 AM

I've tested this on translatewiki, and this works well.