contextplugin.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module core/contextplugin
  7. */
  8. import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
  9. import mix from '@ckeditor/ckeditor5-utils/src/mix';
  10. /**
  11. * The base class for {@link module:core/context~Context} plugin classes.
  12. *
  13. * @implements module:core/plugin~PluginInterface
  14. * @mixes module:utils/observablemixin~ObservableMixin
  15. */
  16. export default class ContextPlugin {
  17. /**
  18. * Creates a new plugin instance.
  19. *
  20. * @param {module:core/context~Context|module:core/editor/editor~Editor} context
  21. */
  22. constructor( context ) {
  23. /**
  24. * The context instance.
  25. *
  26. * @readonly
  27. * @type {module:core/context~Context|module:core/editor/editor~Editor}
  28. */
  29. this.context = context;
  30. }
  31. /**
  32. * @inheritDoc
  33. */
  34. destroy() {
  35. this.stopListening();
  36. }
  37. /**
  38. * Static property which marks plugin as an allowed to be use directly by a {@link module:core/context~Context}.
  39. *
  40. * @returns {Boolean}
  41. */
  42. static get isContextPlugin() {
  43. return true;
  44. }
  45. }
  46. mix( ContextPlugin, ObservableMixin );