যেহেতু আপনি কেবল রেন্ডার বলেছেন, হ্যাঁ আপনি পারেন। আপনি এর লাইন বরাবর কিছু করতে পারেন:
function render(){
var inp = document.getElementById("box");
var data = `
<svg xmlns="http://www.w3.org/2000/svg" width="${inp.offsetWidth}" height="${inp.offsetHeight}">
<foreignObject width="100%" height="100%">
<div xmlns="http://www.w3.org/1999/xhtml"
style="font-family:monospace;font-style: normal; font-variant: normal; font-size:13.3px;padding:2px;;">
${inp.value} <i style="color:red">cant touch this</i>
</div>
</foreignObject>
</svg>`;
var blob = new Blob( [data], {type:'image/svg+xml'} );
var url=URL.createObjectURL(blob);
inp.style.backgroundImage="url("+URL.createObjectURL(blob)+")";
}
onload=function(){
render();
ro = new ResizeObserver(render);
ro.observe(document.getElementById("box"));
}
#box{
color:transparent;
caret-color: black;
font-style: normal;/*must be same as in the svg for caret to align*/
font-variant: normal;
font-size:13.3px;
padding:2px;
font-family:monospace;
}
<textarea id="box" oninput="render()">you can edit me!</textarea>
এটি এমন করে তোলে যাতে একটি
textareaএইচটিএমএল রেন্ডার করে! পুনরায় আকার দেওয়ার সময় ঝলকানি ছাড়াও, সরাসরি ক্লাস ব্যবহার করতে অক্ষমতা এবং ডিয়ার্টের ডিভের ঠিক
svgএকই রকম বিন্যাসের
textareaজন্য ক্যারেট সঠিকভাবে সাজানোর জন্য তা নিশ্চিত করা, এটি কাজ করে!