| 1 | /************************************************************* |
| 2 | * |
| 3 | * Copyright (c) 2018-2022 The MathJax Consortium |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * @fileoverview Implements the SVGmglyph wrapper for the MmlMglyph object |
| 20 | * |
| 21 | * @author [email protected] (Davide Cervone) |
| 22 | */ |
| 23 | |
| 24 | import {SVGWrapperscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGWrapper#, SVGConstructorscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGConstructor#} from '../Wrapper.js'scip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/; |
| 25 | import {CommonMglyphMixinscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyphMixin().} from '../../common/Wrappers/mglyph.js'scip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/; |
| 26 | import {MmlMglyphscip-typescript npm mathjax-full 3.2.2 ts/core/MmlTree/MmlNodes/`mglyph.ts`/MmlMglyph#} from '../../../core/MmlTree/MmlNodes/mglyph.js'scip-typescript npm mathjax-full 3.2.2 ts/core/MmlTree/MmlNodes/`mglyph.ts`/; |
| 27 | import {SVGTextNodescip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`TextNode.ts`/SVGTextNode#} from './TextNode.js'scip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`TextNode.ts`/; |
| 28 | import {OptionListscip-typescript npm mathjax-full 3.2.2 ts/util/`Options.ts`/OptionList#} from '../../../util/Options.js'scip-typescript npm mathjax-full 3.2.2 ts/util/`Options.ts`/; |
| 29 | |
| 30 | /*****************************************************************/ |
| 31 | /** |
| 32 | * The SVGmglyph wrapper for the MmlMglyph object |
| 33 | * |
| 34 | * @template N The HTMLElement node class |
| 35 | * @template T The Text node class |
| 36 | * @template D The Document class |
| 37 | */ |
| 38 | // @ts-ignore |
| 39 | export class SVGmglyphscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#<Nscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#[N], Tscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#[T], Dscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#[D]> extends |
| 40 | CommonMglyphMixinscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyphMixin().<SVGConstructorscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGConstructor#<any, any, any>>(SVGWrapperscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGWrapper#) { |
| 41 | |
| 42 | /** |
| 43 | * The mglyph wrapper |
| 44 | */ |
| 45 | public static kindscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#kind. = MmlMglyphscip-typescript npm mathjax-full 3.2.2 ts/core/MmlTree/MmlNodes/`mglyph.ts`/MmlMglyph#.prototype.kindscip-typescript npm mathjax-full 3.2.2 ts/core/MmlTree/MmlNodes/`mglyph.ts`/MmlMglyph#`<get>kind`().; |
| 46 | |
| 47 | /** |
| 48 | * @override |
| 49 | */ |
| 50 | public toSVGscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#toSVG().(parentscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#toSVG().(parent): Nscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#[N]) { |
| 51 | const svg = this.standardSVGnodescip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGWrapper#standardSVGnode().(parentscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#toSVG().(parent)); |
| 52 | if (this.charWrapperscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyph#charWrapper.) { |
| 53 | (this.charWrapperscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyph#charWrapper. as SVGTextNodescip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`TextNode.ts`/SVGTextNode#<Nscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#[N], Tscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#[T], Dscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/SVGmglyph#[D]>).toSVGscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`TextNode.ts`/SVGTextNode#toSVG().(svg); |
| 54 | return; |
| 55 | } |
| 56 | const {src, alt} = this.nodescip-typescript npm mathjax-full 3.2.2 ts/core/Tree/`Wrapper.ts`/AbstractWrapper#node..attributesscip-typescript npm mathjax-full 3.2.2 ts/core/MmlTree/`MmlNode.ts`/MmlNode#attributes..getListscip-typescript npm mathjax-full 3.2.2 ts/core/MmlTree/`Attributes.ts`/Attributes#getList().('src', 'alt'); |
| 57 | const h = this.fixedscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGWrapper#fixed().(this.heightscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyph#height.); |
| 58 | const w = this.fixedscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGWrapper#fixed().(this.widthscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyph#width.); |
| 59 | const y = this.fixedscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGWrapper#fixed().(this.heightscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyph#height. + (this.valignscip-typescript npm mathjax-full 3.2.2 ts/output/common/Wrappers/`mglyph.ts`/CommonMglyph#valign. || 0)); |
| 60 | const properties: OptionListscip-typescript npm mathjax-full 3.2.2 ts/util/`Options.ts`/OptionList# = { |
| 61 | widthscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/width0:: w, heightscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/height0:: h, |
| 62 | transformscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/transform0:: 'translate(0 ' + y + ') matrix(1 0 0 -1 0 0)', |
| 63 | preserveAspectRatioscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/preserveAspectRatio0:: 'none', |
| 64 | 'aria-label'scip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/`'aria-label'0`:: alt, |
| 65 | hrefscip-typescript npm mathjax-full 3.2.2 ts/output/svg/Wrappers/`mglyph.ts`/href0:: src |
| 66 | }; |
| 67 | const img = this.svgscip-typescript npm mathjax-full 3.2.2 ts/output/svg/`Wrapper.ts`/SVGWrapper#svg().('image', properties); |
| 68 | this.adaptorscip-typescript npm mathjax-full 3.2.2 ts/output/common/`Wrapper.ts`/CommonWrapper#`<get>adaptor`()..appendscip-typescript npm mathjax-full 3.2.2 ts/core/`DOMAdaptor.ts`/DOMAdaptor#append().(svg, img); |
| 69 | } |
| 70 | |
| 71 | } |