@@ -265,9 +265,14 @@ export function useDictionaryEditor(initialSurface = "", initialPronunciation =
265
265
if ( isValid && pronunciation . length ) {
266
266
pronunciation = convertHiraToKana ( pronunciation ) ;
267
267
pronunciation = convertLongVowel ( pronunciation ) ;
268
+
269
+ // 現在の項目が最後の要素の場合のみ「ガ」を追加する
270
+ const isLastItem = accentPhraseIndex === wordAccentPhraseItems . value . length - 1 ;
271
+ const textToFetch = isLastItem ? pronunciation + "ガ'" : pronunciation + "'" ;
272
+
268
273
const fetchedAccentPhrase = (
269
274
await store . actions . FETCH_ACCENT_PHRASES ( {
270
- text : pronunciation + "ガ'" ,
275
+ text : textToFetch ,
271
276
engineId,
272
277
styleId,
273
278
isKana : true ,
@@ -322,12 +327,22 @@ export function useDictionaryEditor(initialSurface = "", initialPronunciation =
322
327
pronunciation : "" ,
323
328
isValid : true ,
324
329
} ) ;
330
+ // 追加したアクセント句を含め、すべてのアクセント句の発音を更新する
331
+ // そうしないと、常に wordAccentPhraseItems の最後の要素にのみ「ガ」を付与する挙動が維持できない
332
+ for ( let i = 0 ; i < wordAccentPhraseItems . value . length ; i ++ ) {
333
+ void updatePronunciation ( wordAccentPhraseItems . value [ i ] . pronunciation , i , true ) ;
334
+ }
325
335
}
326
336
327
337
// 指定されたアクセント句を削除する
328
338
function removeWordAccentPhraseItem ( accentPhraseIndex : number ) : void {
329
339
if ( wordAccentPhraseItems . value . length > 1 ) {
330
340
wordAccentPhraseItems . value . splice ( accentPhraseIndex , 1 ) ;
341
+ // 追加したアクセント句を含め、すべてのアクセント句の発音を更新する
342
+ // そうしないと、常に wordAccentPhraseItems の最後の要素にのみ「ガ」を付与する挙動が維持できない
343
+ for ( let i = 0 ; i < wordAccentPhraseItems . value . length ; i ++ ) {
344
+ void updatePronunciation ( wordAccentPhraseItems . value [ i ] . pronunciation , i , true ) ;
345
+ }
331
346
}
332
347
}
333
348
0 commit comments