I’m using this example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover"/>
<meta name="description" content="Custom text editing using an HTML select box and some radio buttons."/>
<link rel="stylesheet" href="../assets/css/style.css"/>
<!-- Copyright 1998-2023 by Northwoods Software Corporation. -->
<title>Text Editing Examples</title>
</head>
<body>
<!-- This top nav is not part of the sample code -->
<nav id="navTop" class="w-full z-30 top-0 text-white bg-nwoods-primary">
<div class="w-full container max-w-screen-lg mx-auto flex flex-wrap sm:flex-nowrap items-center justify-between mt-0 py-2">
<div class="md:pl-4">
<a class="text-white hover:text-white no-underline hover:no-underline
font-bold text-2xl lg:text-4xl rounded-lg hover:bg-nwoods-secondary " href="../">
<h1 class="my-0 p-1 ">GoJS</h1>
</a>
This file has been truncated. show original
I think I minimally pulled the “customText” part into my code correctly.
As soon as I click on the text block , however, I keep getting ‘TypeError: undefined is not a function’ in Chrome.
It happens right after calling "doActivate()" on customText.
My html div does appear on screen in the right place
Stack trace:
lh.
doActivate (go-debug.js:12156)
Ze.doMouseUp (go-debug.js:12415)
u.doMouseUp (go-debug.js:13966)
a.Pp (go-debug.js:13709)
I did an unminify.com pass on go-debug.js to see if it would help figure out what go is trying to do:
If I look in Chrome, “c” seems to be my HTML Div element I put on the page.
And it is true, it does NOT have “select()” method.
c.style.position = "absolute";
c.style.zIndex = 100;
c.className = "start";
c.textEditingTool = this;
c.qK = k;
if (d && void 0 !== c.onActivate) c.onActivate();
this.nh = c;
c.focus();
<font color="#ff0000"><b>c.select() <-- dies here. Why is it calling select()?! </b></font>
}
}
}
Any ideas?
walter
January 27, 2015, 2:58pm
2
It’s assuming that the element is an HTMLInputElement, calling this method: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement.select
Apparently for 1.5 we have already improved the code to be:
if (typeof input.focus === ‘function’) input.focus();
if (typeof input.select === ‘function’) input.select();
If you have specified the text editor to be something other than an HTMLInputElement, I suppose you could implement focus() and select() methods on your element.
Sorry for the confusion.
Thanks
I wondered about that, but how is the sample working then?
oh-- unless it has the latest code?
I’ll grab the latest also.
I’m using the same html chunk as the example, just to see if I could get anything working.
That has < <span =“pl-ent” style=“line-height: 16.7999992370605px; -sizing: border-; color: rgb99, 163, 92; font-family: Consolas, ‘Liberation Mono’, Menlo, Courier, monospace; white-space: pre; : rgb255, 255, 255;”>div <span =“pl-e” style=“line-height: 16.7999992370605px; -sizing: border-; color: rgb121, 93, 163; font-family: Consolas, ‘Liberation Mono’, Menlo, Courier, monospace; white-space: pre; : rgb255, 255, 255;”>id= <span =“pl-s1” style=“line-height: 16.7999992370605px; -sizing: border-; color: rgb223, 80, 0; font-family: Consolas, ‘Liberation Mono’, Menlo, Courier, monospace; white-space: pre; : rgb255, 255, 255;”><span =“pl-pds” style="-sizing: border-;">"customTextEditor…
I put in the fake select() method, seems to fix it.
walter
January 27, 2015, 3:16pm
5
And I have back-ported the fixes into the 1.4.* stream, so in the future someone using a non-HTMLInputElement just won’t get their text selected. Unless they define the select method themselves, as you now have.