kartik-v / yii2-markdown

Advanced Markdown editing and conversion utilities for Yii Framework 2.0
http://demos.krajee.com/markdown
Other
89 stars 41 forks source link

More features for compatibility with other css frameworks #15

Closed morivitalii closed 10 years ago

morivitalii commented 10 years ago

I want to use this css framework https://github.com/olton/Metro-UI-CSS with editor This framewok is not compatible with twitter bootstrap. Can you add more features for compatibility with other css frameworks? For example. Icons. twb - class="glyphicon glyphicon-{$icon}", metroui - class="icon-{$icon}"

kartik-v commented 10 years ago

Have you checked the Markdown Editor documentation? You can customize virtually every option and all the use cases you need above can be setup as mentioned in the editor settings.

For example to change a button icon there are 2 methods:

  1. Pass an icon to each button's options. It will render the bootstrap glyphicon.
  2. If you want any other icon, then assign icon to null in buttonOptions and set the label to a html markup to generate the icon. You need to set encodeLabels to false in buttonOptions or individually set encodeLabel to false for each button so that it renders the html markup for button icons. For example to set a custom toolbar:
use kartik\markdown\MarkdownEditor;
$customToolbar = [
    [
        'buttons' => [
            MarkdownEditor::BTN_BOLD => ['label'=>'<img src="/images/bold.png">', 'title' => 'Bold'],
            MarkdownEditor::BTN_ITALIC => ['label'=>'<span class="custom-icon-italic"></span>', 'title' => 'Italic'],
        ]
    ],
    [
        'buttons' => [
            MarkdownEditor::BTN_LINK => ['icon' => 'link', 'title' => 'URL/Link'],
            MarkdownEditor::BTN_IMAGE => ['icon' => 'picture', 'title' => 'Image'],
        ],
    ],
];

// usage with model and a custom toolbar
echo MarkdownEditor::widget([
    'model' => $model,
    'attribute' => 'markdown',
    'buttonOptions' => ['encodeLabels' => false],
    'toolbar' => $customToolbar
]);
morivitalii commented 10 years ago

Thank you. I will choose the second method