Interface Document
- All Superinterfaces:
DomQueryable,EventTarget
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAmount of ticks an element remains 'active' for after being clicked -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStylesheet(@NotNull Stylesheet stylesheet) Adds a stylesheet to this document.voidAdopts a node if it belongs to another document instance.Creates a component node.createComponent(@Nullable net.kyori.adventure.text.Component component) Create a component node.createElement(@NotNull String tagName) Creates an element with a specifiedtagName.Create an<item>element.@NotNull StylesheetBuilderCreates a new style sheet builder.Creates an empty text nodecreateText(@Nullable String content) Creates a text node with the specifiedcontent@Nullable ElementGets the last clicked element that's still active.getBody()Gets the body element of the document.Get the root document element.@Nullable ElementgetElementById(String elementId) Gets the first descendant element of with the specifiedelementId@NotNull EventTargetGets the global event target.getHead()Get the<head>element@Nullable ElementGets the element the viewer's cursor is currently hovered over@Nullable StringGets the value of the optionGets a set of all option keys.@NotNull List<Stylesheet> Gets an unmodifiable list of stylesheets this document has.getView()Gets the document view.newCustomEvent(@NotNull String eventType) Create a new custom event.voidremoveOption(@NotNull String optionKey) Removes an option's value.voidSet an option's valueMethods inherited from interface com.juliewoolie.dom.DomQueryable
getElementsByClassName, getElementsByTagName, querySelector, querySelectorAllMethods inherited from interface com.juliewoolie.dom.event.EventTarget
addEventListener, dispatchEvent, getOnAddAttribute, getOnAddOption, getOnAppendChild, getOnAttributeChange, getOnClick, getOnClosing, getOnInput, getOnLoaded, getOnMouseEnter, getOnMouseExit, getOnMouseMove, getOnOptionChange, getOnRemoveAttribute, getOnRemoveChild, getOnRemoveOption, getOnRightClick, getOnSetAttribute, getOnSetOption, getOnSpawned, onAddAttribute, onAddOption, onAppendChild, onAttributeChange, onClick, onClosing, onInput, onLoaded, onMouseEnter, onMouseExit, onMouseMove, onOptionChange, onRemoveAttribute, onRemoveChild, onRemoveOption, onRightClick, onSetAttribute, onSetOption, onSpawned, removeEventListener
-
Field Details
-
ACTIVE_TICKS
static final int ACTIVE_TICKSAmount of ticks an element remains 'active' for after being clicked- See Also:
-
-
Method Details
-
getView
DocumentView getView()Gets the document view.- Returns:
- Document view, or
null, if the document hasn't been shown to a player yet.
-
getOption
-
setOption
Set an option's valueIf the option value is
nullor empty, then this acts the same as callingremoveOption(String)Will trigger an
EventTypes.MODIFY_OPTIONevent after changing the value.- Parameters:
optionKey- Option keyvalue- Option value- Throws:
NullPointerException- ifoptionKeyis null
-
removeOption
Removes an option's value.If the option already has no set value, this method does nothing. Otherwise, it will trigger an
EventTypes.MODIFY_OPTIONevent after changing the value.- Parameters:
optionKey- Option key- Throws:
NullPointerException- ifoptionKeyis null
-
getOptionKeys
-
createElement
Creates an element with a specifiedtagName.The type returned by this method corresponds to the specified tag name.
- Parameters:
tagName- Element's tag name.- Returns:
- Created element
- Throws:
NullPointerException- iftagNameisnull
-
createItemElement
-
createText
-
createText
-
createComponent
ComponentElement createComponent()Creates a component node.Component nodes differ from
TextNodes by the fact they use a fully-styled,Component. It is not recommended to use this, because it can conflict with document styling.Components are required in certain instances, like in item tooltips, where it's not possible to dissect each line of the tooltip, and instead, a component node is used for the content.
- Returns:
- Created component node
-
createComponent
Create a component node.Component nodes differ from
TextNodes by the fact they use a fully-styled,Component. It is not recommended to use this, because it can conflict with document styling.Components are required in certain instances, like in item tooltips, where it's not possible to dissect each line of the tooltip, and instead, a component node is used for the content.
- Parameters:
component- Node content- Returns:
- Created component node
-
newCustomEvent
Create a new custom event.Allows for creating and listening to custom event types with custom event properties.
Before the event can be dispatched, it must be initialized with
CustomEvent.initEvent(Element, boolean, boolean, Map).- Parameters:
eventType- Event Type- Returns:
- Created event
- Throws:
NullPointerException- IfeventTypeisnullIllegalArgumentException- IfeventTypeis an empty string
-
getActiveElement
Gets the last clicked element that's still active.When an element is clicked, it will remain active for
ACTIVE_TICKSticks.- Returns:
- Active element
-
getHoveredElement
Gets the element the viewer's cursor is currently hovered over- Returns:
- Hovered element
-
getBody
BodyElement getBody()Gets the body element of the document.The body element contains all the content of a document
- Returns:
- Document body
-
getDocumentElement
-
getHead
HeadElement getHead()Get the<head>element- Returns:
- Head element, or
null, if no header was declared.
-
getElementById
-
getGlobalTarget
Gets the global event target.The target returned by this method will be called after an event has finished propagation, unless the event has been cancelled.
This target will be invoked after ALL events.
Note that, calling the document's
EventTarget.addEventListener(String, EventListener)is not the same as calling the add event listener on the returned event target.- Returns:
- Global event target
-
adopt
Adopts a node if it belongs to another document instance.- Parameters:
node- Node to adopt.- Throws:
NullPointerException- ifnodeisnull
-
addStylesheet
Adds a stylesheet to this document.- Parameters:
stylesheet- Style sheet- Throws:
NullPointerException- ifstylesheetisnull
-
getStylesheets
Gets an unmodifiable list of stylesheets this document has.- Returns:
- Unmodifiable stylesheet list.
-
createStylesheet
Creates a new style sheet builder.When
StylesheetBuilder.build()is called on the returned sheet, the stylesheet is automatically added to this document's stylesheet list.- Returns:
- Created stylesheet builder
-