I have below code which will fetch the text from json & onclick text , display pop up box in page.... Now i need to give options to change font-family, font color....
But Adding the code in the place of Content is going to be extremely difficult....
Is there any way so that i can improve code structure or write same code in another way ?
JSON :
{
"font" : "Arian",
"x" : 201,
"y" : 461,
"src" : "180ef82d1.otf",
"width" : 679,
"type" : "text",
"text" : "Good Food",
"name" : "edit_good_1"
}
script
const lightId = 'light' + layer.name
const lightIdString = '#' + lightId
$('.container').append(
'<a id ="' + layer.name + '" onclick="openPopUp(' + lightId + ')"' +
'<div class="txtContainer" contenteditable="true" ' +
'style="' +
'left: ' + layer.x + 'px; ' +
'top: ' + layer.y + 'px; ' +
'">' + layer.text + '</div></a>' +
'<div id="light' + layer.name + '" class="white_content" style="' +
'top: ' + layer.y + 'px; ' + '"> content <a href="javascript:void(0)" ' +
'onclick="closePopUp(' + lightId + ')">Close</a></div> <div>'
);
document.getElementById(lightId).style.left = layer.x + document.getElementById(layer.name).offsetWidth + 'px'
codepen : https://codepen.io/kidsdial/pen/OGbGwN