Extract delegate for TrixEditorElement
#1132
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #1023
In preparation for #1128, this commit introduces a module-private
Delegate
class to serve as a representation of what form integrationrequires for the
<trix-editor>
custom element. The structure of theDelegate
class mirrors that of theTrixEditorElement
from which itscontents are extracted.
First, there are the properties that mimic those of most form controls,
including:
labels
form
name
value
defaultValue
type
With the exception of
labels
, property access is mostly proxiedthrough the associated
<input type="hidden">
element (accessed throughits own
inputElement
property).Next, the
Delegate
defines methods that correspond to the CustomElement lifecycle events, including:
connectedCallback
disconnectedCallback
setFormValue
The connected and disconnected callbacks mirror that of the
TrixEditorElement
itself. These callbacks attach and remove eventlisteners for
click
andreset
events.The
setFormValue
is named to correspond withElementInternals.setFormValue. Along with introducing this callback
method, this commit renames the
TrixEditorElement.setInputElementValue
method to
TrixEditorElement.setFormValue
.In addition to renaming
setInputElementValue
, this commit also definesTrixEditorElement.formResetCallback
(along with other emptycallbacks), then implements
TrixEditorElement.reset
as an alias. Thename mirrors the ElementInternals.formResetCallback.