Plugin Directory

Changeset 2473064


Ignore:
Timestamp:
02/11/2021 12:42:30 PM (5 years ago)
Author:
amzimage
Message:

updated to version o.45

Location:
insert-amazon-images
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • insert-amazon-images/trunk/AmazonImages.php

    r2266096 r2473064  
    44Plugin Name: Insert Amz Images
    55Description: Display Amazon product images using the Amazon Product Advertising API.
    6 Version: 0.44
     6Version: 0.45
    77Date: May 16th, 2018
    88Author: AMZ Image
  • insert-amazon-images/trunk/js/manager.js

    r2266096 r2473064  
    2121    }
    2222
    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);
    2656        }
    2757    }, 1000);
     
    97127            }
    98128            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);
    101131            }
    102132            else {
     
    183213                            $(template).find('[data-price]').text(value.sale_price + ' ' + value.currency);
    184214                        }
    185                         else if(value.price) {
     215                        else if (value.price) {
    186216                            $(template).find('[data-price]').text(value.price + ' ' + value.currency);
    187217                        }
    188                         else{
     218                        else {
    189219                            $(template).find('[data-price]').text('not found.');
    190220                        }
  • insert-amazon-images/trunk/readme.txt

    r2266096 r2473064  
    33Donate link: https://amzimage.com/
    44Tags :  amazon, images, affiliate, associates, editor, insert
    5 Version: 0.44
     5Version: 0.45
    66Requires at least :  4.9
    77Tested up to :  5.2.3
    8 Stable tag :  4.4
     8Stable tag :  4.45
    99Requires PHP: 5.6
    1010Licence: GNU General Public License v3.0
     
    5959== Changelog ==
    6060
     61= 0.45 =
     62* Fixed issue with Gutenberg overlay
     63
    6164= 0.44 =
    6265* Add Amazon Product Advertising API 5.0 support
Note: See TracChangeset for help on using the changeset viewer.