text.textContent

You know how you have a text object, you seem to be able to refer to the value of that text object by typing “textName.textContent.”

You can type anything in the text object, and then click play with a default script that says, “window.alert(text.textContent))” and it’ll send an alert with the value of the text.

I literally just found that out, and I can’t find it anywhere in the reference. Is this a built-in variable, or just a normale javascript thing?

4 Likes

huh, never knew that. it’s probably a wick-exclusive thing because the text is the editor’s own thing, if you know what i mean. maybe the text is from a js library, so if that’s the case, anything using the library gets that variable i guess.

1 Like

dom node.textContent is a pure js property
I had’n tried yet to use it to retrieve the string in wickeditor
nice finding

2 Likes

It’s a normal javascript thing. I think there are other two very similar but different javascript methods that might work as well, innerHTML and innerText. innerHTML, depending on the situation, is not recommended as it can result in some security risks.

Wick Editor text objects aren’t HTML nodes, so that isn’t the correct property. It may have the same property name, but it’s not for the same object. Since Wick text objects are exclusive to Wick Editor, the textContent property that Hanzoh is talking about isn’t JavaScript/HTML.

1 Like

I found it when I was trying to define the value of the text. At first, I didn’t know this existed, so I tried “window.alert(text.value),” then I tried, “window.alert(text.setText()),” then lastly I tried, “window.alert(text.setText),” and then it send me an alert saying this:
Screenshot 2020-12-15 at 12.36.48 PM

That’s how I found the “text.textContent” thing (and it seems to work)
It may be a built-in thing that’s supposed to sound like the DOM textContent property

2 Likes

that is really useful to know.

Looking at the Wick source code, textContent is a variable that stores the text of a Path, which text boxes are a type of. I’m not sure if this is supposed to be accessible like this, but it’s interesting nonetheless. textContent is Wick-specific.

2 Likes