spiegel-keyman/common/lexical-model-types
2020-01-30 14:23:31 +07:00
..
.gitignore Setup scaffolding. 2019-10-01 09:15:35 -06:00
build.sh Do not try to build anything in build.sh! 2019-10-01 14:10:07 -06:00
index.d.ts fix(common): model specification for isRTL 2020-01-30 14:23:31 +07:00
package-lock.json Setup scaffolding. 2019-10-01 09:15:35 -06:00
package.json Setup @keymanapp/lexical-model-types for publication. 2019-10-01 14:00:15 -06:00
README.md Document @keymanapp/lexical-model-types. 2019-10-05 13:41:33 -06:00
test.ts Add SuggestionTag interface. 2019-10-01 13:13:21 -06:00

Lexical Model Types

Declares TypeScript types and interfaces required to define Lexical Models, Word breaking functions, and all things in between.

Install

(see below if you are working in the keymanapp/keyman repo!)

npm install --save-dev @keymanapp/lexical-model-types

Usage

Say you are creating a custom lexical model. Then import this module in your lexical model file!

// my-nifty-model.ts

import "@keymanapp/lexical-model-types";

export class MyNiftyClass implements LexicalModel {
  configure(capabilities: Capabilities): Configuration {
    // TODO: implement me!
    throw new Error("Method not implemented.");
  }
  predict(transform: Transform, context: Context): ProbabilityMass<Suggestion>[] {
    // TODO: implement me!
    throw new Error("Method not implemented.");
  }
  wordbreak(context: Context): string {
    // TODO: implement me!
    throw new Error("Method not implemented.");
  }
  punctuation?: LexicalModelPunctuation;
}

If your are creating a custom word breaker, you would do the same:

import "@keymanapp/lexical-model-types";

export let myShinyWordBreaker: WordBreakingFunction;
myShinyWordBreaker = function (phrase: string): Span[] {
  // TODO: implement me!
  throw new Error("Function not implemented")
}

Look at index.d.ts for documentation on each and every type!

Usage within keymanapp/keyman repo

To use it in other subprojects within keymanapp/keyman, ensure that this package is linked using:

npm link .

The following subprojects already perform npm link . as part of their build.sh:

common/predictive-text/
developer/js/