Skip to content

Commit

Permalink
add marked
Browse files Browse the repository at this point in the history
  • Loading branch information
cui-liang committed Aug 3, 2017
1 parent 29fdd32 commit 827cf1c
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 34 deletions.
33 changes: 33 additions & 0 deletions CodeMirrorAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

namespace yiichina\mdeditor;

use yii\web\AssetBundle;

/**
* This asset bundle provides the javascript files for client validation.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class CodeMirrorAsset extends AssetBundle
{
public $sourcePath = '@bower/codemirror';

public $css = [
'lib/codemirror.css',
];

public $js = [
'js/codemirror.js',
];

public $depends = array(
'yii\bootstrap\BootstrapAsset'
);
}
25 changes: 25 additions & 0 deletions MarkedAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

namespace yiichina\mdeditor;

use yii\web\AssetBundle;

/**
* This asset bundle provides the javascript files for client validation.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class MarkedAsset extends AssetBundle
{
public $sourcePath = '@bower/marked';

public $js = [
'lib/marked.js',
];
}
28 changes: 28 additions & 0 deletions MdEditor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace yiichina\mdeditor;

use yii\Helpers\Html;

/**
* This is just an example.
*/
class MdEditor extends \yii\widgets\InputWidget
{
public function init()
{
parent::init();
$view = $this->getView();
MdEditorAsset::register($view);
$view->registerJs("(\"#{$this->options['id']}\").mdEditor()");
}

public function run()
{
if($this->hasModel()) {
return Html::activeTextarea($this->model, $this->attribute, $this->options);
} else {
return Html::textarea($this->name, $this->value, $this->options);
}
}
}
34 changes: 34 additions & 0 deletions MdEditorAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

namespace yiichina\mdeditor;

use yii\web\AssetBundle;

/**
* This asset bundle provides the javascript files for client validation.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class MdEditorAsset extends AssetBundle
{
public $sourcePath = '@bower/cmd-editor';

public $css = [
'css/md-editor.css',
];

public $js = [
'js/md-editor.js',
];

public $depends = array(
'yiichina\mdeditor\CodeMirrorAsset',
'yiichina\mdeditor\MarkedAsset',
);
}
51 changes: 17 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,24 @@
{
"name": "yiichina/yii2-md-editor",
"description": "Yii 2 Advanced Application Template",
"keywords": ["yii2", "framework", "advanced", "application template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"description": "Yii2 中使用 Markdown 在线文本编辑器",
"type": "yii2-extension",
"keywords": ["yii2","extension","editor", "markdown"],
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"authors": [
{
"name": "cuileon",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
"yiisoft/yii2": ">=2.0.6",
"bower-asset/cmd-editor": "*",
"bower-asset/codemirror": "*",
"bower-asset/marked": "*"
},
"config": {
"process-timeout": 1800
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
"autoload": {
"psr-4": {
"yiichina\\md-editor\\": ""
}
},
"repositories": [
{"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},
{"packagist": false}
]
}
}

0 comments on commit 827cf1c

Please sign in to comment.