-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ce6130d
Showing
11 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.idea | ||
vendor | ||
composer.lock | ||
node_modules | ||
.phpunit.result.cache | ||
.php-cs-fixer.cache | ||
app | ||
reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
$finder = Symfony\Component\Finder\Finder::create() | ||
->in([ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
]) | ||
->name('*.php') | ||
->notName('*.blade.php') | ||
->ignoreDotFiles(true) | ||
->ignoreVCS(true); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRules([ | ||
'@PSR12' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'ordered_imports' => ['sort_algorithm' => 'alpha'], | ||
'no_unused_imports' => true, | ||
'not_operator_with_successor_space' => true, | ||
'trailing_comma_in_multiline' => true, | ||
'phpdoc_scalar' => true, | ||
'unary_operator_spaces' => true, | ||
'binary_operator_spaces' => true, | ||
'blank_line_before_statement' => [ | ||
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], | ||
], | ||
'phpdoc_single_line_var_spacing' => true, | ||
'phpdoc_var_without_name' => true, | ||
'method_argument_space' => [ | ||
'on_multiline' => 'ensure_fully_multiline', | ||
'keep_multiple_spaces_after_comma' => true, | ||
], | ||
'single_trait_insert_per_statement' => true, | ||
]) | ||
->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) Danil Shutsky | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# CKEditor field for [MoonShine Laravel admin panel](https://moonshine.cutcode.dev) | ||
|
||
## Documentation | ||
[Read CKEditor field in Official MoonShine Documentation](https://moonshine.cutcode.dev/section/fields-wysiwyg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "moonshine/ckeditor", | ||
"description": "CKEditor for MoonShine", | ||
"keywords": ["moonshine", "ckeditor"], | ||
"type": "library", | ||
"homepage": "https://moonshine.cutcode.dev", | ||
"license": "MIT", | ||
"support": { | ||
"issues": "https://github.com/moonshine-software/ckeditor/issues", | ||
"source": "https://github.com/moonshine-software/ckeditor" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Danil Shutsky", | ||
"email": "[email protected]", | ||
"homepage": "https://cutcode.dev" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.0|^8.1|^8.2", | ||
"ext-curl": "*", | ||
"ext-json": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5.8", | ||
"mockery/mockery": "^1.4.4", | ||
"phpstan/phpstan": "^1.4.7", | ||
"orchestra/testbench": "^4.0|^5.0|^6.0|^7.0|^8.0", | ||
"brianium/paratest": "^6.8" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MoonShine\\CKEditor\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"MoonShine\\CKEditor\\Tests\\": "tests/", | ||
"MoonShine\\CKEditor\\Database\\Factories\\": "database/factories/" | ||
} | ||
}, | ||
"conflict": { | ||
"moonshine/moonshine": "<1.52" | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/phpunit", | ||
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"CKEditorServiceProvider" | ||
] | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<x-moonshine::form.textarea | ||
:attributes="$element->attributes()->merge([ | ||
'id' => 'ckeditor_' . $item->getKey() . '_' . $element->id(), | ||
'name' => $element->name() | ||
])" | ||
>{!! $element->formViewValue($item) ?? '' !!}</x-moonshine::form.textarea> | ||
|
||
<script> | ||
CKEDITOR.ClassicEditor.create(document.getElementById("ckeditor_{{ $item->getKey() }}_{{ $element->id() }}"), { | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html#extended-toolbar-configuration-format | ||
toolbar: { | ||
items: [ | ||
'heading', '|', | ||
'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript', 'removeFormat', '|', | ||
'bulletedList', 'numberedList', 'todoList', | ||
'outdent', 'indent', '|', | ||
'undo', 'redo', | ||
'-', | ||
'exportPDF','exportWord', '|', | ||
'findAndReplace', '|', | ||
'fontSize', 'fontColor', 'fontBackgroundColor', | ||
'alignment', '|', | ||
'link', 'insertImage', 'blockQuote', 'insertTable', 'mediaEmbed', 'codeBlock', 'htmlEmbed', '|', | ||
'specialCharacters', 'horizontalLine', 'sourceEditing' | ||
], | ||
shouldNotGroupWhenFull: true | ||
}, | ||
// Changing the language of the interface requires loading the language file using the <script> tag. | ||
// language: 'es', | ||
list: { | ||
properties: { | ||
styles: true, | ||
startIndex: true, | ||
reversed: true | ||
} | ||
}, | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/headings.html#configuration | ||
heading: { | ||
options: [ | ||
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' }, | ||
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' }, | ||
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }, | ||
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' }, | ||
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' }, | ||
{ model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' }, | ||
{ model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6' } | ||
] | ||
}, | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/editor-placeholder.html#using-the-editor-configuration | ||
placeholder: 'Welcome to CKEditor 5!', | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-family-feature | ||
fontFamily: { | ||
options: [ | ||
'default', | ||
'Arial, Helvetica, sans-serif', | ||
'Courier New, Courier, monospace', | ||
'Georgia, serif', | ||
'Lucida Sans Unicode, Lucida Grande, sans-serif', | ||
'Tahoma, Geneva, sans-serif', | ||
'Times New Roman, Times, serif', | ||
'Trebuchet MS, Helvetica, sans-serif', | ||
'Verdana, Geneva, sans-serif' | ||
], | ||
supportAllValues: true | ||
}, | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-size-feature | ||
fontSize: { | ||
options: [ 10, 12, 14, 'default', 18, 20, 22 ], | ||
supportAllValues: true | ||
}, | ||
// Be careful with the setting below. It instructs CKEditor to accept ALL HTML markup. | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html#enabling-all-html-features | ||
htmlSupport: { | ||
allow: [ | ||
{ | ||
name: /.*/, | ||
attributes: true, | ||
classes: true, | ||
styles: true | ||
} | ||
] | ||
}, | ||
codeBlock: { | ||
languages: [ | ||
{ language: 'php', label: 'Php' }, | ||
{ language: 'js', label: 'Js' } | ||
] | ||
}, | ||
// Be careful with enabling previews | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html#content-previews | ||
htmlEmbed: { | ||
showPreviews: true | ||
}, | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/link.html#custom-link-attributes-decorators | ||
link: { | ||
decorators: { | ||
addTargetToExternalLinks: true, | ||
defaultProtocol: 'https://', | ||
toggleDownloadable: { | ||
mode: 'manual', | ||
label: 'Downloadable', | ||
attributes: { | ||
download: 'file' | ||
} | ||
} | ||
} | ||
}, | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/mentions.html#configuration | ||
mention: { | ||
feeds: [ | ||
{ | ||
marker: '@', | ||
feed: [ | ||
'@apple', '@bears', '@brownie', '@cake', '@cake', '@candy', '@canes', '@chocolate', '@cookie', '@cotton', '@cream', | ||
'@cupcake', '@danish', '@donut', '@dragée', '@fruitcake', '@gingerbread', '@gummi', '@ice', '@jelly-o', | ||
'@liquorice', '@macaroon', '@marzipan', '@oat', '@pie', '@plum', '@pudding', '@sesame', '@snaps', '@soufflé', | ||
'@sugar', '@sweet', '@topping', '@wafer' | ||
], | ||
minimumCharacters: 1 | ||
} | ||
] | ||
}, | ||
simpleUpload: { | ||
// The URL that the images are uploaded to. | ||
uploadUrl: '{{ route('moonshine.attachments') }}', | ||
}, | ||
// The "super-build" contains more premium features that require additional configuration, disable them below. | ||
// Do not turn them on unless you read the documentation and know how to configure them and setup the editor. | ||
removePlugins: [ | ||
// These two are commercial, but you can try them out without registering to a trial. | ||
// 'ExportPdf', | ||
// 'ExportWord', | ||
'CKBox', | ||
'CKFinder', | ||
//'EasyImage', | ||
// This sample uses the Base64UploadAdapter to handle image uploads as it requires no configuration. | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/base64-upload-adapter.html | ||
// Storing images as Base64 is usually a very bad idea. | ||
// Replace it on production website with other solutions: | ||
// https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/image-upload.html | ||
// 'Base64UploadAdapter', | ||
'RealTimeCollaborativeComments', | ||
'RealTimeCollaborativeTrackChanges', | ||
'RealTimeCollaborativeRevisionHistory', | ||
'PresenceList', | ||
'Comments', | ||
'TrackChanges', | ||
'TrackChangesData', | ||
'RevisionHistory', | ||
'Pagination', | ||
'WProofreader', | ||
// Careful, with the Mathtype plugin CKEditor will not load when loading this sample | ||
// from a local file system (file://) - load this site via HTTP server if you enable MathType | ||
'MathType' | ||
] | ||
}); | ||
</script> | ||
|
||
<style> | ||
.ck-editor__editable { | ||
max-height: 400px; | ||
background-color: white!important; | ||
color: black!important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoonShine\CKEditor\Fields; | ||
|
||
use MoonShine\Fields\Textarea; | ||
|
||
final class CKEditor extends Textarea | ||
{ | ||
protected static string $view = 'moonshine-ckeditor::fields.ckeditor'; | ||
|
||
protected array $assets = [ | ||
'vendor/moonshine-ckeditor/js/ckeditor.js', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MoonShine\CKEditor\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
final class CKEditorServiceProvider extends ServiceProvider | ||
{ | ||
public function register(): void | ||
{ | ||
// | ||
} | ||
|
||
public function boot(): void | ||
{ | ||
$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'moonshine-ckeditor'); | ||
|
||
|
||
$this->publishes([ | ||
__DIR__ . '/../../public' => public_path('vendor/moonshine-ckeditor'), | ||
], ['moonshine-ckeditor-assets', 'laravel-assets']); | ||
} | ||
} |