From 2217da01f7fc6ca69b471576c1665e1570c13f53 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 11 Feb 2019 08:30:12 -0500 Subject: [PATCH] finishing core functionality, still need minor styles and adjustments --- js/shortcodeBuilder.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index e4de8eb3..71d589ba 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -19,6 +19,10 @@ jQuery(function ($) { views : {list:[], isList: false}, blankstart : {list:[], isList: false}, } + function replaceNbsp(str) { + var re = new RegExp(String.fromCharCode(160), "g"); + return str.replace(re, " "); + } function generateShortCodeAttribute(state){ var attribute = $("
", { text : state.attribute, @@ -27,7 +31,7 @@ jQuery(function ($) { attribute.attr("data-"+state.type, state.id); attribute.attr("data-type", state.type); $("#"+state.type+"-string").empty(); - attribute.prepend( $("").html(" ")); + attribute.prepend( $("").html(" ")); $("#"+state.type+"-string").html(attribute); } function createShortcodeTile(state, elHook){ @@ -107,11 +111,12 @@ jQuery(function ($) { if( $(this).attr("id") == "copy-to-clipboard" ){ var tempInput = document.createElement("input"); tempInput.style = "position: absolute; left: -1000px; top: -1000px"; - tempInput.value = $("#shortcode-preview").text(); + tempInput.value = replaceNbsp($("#shortcode-preview").text()); document.body.appendChild(tempInput); tempInput.select(); document.execCommand("copy"); document.body.removeChild(tempInput); + $("#shortcode-no-space").children("span.shortcode-space").remove(); }else{ setupAttributes(); } -- 2.17.1