mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-04-30 00:00:04 +08:00
Using display options with layoutCandidates. Fixes #1831
This commit is contained in:
@@ -5,16 +5,19 @@ import {
|
||||
CandidateBoxParams,
|
||||
CandidateBoxRenderParams,
|
||||
CandidateBoxShowParams,
|
||||
KeyboardOptions,
|
||||
} from "./../interfaces";
|
||||
|
||||
class CandidateBox {
|
||||
utilities: Utilities;
|
||||
options: KeyboardOptions;
|
||||
candidateBoxElement!: HTMLDivElement;
|
||||
pageIndex = 0;
|
||||
pageSize;
|
||||
|
||||
constructor({ utilities }: CandidateBoxParams) {
|
||||
constructor({ utilities, options }: CandidateBoxParams) {
|
||||
this.utilities = utilities;
|
||||
this.options = options;
|
||||
Utilities.bindMethods(CandidateBox, this);
|
||||
this.pageSize = this.utilities.getOptions().layoutCandidatesPageSize || 5;
|
||||
}
|
||||
@@ -82,7 +85,7 @@ class CandidateBox {
|
||||
};
|
||||
|
||||
candidateListLIElement.className = "hg-candidate-box-list-item";
|
||||
candidateListLIElement.textContent = candidateListItem;
|
||||
candidateListLIElement.textContent = this.options.display?.[candidateListItem] || candidateListItem;
|
||||
candidateListLIElement.onclick = (e = getMouseEvent()) =>
|
||||
onItemSelected(candidateListItem, e);
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ class SimpleKeyboard {
|
||||
this.candidateBox = this.options.enableLayoutCandidates
|
||||
? new CandidateBox({
|
||||
utilities: this.utilities,
|
||||
options: this.options,
|
||||
})
|
||||
: null;
|
||||
|
||||
@@ -878,6 +879,7 @@ class SimpleKeyboard {
|
||||
this.candidateBox.destroy();
|
||||
this.candidateBox = new CandidateBox({
|
||||
utilities: this.utilities,
|
||||
options: this.options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ export interface KeyboardInput {
|
||||
}
|
||||
|
||||
export type CandidateBoxParams = {
|
||||
utilities: Utilities
|
||||
utilities: Utilities,
|
||||
options: KeyboardOptions
|
||||
}
|
||||
|
||||
export type CandidateBoxShowParams = {
|
||||
|
||||
Reference in New Issue
Block a user