Skip to content

Commit

Permalink
Add superscript and subscript tags to text editor (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
mako321 authored Oct 18, 2023
1 parent 900b402 commit 780d317
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/Services/HeadlessH5PService.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,44 @@ public function getLibraries(string $machineName = null, string $major_version =

if ($machineName) {
$defaultLang = $this->getEditor()->getLibraryLanguage($machineName, $major_version, $minor_version, $lang);
return $this->getEditor()->getLibraryData($machineName, $major_version, $minor_version, $lang, '', $libraries_url, $defaultLang);
$data = $this->getEditor()->getLibraryData($machineName, $major_version, $minor_version, $lang, '', $libraries_url, $defaultLang);
$this->addMoreHtmlTags($data->semantics);

return $data;
}

return collect($this->getEditor()->getLibraries())
->each(fn($item) => $item
$libraries = collect($this->getEditor()->getLibraries());
foreach ($libraries as $library) {
$this->addMoreHtmlTags($library->semantics);
$library
->append('contentsCount')
->append('requiredLibrariesCount')
);
->append('requiredLibrariesCount');
}

return $libraries;
}

private function addMoreHtmlTags($semantics) {
foreach ($semantics as $field) {
while ($field->type === 'list') {
$field = $field->field;
}

if ($field->type === 'group') {
$this->addMoreHtmlTags($field->fields);
continue;
}

if ($field->type === 'text' && isset($field->widget) && $field->widget === 'html') {
if (!isset($field->tags)) {
$field->tags = [];
}
$field->tags = array_merge($field->tags, [
'sup',
'sub',
]);
}
}
}

public function getEditorSettings($content = null): array
Expand Down

0 comments on commit 780d317

Please sign in to comment.