public function getDefaultAttributes()
{
- return array_merge(parent::getDefaultAttributes(), ["add_label" => __('Nouveau chapître')]);
+ return array_merge(parent::getDefaultAttributes(), ["add_label" => __('Nouveau chapitre')]);
+ }
+
+ public function filterValue($value)
+ {
+ if (!$value) {
+ return $value;
+ }
+ $v = json_decode($value, true);
+ if (!$v) {
+ return $value;
+ }
+ $res = [];
+ foreach ($v as $k=>$chapter) {
+ $chapter['type'] = 'regular';
+ $chapter['label'] = trim($chapter['label']);
+ if ($chapter['label'] === '----') {
+ $chapter['label'] = '';
+ $chapter['type'] = 'separator';
+ } else if ($chapter['label'] === '--') {
+ $chapter['label'] = '';
+ $chapter['type'] = 'forcecut';
+ } else if ($chapter['label'] === '++') {
+ $chapter['label'] = '';
+ $chapter['type'] = 'nocut';
+ } else if (str_starts_with($chapter['label'], '!!!')) {
+ $chapter['label'] = substr($chapter['label'], 3);
+ $chapter['type'] = 'column_head';
+ }
+ $res[$k]=$chapter;
+ }
+
+
+ return parent::filterValue(json_encode($res));
}
}
'separator' => __('Séparateur') . ' (----)',
]
]);
- $this->addField('level', FluidbookChapterLevel::class, __('Niveau'), ['default' => 1, 'min' => 1, 'max' => 4]);
+ $this->addField('level', FluidbookChapterLevel::class, __('Niveau'), ['default' => 1, 'min' => 0, 'max' => 3]);
}
}
display: inline-block;
}
- .item[data-level="1"] {
+ .item[data-level="0"] {
padding-left: 0;
}
- .item[data-level="2"] {
+ .item[data-level="1"] {
padding-left: 20px;
}
- .item[data-level="3"] {
+ .item[data-level="2"] {
padding-left: 40px;
}
- .item[data-level="4"] {
+ .item[data-level="3"] {
padding-left: 60px;
}
</style>