Package com.atlassian.adf.model.mark
Class TextColor
- java.lang.Object
-
- com.atlassian.adf.model.mark.TextColor
-
- All Implemented Interfaces:
Element,Mark,FormattedTextMark,TextMark
@Documentation(state=REVIEWED, date="2023-07-26") public class TextColor extends Object implements FormattedTextMark
ThetextColormark adds<span style="color: #ff0000;">...</span>color styling. This mark applies toTextnodes and can only be combined with otherformatted-textmarks. As an additional restriction, it cannot be combined with alinkmark.Rendering colors with theme support
Colors are stored in a hexadecimal format, but need to be displayed differently depending on the current product theme, such as light and dark mode. Support for this is provided via a mapping from each hexadecimal color to a design token from the Atlassian Design System.Currently, such theming is only supported in the web user interface, where it is provided by the
@atlaskit/editor-palettepackage.Example
Java
p(text("Hello "),text("world").Text.textColor(String)textColor}("#97a0af"),text("!") );ADF
{ "type": "paragraph", "content": [ { "type": "text", "text": "Hello " }, { "type": "text", "text": "world", "marks": [ { "type": "textColor", "attrs": { "color": "#97a0af" } } ] }, { "type": "text", "text": "!" } ] }Result
Hello world!
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.adf.model.Element
Element.Key
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcolor()TextColorcolor(Color color)TextColorcolor(String color)TextColorcopy()Returns a deep copy of this element, including copies of any nodes or marks that it contains.StringelementType()Thetypevalue that identifies this element, such as"paragraph"or"strong".booleanequals(Object o)inthashCode()booleanisSupported()Indicates whether this element is fully supported by this library.protected FieldMapmapWithType()static TextColortextColor(Colors.Named color)static TextColortextColor(Color color)static TextColortextColor(String color)Map<String,?>toMap()Transforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.StringtoString()voidvalidate()Verifies that the node is well-formed (including the state of any descendents that it has).-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.atlassian.adf.model.Element
isSupported, validate
-
-
-
-
Method Detail
-
textColor
public static TextColor textColor(String color)
- Parameters:
color- a color defined in HTML hexadecimal format, for example#daa520. To display this color with correct contrast in different product themes, such as light and dark mode, use@atlaskit/editor-paletteto map this color to a design token from the Atlassian Design System.- Returns:
- a
textColormark for the given color
-
textColor
public static TextColor textColor(Colors.Named color)
-
copy
public TextColor copy()
Description copied from interface:ElementReturns a deep copy of this element, including copies of any nodes or marks that it contains. The copy will not necessarily be in exactly the same state as the original in some cases. For example, atextnode that is used inside acodeBlockwill have the ability to use marks on it disabled, but a copy made of the text node using this method will not similarly disallow marks unless it is also added to a content node with those same restrictions.Implementations notes:
- Implementations should narrow the return type.
- Implementations should
return thisif the element is immutable. The@Immutableannotation should be used on the class to offer additional confirmation of this intent. - Implementations should
return parse(toMap())if they have state. - While there may be cases where it is worthwhile to do something more efficient than
the conversion to a map and back, this is discouraged because it would add yet another
fragile piece of code that breaks when new data is added to the node. The
parseandtoMapmethods already have to be updated in these circumstances, so it makes sense to take advantage of that.
-
color
public String color()
-
elementType
public String elementType()
Description copied from interface:ElementThetypevalue that identifies this element, such as"paragraph"or"strong".- Specified by:
elementTypein interfaceElement
-
toMap
public Map<String,?> toMap()
Description copied from interface:ElementTransforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.
-
toString
public String toString()
-
mapWithType
protected FieldMap mapWithType()
-
isSupported
public boolean isSupported()
Description copied from interface:ElementIndicates whether this element is fully supported by this library. This library includes a small amount of support for preserving new, unrecognized node types during a round trip. These are represented by immutable placeholder objects that returnfalsefor this value.- Specified by:
isSupportedin interfaceElement- Returns:
truefor fully supported elements;falsefor immutable placeholders
-
-