Skip to content

Commit

Permalink
Initital commit (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw authored Nov 18, 2023
1 parent be1da04 commit f4f4aa0
Show file tree
Hide file tree
Showing 176 changed files with 21,242 additions and 62 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'psalm.xml'

name: mutation test

jobs:
mutation:
uses: php-forge/actions/.github/workflows/roave-infection.yml@main
secrets:
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
70 changes: 53 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<a href="https://github.com/yii2-extensions/template" target="_blank">
<a href="https://github.com/yii2-extensions/summernote" target="_blank">
<img src="https://www.yiiframework.com/image/yii_logo_light.svg" height="100px;">
</a>
<h1 align="center">Yii2-Template.</h1>
<h1 align="center">Summernote - Super Simple WYSIWYG editor.</h1>
<br>
</p>

Expand All @@ -13,32 +13,68 @@
<a href="https://github.com/yiisoft/yii2/tree/2.2" target="_blank">
<img src="https://img.shields.io/badge/Yii2%20version-2.2-blue" alt="yii2-version">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/template/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
<a href="https://github.com/yii2-extensions/summernote/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/summernote/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://codecov.io/gh/yii2-extensions/template" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/template/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
<a href="https://codecov.io/gh/yii2-extensions/summernote" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/summernote/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/summernote/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Fsummernote%2Fmain" alt="Infection">
</a>
<a href="https://github.com/yii2-extensions/summernote/actions/workflows/static.yml" target="_blank">
<img src="https://github.com/yii2-extensions/gii/actions/workflows/static.yml/badge.svg" alt="PHPStan">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/badge/PHPStan%20level-2-blue" alt="PHPStan level">
</a>
<a href="https://github.styleci.io/repos/698621511?branch=main" target="_blank">
<img src="https://github.styleci.io/repos/698621511/shield?branch=main" alt="Code style">
</a>
<a href="https://github.com/yii2-extensions/summernote/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/badge/PHPStan%20level-7-blue" alt="PHPStan level">
</a>
<a href="https://github.styleci.io/repos/711200053?branch=main" target="_blank">
<img src="https://github.styleci.io/repos/711200053/shield?branch=main" alt="Code style">
</a>
</p>

## Requirements
![summernote](docs/images/summernote.png)

## Installation

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

The minimun version of `PHP` required by this package is `PHP 8.1`.
```
composer require --dev --prefer-dist yii2-extensions/summernote
```

For install this package, you need [composer](https://getcomposer.org/).
or add

```
"yii2-extensions/summernote": "dev-main"
```

to the require-dev section of your `composer.json` file.

## Usage

[Check the documentation docs](/docs/README.md) to learn about usage.
### View

```php
use Yii2\Extensions\Summernote\Summernote;

echo $form
->field($model, 'content')
->widget(
Summernote::class,
[
'config' => [
'focus' => true,
'height' => 200,
'maxHeight' => null,
'minHeight' => null,
'placeholder' => 'Write here...',
],
]
);
```

## Testing

Expand Down
5 changes: 5 additions & 0 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"symbol-whitelist": [
"YII_ENV"
]
}
35 changes: 28 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,62 @@
{
"name": "yii2/template",
"name": "yii2-extensions/summernote",
"type": "library",
"description": "_____",
"description": "Summernote - Super Simple WYSIWYG editor.",
"keywords": [
"_____"
"yii2",
"editor",
"summernote",
"wysiwyg"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"yiisoft/yii2": "^2.2"
"oomphinc/composer-installers-extender": "^2.0",
"php-forge/html": "dev-main",
"yii2-extensions/asset-bootstrap5": "dev-main",
"yiisoft/yii2": "*"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.6",
"php-forge/support": "dev-main",
"phpunit/phpunit": "^10.2",
"roave/infection-static-analysis-plugin": "^1.32",
"yii2-extensions/phpstan": "dev-main"
},
"autoload": {
"psr-4": {
"yii\\template\\": "src"
"Yii2\\Extensions\\Summernote\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yii\\template\\tests\\": "tests"
"Yii2\\Extensions\\Summernote\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
},
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"./node_modules/{$name}": [
"type:bower-asset",
"type:npm-asset"
]
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"yiisoft/yii2-composer": true
"yiisoft/yii2-composer": true,
"composer/installers": true,
"oomphinc/composer-installers-extender": true,
"infection/extension-installer": true
}
},
"scripts": {
Expand Down
Binary file added docs/images/summernote.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
includes:
- vendor/yii2-extensions/phpstan/extension.neon

parameters:
bootstrapFiles:
- tests/Support/bootstrap.php

dynamicConstantNames:
- YII_DEBUG
- YII_ENV
- YII_ENV_DEV
- YII_ENV_PROD
- YII_ENV_TEST

level: 2
level: 7

paths:
- src
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
bootstrap="tests/Support/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
executionOrder="depends,defects"
Expand All @@ -11,7 +11,7 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="Template">
<testsuite name="Yii2-Summernote">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
</issueHandlers>
</psalm>
62 changes: 62 additions & 0 deletions src/Asset/SummernoteAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace Yii2\Extensions\Summernote\Asset;

use Yii2\Asset\BootstrapPluginAsset;
use Yii;
use yii\web\AssetBundle;
use yii\web\JqueryAsset;

/**
* Summernote CSS and JS bundle.
*/
final class SummernoteAsset extends AssetBundle
{
/**
* @inheritDoc
*/
public $sourcePath = __DIR__;

/**
* @inheritDoc
*
* @phpstan-var array<array-key, mixed>
*/
public $depends = [
BootstrapPluginAsset::class,
JqueryAsset::class,
];

public function init(): void
{
parent::init();

$language = Yii::$app->language;

$assetCss = YII_ENV === 'prod' ? 'css/summernote-bs5.min.css' : 'css/summernote-bs5.css';
$assetJs = YII_ENV === 'prod' ? 'js/summernote-bs5.min.js' : 'js/summernote-bs5.js';
$assetLang = YII_ENV === 'prod' ? "lang/summernote-$language.min.js" : "lang/summernote-$language.js";

$this->css[] = $assetCss;
$this->js[] = $assetJs;
$this->js[] = $assetLang;

$only = [
$assetCss,
$assetJs,
$assetLang,
'css/font/*',
'plugin/*/**',
];

$only = array_merge(
$only,
YII_ENV === 'prod'
? ['css/summernote-bs5.min.css.map', 'js/summernote-bs5.min.js.map'] : ["lang/summernote-$language.js.map"]
);

$this->publishOptions['only'] = $only;
}
}
Binary file added src/Asset/css/font/summernote.eot
Binary file not shown.
1 change: 1 addition & 0 deletions src/Asset/css/font/summernote.hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9fe8a4284ea6542e5b857380d2288fbd
Binary file added src/Asset/css/font/summernote.ttf
Binary file not shown.
Binary file added src/Asset/css/font/summernote.woff
Binary file not shown.
Binary file added src/Asset/css/font/summernote.woff2
Binary file not shown.
Loading

0 comments on commit f4f4aa0

Please sign in to comment.