What is a TextEditorElement?


#1

I’m trying to fix a deprecation of TextEditor::getFirstVisibleScreenRow. I am told to use TextEditorElement::getFirstVisibleScreenRow instead.

What is a TextEditorElement? The api mentions TextEditorView but there is no such thing anymore. An api search for TextEditorElement returns nothing.

I thought that a atom-text-editor, a custom html element, was the TextEditor now. If so then what is a TextEditorElement?

P.S. If we are expected to get our packages up to 1.0 then the api docs should be 1.0 first. It isn’t fair.


#2

It is a method of the view returned by atom.views.getView(textEditor). I don’t think the TextEditorElement is anywhere in the docs.


#3

I’m confused. I thought views were only related to space-pen. So getViews is still in 1.0?

Edit: In other words shouldn’t it be called getElement? And, I see object as the class in the inspector for editors. I assumed that was an element.


#4

There is still a model/view separation to the Atom architecture, just that the view is no longer part of the public API to force all interactions to go through the model. While it is an “element” physically, logically it is a view in the model/view-style architecture. Ultimately, they went with getView referring to the role the item returned plays in the system rather than referring to its most likely implementation.


#5

So what does the class TextEditor represent, and why does it appear as a type object in the inspector?


#6

The TextEditor class is the model in the model/view architecture. I don’t know why it appears one way or another in the inspector.


#7

That makes sense, almost. The view object name was changed from view to element. So neither class has model or view in the name. And you get the element with getViews. I think someone was high somewhere at Github. I don’t mean to be demeaning. I used to be a card-carrying hippie.


#8

No names were changed. TextEditorView still exists. TextEditorElement is the replacement. Just because a class is called FooElement doesn’t mean it isn’t a view. Something isn’t a view because of its name, it’s a view because of its intention (or purpose if you prefer).

As @leedohm has pointed out several times, we’re still using a model-view architecture…


#9

It is deprecated. My issue here was meant to be about 1.0.

I understand that. I was just bitching about the confusing nomenclature.


#10

@thomasjo What’s the plan going forward regarding how Views are created/customised? I notice that as of 0.211.0 The TextEditorElement.createSpacePenShim method isn’t being called.

As a new comer to Atom, I was liking how I could read a template/declarative view in the TextEditorView.


#11

@kierans777, you can see the plan for a view system as it evolves by subscribing here: