Skip to content

Commit

Permalink
refactor: コンテキストメニュー上部のテキスト表示周りをリファクタリング (#2223)
Browse files Browse the repository at this point in the history
* テキスト未選択時にコンテキストメニューヘッダーを非表示にする

* コンテキストメニュー上部のテキスト表示周りをリファクタリング

---------

Co-authored-by: jdkfx <amateurranch@gmail.com>
  • Loading branch information
Hiroshiba and jdkfx authored Aug 31, 2024
1 parent b9ea2fa commit 855be3c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/components/Talk/AudioCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -628,31 +628,31 @@ const readyForContextMenu = () => {
const MAX_HEADER_LENGTH = 15;
const SHORTED_HEADER_FRAGMENT_LENGTH = 5;
// 選択範囲を1行目に表示
// 選択範囲のテキスト
const selectionText = textFieldSelection.getAsString();
if (selectionText.length === 0) {
if (selectionText.length > MAX_HEADER_LENGTH) {
// 長すぎる場合適度な長さで省略
contextMenuHeader.value =
selectionText.length <= MAX_HEADER_LENGTH
? selectionText
: `${selectionText.substring(
0,
SHORTED_HEADER_FRAGMENT_LENGTH,
)} ... ${selectionText.substring(
selectionText.length - SHORTED_HEADER_FRAGMENT_LENGTH,
)}`;
} else {
contextMenuHeader.value = selectionText;
}
if (textFieldSelection.isEmpty) {
isRangeSelected.value = false;
getMenuItemButton("切り取り").disabled = true;
getMenuItemButton("コピー").disabled = true;
contextMenuHeader.value = "";
} else {
isRangeSelected.value = true;
getMenuItemButton("切り取り").disabled = false;
getMenuItemButton("コピー").disabled = false;
if (selectionText.length > MAX_HEADER_LENGTH) {
// 長すぎる場合適度な長さで省略
contextMenuHeader.value =
selectionText.length <= MAX_HEADER_LENGTH
? selectionText
: `${selectionText.substring(
0,
SHORTED_HEADER_FRAGMENT_LENGTH,
)} ... ${selectionText.substring(
selectionText.length - SHORTED_HEADER_FRAGMENT_LENGTH,
)}`;
} else {
contextMenuHeader.value = selectionText;
}
}
};
const endContextMenuOperation = async () => {
Expand Down

0 comments on commit 855be3c

Please sign in to comment.