Changeset 2473064
- Timestamp:
- 02/11/2021 12:42:30 PM (5 years ago)
- Location:
- insert-amazon-images
- Files:
-
- 3 added
- 3 edited
-
tags/0.45 (added)
-
tags/0.45/AmazonImages.php (added)
-
tags/0.45/readme.txt (added)
-
trunk/AmazonImages.php (modified) (1 diff)
-
trunk/js/manager.js (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
insert-amazon-images/trunk/AmazonImages.php
r2266096 r2473064 4 4 Plugin Name: Insert Amz Images 5 5 Description: Display Amazon product images using the Amazon Product Advertising API. 6 Version: 0.4 46 Version: 0.45 7 7 Date: May 16th, 2018 8 8 Author: AMZ Image -
insert-amazon-images/trunk/js/manager.js
r2266096 r2473064 21 21 } 22 22 23 setTimeout(function() { 24 if($('.edit-post-header-toolbar').length == 1) { 25 $('.edit-post-header-toolbar').append($('#insert-amazon-images-button')); 23 function getCaretPosition(editableDiv) { 24 var caretPos = 0, 25 sel, range; 26 if (window.getSelection) { 27 sel = window.getSelection(); 28 if (sel.rangeCount) { 29 range = sel.getRangeAt(0); 30 if (range.commonAncestorContainer.parentNode == editableDiv) { 31 caretPos = range.endOffset; 32 } 33 } 34 } else if (document.selection && document.selection.createRange) { 35 range = document.selection.createRange(); 36 if (range.parentElement() == editableDiv) { 37 var tempEl = document.createElement("span"); 38 editableDiv.insertBefore(tempEl, editableDiv.firstChild); 39 var tempRange = range.duplicate(); 40 tempRange.moveToElementText(tempEl); 41 tempRange.setEndPoint("EndToEnd", range); 42 caretPos = tempRange.text.length; 43 } 44 } 45 return caretPos; 46 } 47 48 var updateCaretPosition = function () { 49 console.log(getCaretPosition(this)); 50 }; 51 52 setTimeout(function () { 53 if ($('.edit-post-header-toolbar').length == 1) { 54 $('.edit-post-header-toolbar').after($('#insert-amazon-images-button')); 55 $('.block-editor-writing-flow').on("mousedown mouseup keydown keyup", updateCaretPosition); 26 56 } 27 57 }, 1000); … … 97 127 } 98 128 else if (block_editor.length > 0) { 99 let block = wp.blocks.createBlock( 'core/paragraph', { content: image_html_template });100 wp.data.dispatch( 'core/editor' ).insertBlocks( block);129 let block = wp.blocks.createBlock('core/paragraph', { content: image_html_template }); 130 wp.data.dispatch('core/editor').insertBlocks(block); 101 131 } 102 132 else { … … 183 213 $(template).find('[data-price]').text(value.sale_price + ' ' + value.currency); 184 214 } 185 else if (value.price) {215 else if (value.price) { 186 216 $(template).find('[data-price]').text(value.price + ' ' + value.currency); 187 217 } 188 else {218 else { 189 219 $(template).find('[data-price]').text('not found.'); 190 220 } -
insert-amazon-images/trunk/readme.txt
r2266096 r2473064 3 3 Donate link: https://amzimage.com/ 4 4 Tags : amazon, images, affiliate, associates, editor, insert 5 Version: 0.4 45 Version: 0.45 6 6 Requires at least : 4.9 7 7 Tested up to : 5.2.3 8 Stable tag : 4.4 8 Stable tag : 4.45 9 9 Requires PHP: 5.6 10 10 Licence: GNU General Public License v3.0 … … 59 59 == Changelog == 60 60 61 = 0.45 = 62 * Fixed issue with Gutenberg overlay 63 61 64 = 0.44 = 62 65 * Add Amazon Product Advertising API 5.0 support
Note: See TracChangeset
for help on using the changeset viewer.