toolbar.blade.php 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. @props(['toolbar' => '' ])
  2. @php
  3. use Malzariey\FilamentLexicalEditor\Enums\ToolbarItem;
  4. $item = $toolbar instanceof ToolbarItem ? $toolbar : ToolbarItem::from($toolbar);
  5. @endphp
  6. @switch($item)
  7. @case(ToolbarItem::UNDO)
  8. <x-filament-lexical-editor::toolbar-item ref="undo" disable-option="cannotUndo"
  9. title="{{ __('filament-lexical-editor::lexical-editor.undo') }}" shortcut="Ctrl+Z" icon="undo"/>
  10. @break
  11. @case(ToolbarItem::REDO)
  12. <x-filament-lexical-editor::toolbar-item ref="redo" disable-option="cannotRedo"
  13. title="{{ __('filament-lexical-editor::lexical-editor.redo') }}" shortcut="Ctrl+Y" icon="redo"/>
  14. @break
  15. @case(ToolbarItem::FONT_FAMILY)
  16. <div class="relative w-52 h-11 py-1">
  17. <select x-ref="fontFamily" class="toolbar-item spaced font-family"
  18. x-tooltip="'{{ __('filament-lexical-editor::lexical-editor.font_family') }}'">
  19. <option value="Arial" style="font-family: Arial,serif">Arial</option>
  20. <option value="Courier New" style="font-family: 'Courier New',serif">Courier New</option>
  21. <option value="Georgia" style="font-family: Georgia,serif">Georgia</option>
  22. <option value="Times New Roman" style="font-family: 'Times New Roman',serif">Times New Roman</option>
  23. <option value="Verdana" style="font-family: Verdana,serif">Verdana</option>
  24. </select>
  25. </div>
  26. @break
  27. @case(ToolbarItem::NORMAL)
  28. <x-filament-lexical-editor::toolbar-item active-option="blockType == 'paragraph'" ref="normal"
  29. title="{{ __('filament-lexical-editor::lexical-editor.normal') }}" shortcut="Ctrl+Alt+0"
  30. icon="paragraph"/>
  31. @break
  32. @case(ToolbarItem::H1)
  33. <x-filament-lexical-editor::toolbar-item active-option="blockType == 'h1'" ref="h1"
  34. title="{{ __('filament-lexical-editor::lexical-editor.heading_1') }}" shortcut="Ctrl+Alt+1"
  35. icon="h1"/>
  36. @break
  37. @case(ToolbarItem::H2)
  38. <x-filament-lexical-editor::toolbar-item ref="h2" active-option="blockType == 'h2'"
  39. title="{{ __('filament-lexical-editor::lexical-editor.heading_2') }}" shortcut="Ctrl+Alt+2"
  40. icon="h2"/>
  41. @break
  42. @case(ToolbarItem::H3)
  43. <x-filament-lexical-editor::toolbar-item ref="h3" active-option="blockType == 'h3'"
  44. title="{{ __('filament-lexical-editor::lexical-editor.heading_3') }}" shortcut="Ctrl+Alt+3"
  45. icon="h3"/>
  46. @break
  47. @case(ToolbarItem::H4)
  48. <x-filament-lexical-editor::toolbar-item ref="h4" active-option="blockType == 'h4'"
  49. title="{{ __('filament-lexical-editor::lexical-editor.heading_4') }}" shortcut="Ctrl+Alt+4"
  50. icon="h4"/>
  51. @break
  52. @case(ToolbarItem::H5)
  53. <x-filament-lexical-editor::toolbar-item ref="h5" active-option="blockType == 'h5'"
  54. title="{{ __('filament-lexical-editor::lexical-editor.heading_5') }}" shortcut="Ctrl+Alt+5"
  55. icon="h5"/>
  56. @break
  57. @case(ToolbarItem::H6)
  58. <x-filament-lexical-editor::toolbar-item ref="h6" active-option="blockType == 'h6'"
  59. title="{{ __('filament-lexical-editor::lexical-editor.heading_6') }}" shortcut="Ctrl+Alt+6"
  60. icon="h6"/>
  61. @break
  62. @case(ToolbarItem::BULLET)
  63. <x-filament-lexical-editor::toolbar-item ref="bullet" active-option="blockType == 'bullet'"
  64. title="{{ __('filament-lexical-editor::lexical-editor.bullet_list') }}" shortcut="Ctrl+Alt+7"
  65. icon="bullet-list"/>
  66. @break
  67. @case(ToolbarItem::NUMBERED)
  68. <x-filament-lexical-editor::toolbar-item ref="numbered" active-option="blockType == 'number'"
  69. title="{{ __('filament-lexical-editor::lexical-editor.numbered_list') }}" shortcut="Ctrl+Alt+8"
  70. icon="numbered-list"/>
  71. @break
  72. @case(ToolbarItem::QUOTE)
  73. <x-filament-lexical-editor::toolbar-item ref="quote" active-option="blockType == 'quote'"
  74. title="{{ __('filament-lexical-editor::lexical-editor.quote') }}" shortcut="Ctrl+Alt+Q" icon="quote"/>
  75. @break
  76. @case(ToolbarItem::CODE)
  77. <x-filament-lexical-editor::toolbar-item ref="code" active-option="blockType == 'code'"
  78. title="{{ __('filament-lexical-editor::lexical-editor.code_block') }}" shortcut="Ctrl+Alt+C"
  79. icon="code"/>
  80. @break
  81. @case(ToolbarItem::FONT_SIZE)
  82. <x-filament-lexical-editor::toolbar-item ref="decrement" class="font-decrement"
  83. title="{{ __('filament-lexical-editor::lexical-editor.decrease_font_size') }}" shortcut="Ctrl+Shift+,"
  84. icon-class="format" icon="minus-icon"/>
  85. <input type="number" title="Font size" x-ref="fontSize" class="toolbar-item font-size-input w-16 " min="8"
  86. max="72" value="15">
  87. <x-filament-lexical-editor::toolbar-item ref="increment" class="font-increment"
  88. title="{{ __('filament-lexical-editor::lexical-editor.increase_font_size') }}" shortcut="Ctrl+Shift+."
  89. icon-class="format" icon="add-icon"/>
  90. @break
  91. @case(ToolbarItem::BOLD)
  92. <x-filament-lexical-editor::toolbar-item active-option="isBold" ref="bold" title="{{ __('filament-lexical-editor::lexical-editor.bold') }}"
  93. shortcut="Ctrl+B" icon="bold"/>
  94. @break
  95. @case(ToolbarItem::ITALIC)
  96. <x-filament-lexical-editor::toolbar-item active-option="isItalic" ref="italic"
  97. title="{{ __('filament-lexical-editor::lexical-editor.italic') }}" shortcut="Ctrl+I" icon="italic"/>
  98. @break
  99. @case(ToolbarItem::UNDERLINE)
  100. <x-filament-lexical-editor::toolbar-item active-option="isUnderline" ref="underline"
  101. title="{{ __('filament-lexical-editor::lexical-editor.underline') }}" shortcut="Ctrl+U"
  102. icon="underline"/>
  103. @break
  104. @case(ToolbarItem::ICODE)
  105. <x-filament-lexical-editor::toolbar-item active-option="isCode" ref="icode"
  106. title="{{ __('filament-lexical-editor::lexical-editor.insert_code_block') }}" shortcut="Ctrl+Shift+C"
  107. icon="code"/>
  108. @break
  109. @case(ToolbarItem::LINK)
  110. <x-filament-lexical-editor::toolbar-item active-option="isLink" ref="link"
  111. title="{{ __('filament-lexical-editor::lexical-editor.insert_link') }}" shortcut="Ctrl+K"
  112. icon="link"/>
  113. @break
  114. @case(ToolbarItem::TEXT_COLOR)
  115. <x-filament-lexical-editor::text-color-dialog ref="text_color" icon="font-color"
  116. :title="__('filament-lexical-editor::lexical-editor.formatting_text_color')"/>
  117. @break
  118. @case(ToolbarItem::BACKGROUND_COLOR)
  119. <x-filament-lexical-editor::text-color-dialog ref="background_color" icon="bg-color"
  120. :title="__('filament-lexical-editor::lexical-editor.formatting_background_color')"/>
  121. @break
  122. @case(ToolbarItem::LOWERCASE)
  123. <x-filament-lexical-editor::toolbar-item active-option="isLowercase" ref="lowercase"
  124. title="{{ __('filament-lexical-editor::lexical-editor.lowercase') }}" shortcut="Ctrl+Shift+1"
  125. icon="lowercase"/>
  126. @break
  127. @case(ToolbarItem::UPPERCASE)
  128. <x-filament-lexical-editor::toolbar-item active-option="isUppercase" ref="uppercase"
  129. title="{{ __('filament-lexical-editor::lexical-editor.uppercase') }}" shortcut="Ctrl+Shift+2"
  130. icon="uppercase"/>
  131. @break
  132. @case(ToolbarItem::CAPITALIZE)
  133. <x-filament-lexical-editor::toolbar-item active-option="isCapitalize" ref="capitalize"
  134. title="{{ __('filament-lexical-editor::lexical-editor.capitalize') }}" shortcut="Ctrl+Shift+3"
  135. icon="capitalize"/>
  136. @break
  137. @case(ToolbarItem::STRIKETHROUGH)
  138. <x-filament-lexical-editor::toolbar-item active-option="isStrikethrough" ref="strikethrough"
  139. title="{{ __('filament-lexical-editor::lexical-editor.strikethrough') }}" shortcut="Ctrl+Shift+S"
  140. icon="strikethrough"/>
  141. @break
  142. @case(ToolbarItem::SUBSCRIPT)
  143. <x-filament-lexical-editor::toolbar-item active-option="isSubscript" ref="subscript"
  144. title="{{ __('filament-lexical-editor::lexical-editor.subscript') }}" shortcut="Ctrl+,"
  145. icon="subscript"/>
  146. @break
  147. @case(ToolbarItem::SUPERSCRIPT)
  148. <x-filament-lexical-editor::toolbar-item active-option="isSuperscript" ref="superscript"
  149. title="{{ __('filament-lexical-editor::lexical-editor.superscript') }}" shortcut="Ctrl+."
  150. icon="superscript"/>
  151. @break
  152. @case(ToolbarItem::CLEAR)
  153. <x-filament-lexical-editor::toolbar-item ref="clear" title="{{ __('filament-lexical-editor::lexical-editor.clear_text_formatting') }}"
  154. shortcut="Ctrl+/" icon="clear"/>
  155. @break
  156. @case(ToolbarItem::LEFT)
  157. <x-filament-lexical-editor::toolbar-item active-option="elementFormat == 'left'" ref="left" rtl-ref="right"
  158. title="{{ __('filament-lexical-editor::lexical-editor.left_align') }}"
  159. rtl-title="{{ __('filament-lexical-editor::lexical-editor.right_align') }}" shortcut="Ctrl+Shift+L"
  160. rtl-shortcut="Ctrl+Shift+R" icon="left-align" rtl-icon="right-align"/>
  161. @break
  162. @case(ToolbarItem::CENTER)
  163. <x-filament-lexical-editor::toolbar-item active-option="elementFormat == 'center'" ref="center"
  164. title="{{ __('filament-lexical-editor::lexical-editor.center_align') }}" shortcut="Ctrl+Shift+E"
  165. icon="center-align"/>
  166. @break
  167. @case(ToolbarItem::RIGHT)
  168. <x-filament-lexical-editor::toolbar-item active-option="elementFormat == 'right'" ref="right" rtl-ref="left"
  169. title="{{ __('filament-lexical-editor::lexical-editor.right_align') }}"
  170. rtl-title="{{ __('filament-lexical-editor::lexical-editor.left_align') }}" shortcut="Ctrl+Shift+R"
  171. rtl-shortcut="Ctrl+Shift+L" icon="right-align" rtl-icon="left-align"/>
  172. @break
  173. @case(ToolbarItem::JUSTIFY)
  174. <x-filament-lexical-editor::toolbar-item active-option="elementFormat == 'justify'" ref="justify"
  175. title="{{ __('filament-lexical-editor::lexical-editor.justify_align') }}" shortcut="Ctrl+Shift+J"
  176. icon="justify-align"/>
  177. @break
  178. @case(ToolbarItem::START)
  179. <x-filament-lexical-editor::toolbar-item active-option="elementFormat == 'start'" ref="start" rtl-ref="end"
  180. title="{{ __('filament-lexical-editor::lexical-editor.start_align') }}"
  181. rtl-title="{{ __('filament-lexical-editor::lexical-editor.end_align') }}" shortcut="Ctrl+Shift+["
  182. rtl-shortcut="Ctrl+Shift+]" icon="left-align" rtl-icon="right-align"/>
  183. @break
  184. @case(ToolbarItem::END)
  185. <x-filament-lexical-editor::toolbar-item active-option="elementFormat == 'end'" ref="end" rtl-ref="start"
  186. title="{{ __('filament-lexical-editor::lexical-editor.end_align') }}"
  187. rtl-title="{{ __('filament-lexical-editor::lexical-editor.start_align') }}" shortcut="Ctrl+Shift+]"
  188. rtl-shortcut="Ctrl+Shift+[" icon="right-align" rtl-icon="left-align"/>
  189. @break
  190. @case(ToolbarItem::INDENT)
  191. <x-filament-lexical-editor::toolbar-item ref="indent" title="{{ __('filament-lexical-editor::lexical-editor.indent') }}" shortcut="Ctrl+]"
  192. icon="indent"/>
  193. @break
  194. @case(ToolbarItem::OUTDENT)
  195. <x-filament-lexical-editor::toolbar-item ref="outdent" title="{{ __('filament-lexical-editor::lexical-editor.outdent') }}" shortcut="Ctrl+["
  196. icon="outdent"/>
  197. @break
  198. @case(ToolbarItem::HR)
  199. <x-filament-lexical-editor::toolbar-item ref="hr" title="{{ __('filament-lexical-editor::lexical-editor.hr') }}" shortcut=""
  200. icon="horizontal-rule"/>
  201. @break
  202. @case(ToolbarItem::IMAGE)
  203. <x-filament-lexical-editor::toolbar-item ref="image" title="{{ __('filament-lexical-editor::lexical-editor.image') }}" shortcut=""
  204. icon="image"/>
  205. @break
  206. @case(ToolbarItem::DIVIDER)
  207. <div class="divider"></div>
  208. @break
  209. @endswitch