mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-02 13:47:42 +00:00
fix(web): Toolbar UI -> TS, ES modules - but not yet tested
This commit is contained in:
parent
892bbd58ee
commit
d81b1cd51c
8 changed files with 1381 additions and 1155 deletions
|
|
@ -315,10 +315,15 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
|
|||
* uses a pick list (Chinese, Japanese, Korean, etc.)
|
||||
* (This function accepts either keyboard structure.)
|
||||
*/
|
||||
isCJK(k0? /* keyboard script object */) {
|
||||
isCJK(k0? /* keyboard script object | return-type of _GetKeyboardDetail [b/c Toolbar UI]*/) {
|
||||
let kbd: Keyboard;
|
||||
if(k0) {
|
||||
kbd = new Keyboard(k0);
|
||||
let kbdDetail = k0 as ReturnType<KeymanEngine['_GetKeyboardDetail']>;
|
||||
if(kbdDetail.KeyboardID){
|
||||
kbd = this.keyboardRequisitioner.cache.getKeyboard(k0.KeyboardID);
|
||||
} else {
|
||||
kbd = new Keyboard(k0);
|
||||
}
|
||||
} else {
|
||||
kbd = this.core.activeKeyboard;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {
|
|||
getAbsoluteY,
|
||||
StylesheetManager
|
||||
} from "keyman/engine/dom-utils";
|
||||
import { DomEventTracker } from "keyman/engine/events";
|
||||
import { BrowserConfiguration, BrowserInitOptionSpec } from "./configuration.js";
|
||||
|
||||
/**
|
||||
|
|
@ -109,26 +110,38 @@ export class UtilApiEndpoint {
|
|||
return styleSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a stylesheet element
|
||||
*
|
||||
* @param {Object} s style sheet reference
|
||||
* @return {boolean} false if element is not a style sheet
|
||||
**/
|
||||
removeStyleSheet(s: HTMLStyleElement) {
|
||||
return this.stylesheetManager.unlink(s);
|
||||
}
|
||||
/**
|
||||
* Remove a stylesheet element
|
||||
*
|
||||
* @param {Object} s style sheet reference
|
||||
* @return {boolean} false if element is not a style sheet
|
||||
**/
|
||||
removeStyleSheet(s: HTMLStyleElement) {
|
||||
return this.stylesheetManager.unlink(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reference to an external stylesheet file
|
||||
*
|
||||
* @param {string} s path to stylesheet file
|
||||
*/
|
||||
linkStyleSheet(s: string): void {
|
||||
this.stylesheetManager.linkExternalSheet(s);
|
||||
}
|
||||
/**
|
||||
* Add a reference to an external stylesheet file
|
||||
*
|
||||
* @param {string} s path to stylesheet file
|
||||
*/
|
||||
linkStyleSheet(s: string): void {
|
||||
this.stylesheetManager.linkExternalSheet(s);
|
||||
}
|
||||
|
||||
shutdown() {
|
||||
this.stylesheetManager?.unlinkAll();
|
||||
}
|
||||
|
||||
// Possible alternative: https://www.npmjs.com/package/language-tags
|
||||
// This would necessitate linking in a npm module into compiled KeymanWeb, though.
|
||||
getLanguageCodes(lgCode: string): string[] {
|
||||
if(lgCode.indexOf('-')==-1) {
|
||||
return [lgCode];
|
||||
} else {
|
||||
return lgCode.split('-');
|
||||
}
|
||||
}
|
||||
|
||||
readonly DomEventTracker = DomEventTracker;
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ let es5ClassAnnotationAsPurePlugin = {
|
|||
}
|
||||
}
|
||||
|
||||
const modules = ['kmwuitoggle'];
|
||||
const modules = ['kmwuitoggle', 'kmwuitoolbar'];
|
||||
|
||||
for(let module of modules) {
|
||||
await esbuild.build({
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,8 +11,8 @@
|
|||
"files": [
|
||||
// "kmwuibutton.ts",
|
||||
// "kmwuifloat.ts",
|
||||
"kmwuitoggle.ts" //,
|
||||
// "kmwuitoolbar.ts"
|
||||
"kmwuitoggle.ts",
|
||||
"kmwuitoolbar.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../browser" }
|
||||
|
|
|
|||
|
|
@ -391,6 +391,24 @@ export default class KeymanEngine<
|
|||
return this.contextManager.activeKeyboard?.metadata.id ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getActiveLanguage
|
||||
* Scope Public
|
||||
* @param {boolean=} true to retrieve full language name, false/undefined to retrieve code.
|
||||
* @return {string} language code
|
||||
* Description Return language code for currently selected language
|
||||
*/
|
||||
getActiveLanguage(fullName?: boolean): string {
|
||||
// In short... the activeStub.
|
||||
const metadata = this.contextManager.activeKeyboard?.metadata;
|
||||
|
||||
if(!fullName) {
|
||||
return metadata.langId ?? '';
|
||||
} else {
|
||||
return metadata.langName ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function isChiral
|
||||
* Scope Public
|
||||
|
|
|
|||
|
|
@ -274,17 +274,6 @@ namespace com.keyman {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getActiveLanguage
|
||||
* Scope Public
|
||||
* @param {boolean=} true to retrieve full language name, false/undefined to retrieve code.
|
||||
* @return {string} language code
|
||||
* Description Return language code for currently selected language
|
||||
*/
|
||||
['getActiveLanguage'](fullName?: boolean): string {
|
||||
return this.keyboardManager.getActiveLanguage(fullName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function disableControl
|
||||
* Scope Public
|
||||
|
|
|
|||
|
|
@ -24,16 +24,6 @@ namespace com.keyman {
|
|||
this.keyman = keyman;
|
||||
}
|
||||
|
||||
// Possible alternative: https://www.npmjs.com/package/language-tags
|
||||
// This would necessitate linking in a npm module into compiled KeymanWeb, though.
|
||||
['getLanguageCodes'](lgCode: string): string[] {
|
||||
if(lgCode.indexOf('-')==-1) {
|
||||
return [lgCode];
|
||||
} else {
|
||||
return lgCode.split('-');
|
||||
}
|
||||
}
|
||||
|
||||
initDevices(): void {
|
||||
this.device = new Device();
|
||||
this.physicalDevice = new Device();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue