CopyPasteRules.js 757 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import inherits from 'inherits';
  2. import RuleProvider from 'lib/features/rules/RuleProvider';
  3. export default function CopyPasteRules(eventBus) {
  4. RuleProvider.call(this, eventBus);
  5. }
  6. CopyPasteRules.$inject = [ 'eventBus' ];
  7. inherits(CopyPasteRules, RuleProvider);
  8. CopyPasteRules.prototype.init = function() {
  9. this.addRule('element.copy', function(context) {
  10. var element = context.element;
  11. if (element.host) {
  12. return false;
  13. }
  14. return true;
  15. });
  16. this.addRule('element.paste', function(context) {
  17. if (context.source) {
  18. return false;
  19. }
  20. return true;
  21. });
  22. this.addRule('elements.paste', function(context) {
  23. if (context.target.id === 'parent2') {
  24. return false;
  25. }
  26. return true;
  27. });
  28. };