Guest User

Untitled

a guest
Mar 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public markContent(): void {
  2.  
  3. const selection = window.getSelection();
  4. const selectionRange = window.getSelection().getRangeAt(0);
  5.  
  6. if (selectionRange.startOffset !== selectionRange.endOffset) {
  7. if (this.markerEvent === 'p' || this.markerEvent === 'mark' || this.markerEvent === 'strong') {
  8.  
  9. const textSeleted = window.getSelection().toString();
  10. const range = window.getSelection().getRangeAt(0).cloneRange();
  11. if (this.markerEvent !== 'mark') {
  12. const marker = document.createElement('mark');
  13. marker.setAttribute('class', this.colorMarker);
  14. marker.textContent = textSeleted;
  15.  
  16. range.surroundContents(marker);
  17.  
  18. this.libraryServices.changeBobblePosition({ top: 0, left: 0, display: 'none' });
  19. }
  20. }
  21. }
  22.  
  23. }
Add Comment
Please, Sign In to add comment