StackItemFactory.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*************************************************************
  2. *
  3. * Copyright (c) 2009-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 A factory for stack items. This allows particular items to be
  19. * overwritten later.
  20. *
  21. * @author v.sorge@mathjax.org (Volker Sorge)
  22. */
  23. import {StackItemClass, StackItem, BaseItem} from './StackItem.js';
  24. import ParseOptions from './ParseOptions.js';
  25. import {AbstractFactory} from '../../core/Tree/Factory.js';
  26. class DummyItem extends BaseItem {}
  27. /**
  28. * The StackItemFactory is initially populated with the default stack item
  29. * classes. They can be changed, deleted or added to, if and when necessary.
  30. *
  31. * @constructor
  32. * @extends {AbstractFactory}
  33. */
  34. export default class StackItemFactory extends AbstractFactory<StackItem, StackItemClass> {
  35. /**
  36. * @override
  37. */
  38. public static DefaultStackItems: {[kind: string]: StackItemClass} = {
  39. [DummyItem.prototype.kind]: DummyItem
  40. };
  41. /**
  42. * @override
  43. */
  44. public defaultKind = 'dummy';
  45. /**
  46. * The parser configuration.
  47. * @type {ParseOptions}
  48. */
  49. public configuration: ParseOptions = null;
  50. }