|
50 | 50 | var block = getSelectedBlock();
|
51 | 51 |
|
52 | 52 | if ( ! editor.$( block ).find( 'figcaption' ).length ) {
|
53 |
| - var figcaption = editor.$( '<figcaption><br></figcaption>' ); |
| 53 | + var figcaption = editor.$( '<figcaption contenteditable="true"><br></figcaption>' ); |
54 | 54 |
|
55 | 55 | editor.undoManager.transact( function() {
|
56 | 56 | editor.$( block ).append( figcaption );
|
|
97 | 97 | editor.on( 'preinit', function() {
|
98 | 98 | var DOM = tinymce.DOM;
|
99 | 99 |
|
| 100 | + editor.on( 'mousedown click', function( event ) { |
| 101 | + if ( event.target.getAttribute( 'contenteditable' ) === 'true' ) { |
| 102 | + if ( event.target !== editor.selection.getNode() ) { |
| 103 | + setTimeout( function() { |
| 104 | + editor.selection.placeCaretAt( event.clientX, event.clientY ); |
| 105 | + }, 50 ); |
| 106 | + } |
| 107 | + } |
| 108 | + }, true ); |
| 109 | + |
100 | 110 | editor.addButton( 'block', {
|
101 | 111 | icon: 'gridicons-posts',
|
102 | 112 | tooltip: 'Add Block',
|
|
591 | 601 | }
|
592 | 602 |
|
593 | 603 | var hidden = true;
|
594 |
| - var keypress = false; |
595 | 604 |
|
596 | 605 | editor.on( 'keydown', function( event ) {
|
597 |
| - keypress = true; |
598 |
| - |
599 | 606 | if ( ! isInputKeyEvent( event ) ) {
|
600 | 607 | return;
|
601 | 608 | }
|
602 | 609 |
|
603 |
| - // No typing directly on elements. |
604 |
| - if ( anchorNode.nodeType === 1 && ! isEmptySlot( anchorNode ) ) { |
605 |
| - event.preventDefault(); |
606 |
| - } else { |
607 |
| - hidden = true; |
608 |
| - } |
609 |
| - |
| 610 | + hidden = true; |
610 | 611 | insert = false;
|
611 | 612 | } );
|
612 | 613 |
|
613 |
| - editor.on( 'keyup', function( event ) { |
614 |
| - keypress = false; |
615 |
| - } ); |
616 |
| - |
617 |
| - editor.on( 'beforePastePreProcess beforeExecCommand', function( event ) { |
618 |
| - if ( anchorNode.nodeType === 1 && ! isEmptySlot( anchorNode ) ) { |
619 |
| - event.preventDefault(); |
620 |
| - } |
621 |
| - } ); |
622 |
| - |
623 |
| - editor.on( 'input', function( event ) { |
624 |
| - // Non key input (e.g. emoji). |
625 |
| - if ( keypress ) { |
626 |
| - return; |
627 |
| - } |
628 |
| - |
629 |
| - if ( anchorNode.nodeType === 1 && ! isEmptySlot( anchorNode ) ) { |
630 |
| - // Event not cancelable. :( |
631 |
| - // Let's see how this goes, it might be buggy. |
632 |
| - editor.undoManager.add(); |
633 |
| - editor.undoManager.undo(); |
634 |
| - } |
635 |
| - } ); |
636 |
| - |
637 | 614 | editor.on( 'mousedown touchstart', function() {
|
638 | 615 | hidden = false;
|
639 | 616 | insert = false;
|
|
698 | 675 | addfigcaption();
|
699 | 676 | event.preventDefault();
|
700 | 677 | }
|
701 |
| - |
702 |
| - if ( keyCode === VK.BACKSPACE ) { |
703 |
| - var caretEl = editor.selection.getNode(); |
704 |
| - |
705 |
| - if ( caretEl.nodeName !== 'FIGCAPTION' ) { |
706 |
| - removeBlock(); |
707 |
| - event.preventDefault(); |
708 |
| - } else { |
709 |
| - var range = editor.selection.getRng(); |
710 |
| - |
711 |
| - if ( range.collapsed && range.startOffset === 0 ) { |
712 |
| - removefigcaption(); |
713 |
| - event.preventDefault(); |
714 |
| - } |
715 |
| - } |
716 |
| - } |
717 |
| - |
718 |
| - if ( keyCode === VK.LEFT ) { |
719 |
| - var range = editor.selection.getRng(); |
720 |
| - |
721 |
| - if ( keyCode === VK.LEFT && range.startOffset === 0 ) { |
722 |
| - event.preventDefault(); |
723 |
| - } |
724 |
| - } |
725 | 678 | } else {
|
726 | 679 | if ( keyCode === VK.BACKSPACE ) {
|
727 | 680 | var selection = window.getSelection();
|
|
769 | 722 | metaCount = 0;
|
770 | 723 | } );
|
771 | 724 |
|
772 |
| - editor.on( 'dragstart', function( event ) { |
773 |
| - var block = getSelectedBlock(); |
774 |
| - |
775 |
| - if ( block.nodeName === 'FIGURE' ) { |
776 |
| - event.preventDefault(); |
777 |
| - } |
778 |
| - } ); |
779 |
| - |
780 | 725 | editor.on( 'nodeChange', function() {
|
781 | 726 | editor.$( editor.getBody() ).children().attr( 'data-mce-selected', null );
|
782 | 727 | editor.$( getSelectedBlock() ).attr( 'data-mce-selected', 'true' );
|
|
0 commit comments