Coupling of default SuperEditor to SingleColumnDocumentLayout and CommonOps (and how to get around it properly) #2356
Replies: 1 comment 6 replies
-
Thanks for filing this @JostSchenck First, I'll confirm that currently Now, to your specific question. I'm not sure what you mean by a "tree". But looking just at your reference to collapsing content, have you looked into creating custom components for that purpose? We have a ticket filed for certain collapsing behavior that I plan to work on, but haven't gotten to it yet. My expectation is that I'll be able to accomplish that with new components (widgets), rather than altering the whole document layout. Have you tried that? Beyond the collapsing question - can you provide any screenshots that demonstrate what you mean by a tree structure? PS - Our initial intention was for developers to do two things with this package. In cases where developers have use-cases within a kind of standard set of use-cases, they would use the |
Beta Was this translation helpful? Give feedback.
-
I encounter difficulties creating my own editor using the default
SuperEditor
as a basis; I get the impression that it is very tightly coupled to certain classes likeSingleColumnDocumentLayout
as well asCommonOps
that make it hard (at least to me) to replace or extend their functionalities without rewriting (and mostly copying) a lot of the defaultSuperEditor
's functionality. I wonder if I maybe misunderstand the way this toolkit should be used.My use case: I'm using super_editor to create an outline editor like experience -- like dynalist or workflowy, with paragraphs and their headings being indented and a tree structure being honored while editing; from outliners "folding" (collapsing and expanding) of nodes in the tree is expected. To realise this, the best way I could think of was by implementing my own
DocumentLayout
, which is very similar toSingleColumnDocumentLayout
, but organizes components in a tree of folding widgets according to the structure of the document. However, I can't use my own, very similarDocumentLayout
-implementation if I don't either write my own complete editor widget instead of the default SuperEditor, or fork super_editor, adding a parameter to it which takes a builder function for a document layout (idea by @jmatth in #1129), becauseSingleColumnDocumentLayout
is hardwired.A problem with similarly tight coupling is with
CommonEditorOperations
; many operations have to behave slightly dfferent with an outliner type of text editor. In the documentation to CommonEditorOperations, it says:This is something that I just don't get: If I create an
extension CommonOpsExtension on CommonEditorOperations
, I won't be able to reach members likecomposer
,document
oreditor
, because extensions in Dart just don't allow this. And if I do aclass MyCommonOps extends CommonEditorOperations
, I won't be able to inject it into SuperEditor, as this is hardwired as well (in _createEditContext ). So again, I either have to roll my own SuperEditor replacement, duplicating a lot of code, or fork.You guys are so passionate about composition that I am sure I'm missing something obvious. Can you enlighten me on what it is? @matthew-carroll @angelosilvestre @knopp
Beta Was this translation helpful? Give feedback.
All reactions