remove magic number in favor of calculating it on the fly
This commit is contained in:
parent
9ec5410273
commit
e3b561835b
|
@ -282,11 +282,15 @@ class _ToolbarBody extends HookWidget {
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.reformat((selection) {
|
controller.reformat((selection) {
|
||||||
final insides = selection.isNotEmpty ? selection : '___';
|
const textBeg = '\n::: spoiler spoiler\n';
|
||||||
|
final textMid = selection.isNotEmpty ? selection : '___';
|
||||||
|
const textEnd = '\n:::\n';
|
||||||
|
|
||||||
return _Reformat(
|
return _Reformat(
|
||||||
text: '\n::: spoiler spoiler\n$insides\n:::\n',
|
text: textBeg + textMid + textEnd,
|
||||||
selectionBeginningShift: 21,
|
selectionBeginningShift: textBeg.length,
|
||||||
selectionEndingShift: 21 + insides.length - selection.length,
|
selectionEndingShift:
|
||||||
|
textBeg.length + textMid.length - selection.length,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue