Paragraph
Paragraph is a built-in tool so users can add text to their designs. This tool is supported for all display modes.
Enable / Disable
Paragraph tool is enabled by default but you can choose to disable it.
unlayer.init({
tools: {
paragraph: {
enabled: false,
},
},
});
Default Values
Paragraph tool comes with the following default values. You can choose to change any of these.
Property | Default Value |
---|---|
textJson | {"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","text":"This is a new Paragraph block. Change the text.","type":"extended-text","version":1}],"format":"","indent":0,"type":"paragraph","version":1,"textFormat":0}],"format":"","indent":0,"type":"root","version":1}} |
textAlign | left |
fontSize | 14px |
color | #000000 |
lineHeight | 140% |
containerPadding | 10px |
fontFamily | Arial, Helvetica, sans-serif |
Here are a few examples on how to change these default values.
Default Text
unlayer.init({
tools: {
paragraph: {
properties: {
textJson: {
value:
'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","text":"My Paragraph","type":"extended-text","version":1}],"format":"","indent":0,"type":"paragraph","version":1,"textFormat":0}],"format":"","indent":0,"type":"root","version":1}}',
},
},
},
},
});
Font Size
unlayer.init({
tools: {
paragraph: {
properties: {
fontSize: {
editor: {
defaultValue: '16px',
},
},
},
},
},
});
Alignment
unlayer.init({
tools: {
paragraph: {
properties: {
textAlign: {
editor: {
defaultValue: 'right',
},
},
},
},
},
});
Color
unlayer.init({
tools: {
paragraph: {
properties: {
color: {
editor: {
defaultValue: '#ff0000',
},
},
},
},
},
});
Line Height
unlayer.init({
tools: {
paragraph: {
properties: {
lineHeight: {
editor: {
defaultValue: '140%',
},
},
},
},
},
});
Container Padding
unlayer.init({
tools: {
paragraph: {
properties: {
containerPadding: {
editor: {
defaultValue: '10px',
},
},
},
},
},
});
Font Family
unlayer.init({
tools: {
paragraph: {
properties: {
fontFamily: {
editor: {
defaultValue: {
value: "'Pacifico',cursive",
},
},
},
},
},
},
});
Please match exactly the value with one of those found in the font family configuration.
Migrating from Text Tool
If you're currently using the deprecated Text tool and need to maintain old functionality, you have two options:
Option 1: Duplicate the Text Tool
Find existing templates that use the Text tool and duplicate the tool:
- Find existing templates that use the Text tool
- Duplicate the Text tool
- The duplicated Text tool will retain its old functionality
Option 2: Lock Your Builder Version
Pin your builder to a stable version where the Text tool is still available. See the version locking documentation for detailed instructions.