Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Trix Toolbar Button Subscript & Superscript #14185

Open
wants to merge 5 commits into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/forms/dist/components/rich-editor.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/forms/docs/02-fields/10-rich-editor.md
untillnesss marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ RichEditor::make('content')
'orderedList',
'redo',
'strike',
'sub',
'sup',
'underline',
'undo',
])
Expand Down
4 changes: 4 additions & 0 deletions packages/forms/resources/js/components/rich-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Trix.LineBreakInsertion.prototype.shouldInsertBlockBreak = function () {
}
}

Trix.config.textAttributes.sub = { tagName: 'sub', inheritable: true }

Trix.config.textAttributes.sup = { tagName: 'sup', inheritable: true }

export default function richEditorFormComponent({ state }) {
return {
state,
Expand Down
2 changes: 2 additions & 0 deletions packages/forms/resources/lang/en/components.php
untillnesss marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@
'ordered_list' => 'Numbered list',
'redo' => 'Redo',
'strike' => 'Strikethrough',
'sub' => 'Subscript',
'sup' => 'Superscript',
'underline' => 'Underline',
'undo' => 'Undo',
],
Expand Down
50 changes: 50 additions & 0 deletions packages/forms/resources/views/components/rich-editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,56 @@ class="-mx-4 h-4 dark:fill-current"
</x-filament-forms::rich-editor.toolbar.button>
@endif

@if ($hasToolbarButton('sub'))
<x-filament-forms::rich-editor.toolbar.button
data-trix-attribute="sub"
data-trix-key="-"
title="{{ __('filament-forms::components.rich_editor.toolbar_buttons.sub') }}"
tabindex="-1"
>
<svg
class="-mx-4 h-4 dark:fill-current"
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="sub"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
fill="currentColor"
d="M496 448h-16V304a16 16 0 0 0-16-16h-48a16 16 0 0 0-14.29 8.83l-16 32A16 16 0 0 0 400 352h16v96h-16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h96a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zM336 64h-67a16 16 0 0 0-13.14 6.87l-79.9 115-79.9-115A16 16 0 0 0 83 64H16A16 16 0 0 0 0 80v48a16 16 0 0 0 16 16h33.48l77.81 112-77.81 112H16a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h67a16 16 0 0 0 13.14-6.87l79.9-115 79.9 115A16 16 0 0 0 269 448h67a16 16 0 0 0 16-16v-48a16 16 0 0 0-16-16h-33.48l-77.81-112 77.81-112H336a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16z"
/>
</svg>
</x-filament-forms::rich-editor.toolbar.button>
@endif

@if ($hasToolbarButton('sup'))
<x-filament-forms::rich-editor.toolbar.button
data-trix-attribute="sup"
data-trix-key="+"
title="{{ __('filament-forms::components.rich_editor.toolbar_buttons.sup') }}"
tabindex="-1"
>
<svg
class="-mx-4 h-4 dark:fill-current"
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="sup"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
fill="currentColor"
d="M496 160h-16V16a16 16 0 0 0-16-16h-48a16 16 0 0 0-14.29 8.83l-16 32A16 16 0 0 0 400 64h16v96h-16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h96a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zM336 64h-67a16 16 0 0 0-13.14 6.87l-79.9 115-79.9-115A16 16 0 0 0 83 64H16A16 16 0 0 0 0 80v48a16 16 0 0 0 16 16h33.48l77.81 112-77.81 112H16a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h67a16 16 0 0 0 13.14-6.87l79.9-115 79.9 115A16 16 0 0 0 269 448h67a16 16 0 0 0 16-16v-48a16 16 0 0 0-16-16h-33.48l-77.81-112 77.81-112H336a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16z"
/>
</svg>
</x-filament-forms::rich-editor.toolbar.button>
@endif

@if ($hasToolbarButton('link'))
<x-filament-forms::rich-editor.toolbar.button
data-trix-attribute="href"
Expand Down
2 changes: 2 additions & 0 deletions packages/forms/src/Components/RichEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RichEditor extends Field implements Contracts\CanBeLengthConstrained, Cont
'orderedList',
'redo',
'strike',
'sub',
'sup',
'underline',
'undo',
];
Expand Down