restrictededitingmode.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module restricted-editing/restrictededitingmode
  7. */
  8. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  9. import RestrictedEditingModeEditing from './restrictededitingmodeediting';
  10. import RestrictedEditingModeUI from './restrictededitingmodeui';
  11. import '../theme/restrictedediting.css';
  12. /**
  13. * The restricted editing mode plugin.
  14. *
  15. * This is a "glue" plugin which loads the following plugins:
  16. *
  17. * * The {@link module:restricted-editing/restrictededitingmodeediting~RestrictedEditingModeEditing restricted mode editing feature}.
  18. * * The {@link module:restricted-editing/restrictededitingmodeui~RestrictedEditingModeUI restricted mode UI feature}.
  19. *
  20. * @extends module:core/plugin~Plugin
  21. */
  22. export default class RestrictedEditingMode extends Plugin {
  23. /**
  24. * @inheritDoc
  25. */
  26. static get pluginName() {
  27. return 'RestrictedEditingMode';
  28. }
  29. /**
  30. * @inheritDoc
  31. */
  32. static get requires() {
  33. return [ RestrictedEditingModeEditing, RestrictedEditingModeUI ];
  34. }
  35. }
  36. /**
  37. * The configuration of the restricted editing mode feature. Introduced by the
  38. * {@link module:restricted-editing/restrictededitingmode~RestrictedEditingMode} feature.
  39. *
  40. * Read more in {@link module:restricted-editing/restrictededitingmode~RestrictedEditingModeConfig}.
  41. *
  42. * @member {module:restricted-editing/restrictededitingmode~RestrictedEditingModeConfig}
  43. * module:core/editor/editorconfig~EditorConfig#restrictedEditing
  44. */
  45. /**
  46. * The configuration of the restricted editing mode feature.
  47. * The option is used by the {@link module:restricted-editing/restrictededitingmode~RestrictedEditingMode} feature.
  48. *
  49. * ClassicEditor
  50. * .create( {
  51. * restrictedEditing: {
  52. * allowedCommands: [ 'bold', 'link', 'unlink' ],
  53. * allowedAttributes: [ 'bold', 'linkHref' ]
  54. * }
  55. * } )
  56. * .then( ... )
  57. * .catch( ... );
  58. *
  59. * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
  60. *
  61. * @interface module:restricted-editing/restrictededitingmode~RestrictedEditingModeConfig
  62. */
  63. /**
  64. * The command names allowed in non-restricted areas of the content.
  65. *
  66. * Defines which feature commands should be enabled in the restricted editing mode. The commands used for typing and deleting text
  67. * (`'input'`, `'delete'` and `'forwardDelete'`) are allowed by the feature inside non-restricted regions and do not need to be defined.
  68. *
  69. * **Note**: The restricted editing mode always allows to use the restricted mode navigation commands as well as `'undo'` and `'redo'`
  70. * commands.
  71. *
  72. * The default value is:
  73. *
  74. * const restrictedEditingConfig = {
  75. * allowedCommands: [ 'bold', 'italic', 'link', 'unlink' ]
  76. * };
  77. *
  78. * To make a command always enabled (also outside non-restricted areas) use
  79. * {@link module:restricted-editing/restrictededitingmodeediting~RestrictedEditingModeEditing#enableCommand} method.
  80. *
  81. * @member {Array.<String>} module:restricted-editing/restrictededitingmode~RestrictedEditingModeConfig#allowedCommands
  82. */
  83. /**
  84. * The text attribute names allowed when pasting content ot non-restricted areas.
  85. *
  86. * The default value is:
  87. *
  88. * const restrictedEditingConfig = {
  89. * allowedAttributes: [ 'bold', 'italic', 'linkHref' ]
  90. * };
  91. *
  92. * @member {Array.<String>} module:restricted-editing/restrictededitingmode~RestrictedEditingModeConfig#allowedAttributes
  93. */