0

I have Textbox with text "This is google.com", I want to set hyper link to only word "google.com" not the whole textbox text. How do I set/get hyper link to the substring?

var canvas = new fabric.Canvas('c');

var urlText = new fabric.Textbox("This is google.com", {
});

urlText.setSelectionStyles({ underline: true }, 8, 18)
urlText.setSelectionStyles({linkURL: "https://www.google.com/"}, 2, 4)
urlText.setSelectionStyles({linkName:"google.com"}, 8, 18)
urlText.setSelectionStyles({fill:"rgba(0,0,255,1)"}, 8, 18)
canvas.add(urlText);
canvas {
    border: 1px solid #999;
}
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas id="c" width="1000" height="500"></canvas>

Can you please help me out to get clickable event on google.com?

Thanks. Any help will be appreciated.

Yuyutsu
  • 2,509
  • 22
  • 38
  • ok this is not straight forward, but maybe something can be done – AndreaBogazzi Sep 04 '18 at 05:21
  • Hi @AndreaBogazzi, is there is anyway to get character index without editing mode? currently, I am getting character index and line number using get2DCursorLocation but only in editing mode. with the help of character index. I am able to find character style. – Yuyutsu Sep 04 '18 at 06:37

0 Answers0