1/** 2 * Registers Blocks in the text editor as QuickTag Buttons. 3 * 4 * @since 1.9.6 5 * 6 * @author ConvertKit 7 */ 8 9for (const block in convertkit_quicktags) { 10 convertKitQuickTagRegister(convertkit_quicktags[block]); 11} 12 13/** 14 * Registers the given block as a Quick Tag, with a button in 15 * the Text Editor toolbar. 16 * 17 * @since 1.9.6 18 * 19 * @param {Object} block Block. 20 */ 21function convertKitQuickTagRegister(block) { 22 QTags.addButton('convertkit-' + block.name, block.title, function () { 23 // Perform an AJAX call to load the modal's view. 24 fetch( 25 convertkit_admin_tinymce.ajaxurl + 26 '/' + 27 block.name + 28 '/' + 29 'quicktags', 30 { 31 method: 'GET', 32 headers: { 33 'X-WP-Nonce': convertkit_admin_tinymce.nonce, 34 }, 35 } 36 ) 37 .then(function (response) { 38 return response.json(); 39 }) 40 .then(function (result) { 41 // Show Modal. 42 convertKitQuickTagsModal.open(); 43 44 // Get Modal. 45 const quicktagsModal = document.querySelector( 46 'div.convertkit-quicktags-modal div.media-modal.wp-core-ui' 47 ), 48 quicktagsModalHeader = quicktagsModal.querySelector( 49 'div.media-frame-title' 50 ), 51 quicktagsModalFooter = quicktagsModal.querySelector( 52 'div.media-frame-toolbar div.media-toolbar' 53 ); 54 55 // Resize Modal so it's not full screen. 56 quicktagsModal.style.width = block.modal.width + 'px'; 57 quicktagsModal.style.height = 58 block.modal.height + 59 quicktagsModalHeader.offsetHeight + 60 quicktagsModalFooter.offsetHeight + 61 'px'; // Prevents a vertical scroll bar. 62 63 // Set Title. 64 document.querySelector( 65 '#convertkit-quicktags-modal .media-frame-title h1' 66 ).textContent = block.title; 67 68 // Inject HTML into modal. 69 document.querySelector( 70 '#convertkit-quicktags-modal .media-frame-content' 71 ).innerHTML = result; 72 73 // Initialize tabbed interface. 74 convertKitTabsInit(); 75 76 // Listen for color input changes. 77 convertKitColorInputInit(); 78 79 // Initialize conditional fields. 80 convertKitConditionallyDisplayTinyMCEModalFields(); 81 82 // Listen for field changes. 83 convertKitConditionalFieldsInit(); 84 85 // Bind refresh resource event listeners. 86 convertKitRefreshResourcesInitEventListeners(); 87 }) 88 .catch(function (error) { 89 console.error(error); 90 }); 91 }); 92}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.