WrapperFactory.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*************************************************************
  2. *
  3. * Copyright (c) 2017-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. * @fileoverview Implements the OutputWrapperFactory class
  19. *
  20. * @author dpvc@mathjax.org (Davide Cervone)
  21. */
  22. import {CommonOutputJax} from './OutputJax.js';
  23. import {AbstractWrapperFactory} from '../../core/Tree/WrapperFactory.js';
  24. import {CommonWrapper, CommonWrapperClass} from './Wrapper.js';
  25. import {CharOptions, DelimiterData, FontData} from './FontData.js';
  26. import {MmlNode} from '../../core/MmlTree/MmlNode.js';
  27. /*****************************************************************/
  28. /**
  29. * The OutputWrapperFactory class for creating OutputWrapper nodes
  30. *
  31. * @template J The OutputJax type
  32. * @template W The Wrapper type
  33. * @template C The WrapperClass type
  34. * @template CC The CharOptions type
  35. * @template FD The FontData type
  36. */
  37. export class CommonWrapperFactory<
  38. J extends CommonOutputJax<any, any, any, W, CommonWrapperFactory<J, W, C, CC, DD, FD>, FD, any>,
  39. W extends CommonWrapper<J, W, C, CC, DD, FD>,
  40. C extends CommonWrapperClass<J, W, C, CC, DD, FD>,
  41. CC extends CharOptions,
  42. DD extends DelimiterData,
  43. FD extends FontData<CC, any, DD>
  44. > extends AbstractWrapperFactory<MmlNode, W, C> {
  45. /**
  46. * The default list of wrapper nodes this factory can create
  47. * (filled in by subclasses)
  48. */
  49. public static defaultNodes: {[kind: string]: CommonWrapperClass<any, any, any, any, any, any>} = {};
  50. /**
  51. * The output jax associated with this factory
  52. */
  53. public jax: J = null;
  54. /**
  55. * @return {Object} The list of node-creation functions
  56. */
  57. get Wrappers(): Object {
  58. return this.node;
  59. }
  60. }
  61. export type AnyWrapperFactory = CommonWrapperFactory<any, any, any, any, any, any>;