← All plugins
Code field for MoonShine Laravel admin panel
Code editor integration for MoonShine Laravel admin panel. This package adds syntax highlighting and advanced code editing capabilities powered by Ace editor. Features include support for multiple programming languages, customizable themes (light/dark), and a rich set of editor options to enhance your code editing experience.
Extends Textarea and has the same features
The package is based on the Ace library.
Compatibility
MoonShine
Moonshine Ace
Currently supported
>= v3.0
>= v1.0.0
yes
Installation
composer require moonshine/ace
composer require moonshine/ace
composer require moonshine/ace
composer require moonshine/ace
composer require moonshine/ace
Usage
use MoonShine\Ace\Fields\Code;
Code::make('Code')
use MoonShine\Ace\Fields\Code ;
Code :: make ( 'Code' )
use MoonShine\Ace\Fields\Code;
Code::make('Code')
use MoonShine\Ace\Fields\Code ;
Code :: make ( 'Code' )
use MoonShine\Ace\Fields\Code;
Code::make('Code')
Default config
To change the default settings, you need to publish the configuration file:
php artisan vendor:publish --tag="moonshine-ace-config"
php artisan vendor : publish -- tag = "moonshine-ace-config"
php artisan vendor:publish --tag="moonshine-ace-config"
php artisan vendor : publish -- tag = "moonshine-ace-config"
php artisan vendor:publish --tag="moonshine-ace-config"
You can also add additional options to the configuration file that will apply to all Code fields
'options' => [
'language' => 'javascript',
'options' => [
'useSoftTabs' => true,
'navigateWithinSoftTabs' => true,
],
'themes' => [
'light' => 'chrome',
'dark' => 'cobalt'
],
],
'options' => [
'language' => 'javascript' ,
'options' => [
'useSoftTabs' => true ,
'navigateWithinSoftTabs' => true ,
],
'themes' => [
'light' => 'chrome' ,
'dark' => 'cobalt'
],
],
'options' => [
'language' => 'javascript',
'options' => [
'useSoftTabs' => true,
'navigateWithinSoftTabs' => true,
],
'themes' => [
'light' => 'chrome',
'dark' => 'cobalt'
],
],
'options' => [
'language' => 'javascript' ,
'options' => [
'useSoftTabs' => true ,
'navigateWithinSoftTabs' => true ,
],
'themes' => [
'light' => 'chrome' ,
'dark' => 'cobalt'
],
],
'options' => [
'language' => 'javascript',
'options' => [
'useSoftTabs' => true,
'navigateWithinSoftTabs' => true,
],
'themes' => [
'light' => 'chrome',
'dark' => 'cobalt'
],
],
For more information, visit the Ace library.
Language
To change the language, use the language() method.
language(string $language)
language ( string $language)
language(string $language)
language ( string $language)
language(string $language)
Code::make('Code')
->language('php');
Code :: make ( 'Code' )
-> language ( 'php' );
Code::make('Code')
->language('php');
Code :: make ( 'Code' )
-> language ( 'php' );
Code::make('Code')
->language('php');
Themes
To change the themes, use the themes() method.
themes(string $light = null, string $dark = null)
themes ( string $light = null , string $dark = null )
themes(string $light = null, string $dark = null)
themes ( string $light = null , string $dark = null )
themes(string $light = null, string $dark = null)
Code::make('Code')
->themes('chrome', 'cobalt');
Code :: make ( 'Code' )
-> themes ( 'chrome' , 'cobalt' );
Code::make('Code')
->themes('chrome', 'cobalt');
Code :: make ( 'Code' )
-> themes ( 'chrome' , 'cobalt' );
Code::make('Code')
->themes('chrome', 'cobalt');
Options
The addOption() method allows you to add additional options for a field
addOption(string $name, string|int|float|bool $value)
addOption ( string $name, string|int|float|bool $value)
addOption(string $name, string|int|float|bool $value)
addOption ( string $name, string|int|float|bool $value)
addOption(string $name, string|int|float|bool $value)
Code::make('Code')
->addOption('showGutter', false)
Code :: make ( 'Code' )
-> addOption ( 'showGutter' , false )
Code::make('Code')
->addOption('showGutter', false)
Code :: make ( 'Code' )
-> addOption ( 'showGutter' , false )
Code::make('Code')
->addOption('showGutter', false)