Enh: Added AbstractRichTextEditor::layout in order to change richtext style

Enh: Added `block` type RichText for non focus menu style
This commit is contained in:
buddh4 2018-08-03 13:27:37 +02:00
parent 13ef8c2bca
commit c7b379f2b9
9 changed files with 30 additions and 13 deletions

View File

@ -50,7 +50,7 @@
"bower-asset/imagesloaded": "*",
"bower-asset/jquery-timeentry": "^2.0",
"bower-asset/caret.js": "0.2.2",
"npm-asset/humhub-prosemirror-richtext": "^1.0.6",
"npm-asset/humhub-prosemirror-richtext": "^1.0.7",
"npm-asset/at.js": "^1.5.1",
"yiisoft/yii2-queue": "~2.0.0",
"yiisoft/yii2-redis": "~2.0.0",

View File

@ -9,7 +9,8 @@ HumHub Change Log
- Fix: Click to topics lead on streams without topic filter throws javascript error. (https://github.com/humhub/humhub-modules-polls/issues/49)
- Fix: Existing files may cause NULL pointer exception
- Fix: Newly created profile fields cannot be updated
- Enh: Added `AbstractRichTextEditor::layout` in order to change richtext style
- Enh: Added `block` type RichText for non focus menu style
1.3.0-beta.3 (July 30, 2018)
-----------------------------

View File

@ -23,6 +23,7 @@ $submitUrl = Url::to(['/comment/comment/edit', 'id' => $comment->id, 'contentMod
<div class="comment-create-input-group">
<?= $form->field($comment, 'message')->widget(RichTextField::class, [
'id' => 'comment_input_'.$comment->id,
'layout' => RichTextField::LAYOUT_INLINE,
'placeholder' => Yii::t('CommentModule.views_edit', 'Edit your comment...'),
'focus' => true
])->label(false) ?>

View File

@ -23,6 +23,7 @@ $submitUrl = Url::to(['/comment/comment/post']);
<div class="comment-create-input-group">
<?= RichTextField::widget([
'id' => 'newCommentForm_' . $id,
'layout' => RichTextField::LAYOUT_INLINE,
'pluginOptions' => ['maxHeight' => '300px'],
'placeholder' => Yii::t('CommentModule.widgets_views_form', 'Write a new comment...'),
'name' => 'message'

View File

@ -46,11 +46,20 @@ use yii\helpers\Url;
*/
class AbstractRichTextEditor extends JsInputWidget
{
const LAYOUT_BLOCK = 'block';
const LAYOUT_INLINE = 'inline';
/**
* @var string richtext feature preset e.g: 'markdown', 'normal', 'full'
*/
public $preset;
/**
* @var string defines the style/layout of the richtext
*/
public $layout = self::LAYOUT_BLOCK;
/**
* Can be used to overwrite the default placeholder.
*
@ -131,14 +140,9 @@ class AbstractRichTextEditor extends JsInputWidget
*/
public $label = false;
/**
* @var [] renderer class definition
*/
public static $renderer;
/**
* @inhertidoc
*/
/**
* @inhertidoc
*/
public function run()
{
$inputOptions = $this->getInputAttributes();
@ -160,6 +164,11 @@ class AbstractRichTextEditor extends JsInputWidget
return $input . $richText . $this->prepend();
}
/**
* @var [] renderer class definition
*/
public static $renderer;
/**
* This method can be overwritten in order to prepend content after the actual rich text content.
* @return string

View File

@ -32,7 +32,7 @@ class ProsemirrorRichTextEditor extends AbstractRichTextEditor
/**
* @var string defines the editor style, which will be added as class attribute
*/
public $menuClass = self::MENU_CLASS_FOCUS;
public $menuClass;
public static $renderer = [
'class' => ProsemirrorRichText::class
@ -40,8 +40,11 @@ class ProsemirrorRichTextEditor extends AbstractRichTextEditor
public function init()
{
if($this->menuClass === static::MENU_CLASS_PLAIN) {
if($this->layout === static::LAYOUT_BLOCK) {
$this->exclude[] = 'resizeNav';
$this->menuClass = static::MENU_CLASS_PLAIN;
} else {
$this->menuClass = static::MENU_CLASS_FOCUS;
}
parent::init();

View File

@ -19,6 +19,7 @@ $submitUrl = $post->content->container->createUrl('/post/post/edit', ['id' => $p
<div class="post-richtext-input-group">
<?= $form->field($post, 'message')->widget(RichTextField::class, [
'id' => 'post_input_'. $post->id,
'layout' => RichTextField::LAYOUT_INLINE,
'pluginOptions' => ['maxHeight' => '300px'],
'placeholder' => Yii::t('PostModule.views_edit', 'Edit your post...')
])->label(false) ?>

View File

@ -6,6 +6,7 @@ use humhub\modules\content\widgets\richtext\RichTextField;
<?= RichTextField::widget([
'id' => 'contentForm_message',
'layout' => RichTextField::LAYOUT_INLINE,
'pluginOptions' => ['maxHeight' => '300px'],
'placeholder' => Yii::t("PostModule.widgets_views_postForm", "What's on your mind?"),
'name' => 'message',

View File

@ -234,7 +234,7 @@
position: relative;
min-height: 1em;
color: #666;
padding: 1px 6px;
padding: 1px 6px 1px 0;
top: 0; left: 0; right: 0;
z-index: 10;
-moz-box-sizing: border-box;