-
Notifications
You must be signed in to change notification settings - Fork 3
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
5 changed files
with
137 additions
and
34 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,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' | ||
); | ||
} |
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 | ||
/** | ||
* @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', | ||
]; | ||
} |
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,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); | ||
} | ||
} | ||
} |
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,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', | ||
); | ||
} |
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 |
---|---|---|
@@ -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} | ||
] | ||
} | ||
} |