-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Showing
7 changed files
with
129 additions
and
4 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
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
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,41 @@ | ||
<textarea id='ckeditor_{{ $field->id() }}' name="{{ $field->name() }}"> | ||
{!! $field->formViewValue($item) ?? '' !!} | ||
</textarea> | ||
|
||
<script> | ||
var editor_config = { | ||
path_absolute : "/", | ||
selector: 'textarea#ckeditor_{{ $field->id() }}', | ||
relative_urls: false, | ||
plugins: '{{ $field->plugins }}', | ||
toolbar: '{{ $field->toolbar }}', | ||
tinycomments_mode: 'embedded', | ||
tinycomments_author: '{{ $field->commentAuthor }}', | ||
mergetags_list: @json($field->mergeTags), | ||
file_picker_callback : function(callback, value, meta) { | ||
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth; | ||
var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight; | ||
var cmsURL = editor_config.path_absolute + 'laravel-filemanager?editor=' + meta.fieldname; | ||
if (meta.filetype == 'image') { | ||
cmsURL = cmsURL + "&type=Images"; | ||
} else { | ||
cmsURL = cmsURL + "&type=Files"; | ||
} | ||
tinyMCE.activeEditor.windowManager.openUrl({ | ||
url : cmsURL, | ||
title : 'Filemanager', | ||
width : x * 0.8, | ||
height : y * 0.8, | ||
resizable : "yes", | ||
close_previous : "no", | ||
onMessage: (api, message) => { | ||
callback(message.content); | ||
} | ||
}); | ||
} | ||
}; | ||
tinymce.init(editor_config); | ||
</script> |
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
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,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Leeto\MoonShine\Fields; | ||
|
||
final class TinyMce extends Field | ||
{ | ||
protected static string $view = 'moonshine::fields.tinymce'; | ||
|
||
public string $plugins = 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount checklist mediaembed casechange export formatpainter pageembed linkchecker a11ychecker tinymcespellchecker permanentpen powerpaste advtable advcode editimage tinycomments tableofcontents footnotes mergetags autocorrect typography inlinecss'; | ||
|
||
public string $toolbar = 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table mergetags | addcomment showcomments | spellcheckdialog a11ycheck typography | align lineheight | checklist numlist bullist indent outdent | emoticons charmap | removeformat'; | ||
|
||
public array $mergeTags = []; | ||
|
||
public string $commentAuthor = 'Author name'; | ||
|
||
public function getAssets(): array | ||
{ | ||
return [ | ||
"https://cdn.tiny.cloud/1/{$this->token()}/tinymce/{$this->version()}/tinymce.min.js" | ||
]; | ||
} | ||
|
||
public function mergeTags(array $mergeTags): self | ||
{ | ||
$this->mergeTags = $mergeTags; | ||
|
||
return $this; | ||
} | ||
|
||
public function commentAuthor(string $commentAuthor): self | ||
{ | ||
$this->commentAuthor = $commentAuthor; | ||
|
||
return $this; | ||
} | ||
|
||
public function plugins(string $plugins): self | ||
{ | ||
$this->plugins = $plugins; | ||
|
||
return $this; | ||
} | ||
|
||
public function toolbar(string $toolbar): self | ||
{ | ||
$this->toolbar = $toolbar; | ||
|
||
return $this; | ||
} | ||
|
||
protected function token(): string | ||
{ | ||
return config('moonshine.tinymce.token', ''); | ||
} | ||
|
||
protected function version(): string | ||
{ | ||
return (string) config('moonshine.tinymce.version', 6); | ||
} | ||
} |
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
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