All files / src/pwk env.js

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117                                          1x   1x           1x                                                                                       1x                                                                                      
/**
 * @fileoverview Environment configurations.
 * @author Dmytro Antonenko <dmitry.antonenko@pubwebkit.com>
 */
import {WidthNodeStyle} from './style/node/width_node_style.js';
import {BackgroundColorTextStyle} from './style/text/background_color_text_style.js';
import {BaseNodeStyle} from './style/node/base_node_style.js';
import {BaseTextStyle} from './style/text/base_text_style.js';
import {ColorTextStyle} from './style/text/color_text_style.js';
import {FontTextStyle} from './style/text/font_text_style.js';
import {IndentNodeStyle} from './style/node/indent_node_style.js';
import {NodeStyle} from './style/node/node_style.js';
import {TabRenderer} from './content/char/tab_renderer.js';
import {TextAlignNodeStyle} from './style/node/text_align_node_style.js';
import {ImeTextStyle} from './style/text/ime_text_style.js';
import {StrikethroughTextStyle} from './style/text/strikethrough_text_style.js';
import {SubscriptTextStyle} from './style/text/subscript_text_style.js';
import {SuperscriptTextStyle} from './style/text/superscript_text_style.js';
import {TextStyle} from './style/text/text_style.js';
import {UnderlineTextStyle} from './style/text/underline_text_style.js';
 
goog.declareModuleId('pwk.env');
 
const {CustomCharRendererBase} = goog.requireType('pwk.content.char.CustomCharRendererBase');
 
/**
 * Default map of the fonts to use in the editor.
 * @type {!Object<string, !Object<string, !Array<string>>>}
 */
const defaultFontsConfiguration = {
  'LoadOnly': {
    'Adobe NotDef': ['n4']
  },
  'Custom': {
    'Arial': ['n4', 'i4', 'n7', 'i7'],
    'DejaVu Sans': ['n4', 'i4', 'n7', 'i7'],
    'DejaVu Sans Mono': ['n4', 'i4', 'n7', 'i7'],
    'Verdana': ['n4', 'i4', 'n7', 'i7'],
  },
  'Google': {
    'Satisfy': ['n4', 'i4'],
    'Alegreya': ['n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
    'Anonymous Pro': ['n4', 'i4', 'n7', 'i7'],
    'Archivo Narrow': ['n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7'],
    'Cormorant': ['n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7'],
    'Fira Sans': ['n1', 'i1', 'n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
    'Gentium Book Basic': ['n4', 'i4', 'n7', 'i7'],
    'Lato': ['n1', 'i1', 'n3', 'i3', 'n4', 'i4', 'n7', 'i7', 'n9', 'i9'],
    'Literata': ['n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
    'Montserrat Alternates': ['n1', 'i1', 'n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
    'Montserrat': ['n1', 'i1', 'n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
    'Noto Sans': ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9'],
    'Noto Sans JP': ['n1', 'n3', 'n4', 'n5', 'n7', 'n9'],
    'Noto Sans Mono': ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9'],
    'Nunito Sans': ['n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
    'Old Standard TT': ['n4', 'i4', 'n7', 'i7'],
    'Open Sans': ['n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8'],
    'Oswald': ['n2', 'n3', 'n4', 'n5', 'n6', 'n7'],
    'Roboto': ['n1', 'i1', 'n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n7', 'i7', 'n9', 'i9'],
    'Rubik Distressed': ['n4'],
    'Sora': ['n1', 'i1', 'n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8'],
    'Source Serif Pro': ['n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n6', 'i6', 'n7', 'i7', 'n9', 'i9'],
    'Space Mono': ['n4', 'i4', 'n7', 'i7'],
    'Ubuntu': ['n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n7', 'i7',],
    'Vollkorn': ['n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
    'Work Sans': ['n1', 'i1', 'n2', 'i2', 'n3', 'i3', 'n4', 'i4', 'n5', 'i5', 'n6', 'i6', 'n7', 'i7', 'n8', 'i8', 'n9', 'i9'],
  }
};
 
/**
 * Environment configurations.
 * @dict
 */
export const env = {
  /**
   * The map of the text styles. Each text styles class should be instantiated.
   * @type {!Object<string, !BaseTextStyle>}
   */
  'textStyles': {
    [TextStyle.BACKGROUND_COLOR]: new BackgroundColorTextStyle(),
    [TextStyle.COLOR]: new ColorTextStyle(),
    [TextStyle.FONT]: new FontTextStyle(defaultFontsConfiguration),
    [TextStyle.IME]: new ImeTextStyle(),
    [TextStyle.STRIKETHROUGH]: new StrikethroughTextStyle(),
    [TextStyle.SUBSCRIPT]: new SubscriptTextStyle(),
    [TextStyle.SUPERSCRIPT]: new SuperscriptTextStyle(),
    [TextStyle.UNDERLINE]: new UnderlineTextStyle(),
  },
 
  /**
   * The map of the text styles applied on the node level. Each text styles
   * class should be instantiated.
   * @type {!Object<string, !BaseNodeStyle>}
   */
  'nodeStyles': {
    [NodeStyle.TEXT_ALIGN]: new TextAlignNodeStyle(),
    [NodeStyle.INDENT]: new IndentNodeStyle(),
    [NodeStyle.WIDTH]: new WidthNodeStyle(),
  },
 
  /**
   * The map of the custom char renderers. Each renderer should be instantiated.
   * The key represents a char code point. The value should be a class inherited
   * from {@link pwk.content.char.CustomCharRendererBase}
   * @type {!Object<string, !CustomCharRendererBase>}
   */
  'char-renderers': {
    '9': new TabRenderer()
  },
 
  /**
   * The map of the fonts to use in the editor.
   * @type {!Object<string, !Object<string, !Array<string>>>}
   */
  'fonts': defaultFontsConfiguration
};