luwes / craft-codemirror Goto Github PK
View Code? Open in Web Editor NEWAdd the awesome in-browser code editor CodeMirror as a field type.
License: MIT License
Add the awesome in-browser code editor CodeMirror as a field type.
License: MIT License
First of all, thank you for this plugin. Now that Craft 4 is about to be released, do you plan to have the plugin ready by then?
CodeMirror fields don't seem to update Live Preview for me. Latest Craft and CodeMirror.
Cool plugin but, I'm trying to make an inline CSS editor and it's not picking up the syntax highlighting for CSS despite having CSS enabled in my modes?
Any ideas?
Plug-in doesn't initialize correctly on tabs besides the first tab on entry editors.
Hey :)
You said you merged PR for craft 4 ..
but still not avaible to download in Craft store..
any info on that
After composer installation try to install it in the settings -> Plugins page but gives error.
I use Craft 3
Invalid Configuration – yii\base\InvalidConfigException
Unable to locate message source for category 'codemirror'.
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/i18n/I18N.php at line 200
191192193194195196197198199200201202 $source = $this->translations[''];
if ($source instanceof MessageSource) {
return $source;
} else {
return $this->translations[$category] = $this->translations[''] = Yii::createObject($source);
}
}
}
throw new InvalidConfigException("Unable to locate message source for category '$category'.");
}
}
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/i18n/I18N.php at line 88 – yii\i18n\I18N::getMessageSource('codemirror')
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/i18n/I18N.php at line 311 – yii\i18n\I18N::translate('codemirror', 'plugin loaded', [], 'fi-FI')
305306307308309310311312313314315316317
/**
@inheritdoc
*/
public function translate($category, $message, $params, $language)
{
$translation = parent::translate($category, $message, $params, $language);
if ($this->_shouldAddTranslationDebugOutput()) {
switch ($category) {
case 'site':
$char = '$';
break;
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/BaseYii.php at line 509 – craft\i18n\I18N::translate('codemirror', 'plugin loaded', [], 'fi-FI')
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/luwes/craft3-codemirror/src/CodeMirror.php at line 71 – yii\BaseYii::t('codemirror', 'plugin loaded')
65666768697071727374757677 function (PluginEvent $event) {
if ($event->plugin === $this) {
}
}
);
Craft::info('CodeMirror ' . Craft::t('codemirror', 'plugin loaded'), __METHOD__);
}
// Protected Methods
// =========================================================================
}
6. in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/base/Object.php at line 107 – luwes\codemirror\CodeMirror::init()
7. in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/base/Module.php at line 158 – yii\base\Object::__construct(['name' => 'CodeMirror', 'version' => '1.0.0', 'schemaVersion' => '1.0.0', 'description' => 'Add the awesome in-browser code ...', ...])
8. in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/base/Plugin.php at line 87 – yii\base\Module::__construct('code-mirror', craft\web\Application, ['name' => 'CodeMirror', 'version' => '1.0.0', 'schemaVersion' => '1.0.0', 'description' => 'Add the awesome in-browser code ...', ...])
81828384858687888990919293 }
});
// Set this as the global instance of this plugin class
static::setInstance($this);
parent::__construct($id, $parent, $config);
}
/**
* @inheritdoc
*/
public function getHandle(): string
craft\base\Plugin::__construct('code-mirror', craft\web\Application, ['name' => 'CodeMirror', 'version' => '1.0.0', 'schemaVersion' => '1.0.0', 'description' => 'Add the awesome in-browser code ...', ...])
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/di/Container.php at line 381 – ReflectionClass::newInstanceArgs(['code-mirror', craft\web\Application, ['basePath' => '/Users/digikokki/Documents/_code...', 'name' => 'CodeMirror', 'version' => '1.0.0', 'schemaVersion' => '1.0.0', ...]])
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/di/Container.php at line 156 – yii\di\Container::build('luwes\codemirror\CodeMirror', ['code-mirror', craft\web\Application], ['basePath' => '/Users/digikokki/Documents/_code...', 'name' => 'CodeMirror', 'version' => '1.0.0', 'schemaVersion' => '1.0.0', ...])
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/BaseYii.php at line 348 – yii\di\Container::get('luwes\codemirror\CodeMirror', ['code-mirror', craft\web\Application], ['basePath' => '/Users/digikokki/Documents/_code...', 'name' => 'CodeMirror', 'version' => '1.0.0', 'schemaVersion' => '1.0.0', ...])
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/services/Plugins.php at line 586 – yii\BaseYii::createObject(['basePath' => '/Users/digikokki/Documents/_code...', 'name' => 'CodeMirror', 'version' => '1.0.0', 'schemaVersion' => '1.0.0', ...], ['code-mirror', craft\web\Application])
580581582583584585586587588589590591592 $config['settings'] = $settings;
}
}
// Create the plugin
/** @var Plugin $plugin */
$plugin = Craft::createObject($config, [$handle, Craft::$app]);
if ($row !== null) {
$this->_setPluginMigrator($plugin, $row['id']);
}
return $plugin;
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/services/Plugins.php at line 315 – craft\services\Plugins::createPlugin('code-mirror')
309310311312313314315316317318319320321 if (isset($this->_installedPluginInfo[$handle])) {
// It's already installed
return true;
}
/** @var Plugin $plugin */
$plugin = $this->createPlugin($handle);
// Fire a 'beforeInstallPlugin' event
if ($this->hasEventHandlers(self::EVENT_BEFORE_INSTALL_PLUGIN)) {
$this->trigger(self::EVENT_BEFORE_INSTALL_PLUGIN, new PluginEvent([
'plugin' => $plugin
]));
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/controllers/PluginsController.php at line 49 – craft\services\Plugins::installPlugin('code-mirror')
43444546474849505152535455 */
public function actionInstallPlugin(): Response
{
$this->requirePostRequest();
$pluginHandle = Craft::$app->getRequest()->getRequiredBodyParam('pluginHandle');
if (Craft::$app->getPlugins()->installPlugin($pluginHandle)) {
Craft::$app->getSession()->setNotice(Craft::t('app', 'Plugin installed.'));
} else {
Craft::$app->getSession()->setError(Craft::t('app', 'Couldn’t install plugin.'));
}
return $this->redirectToPostedUrl();
craft\controllers\PluginsController::actionInstallPlugin()
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([craft\controllers\PluginsController, 'actionInstallPlugin'], [])
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/base/Controller.php at line 156 – yii\base\InlineAction::runWithParams(['p' => 'admin/settings/plugins'])
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/base/Module.php at line 523 – yii\base\Controller::runAction('install-plugin', ['p' => 'admin/settings/plugins'])
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/web/Application.php at line 241 – yii\base\Module::runAction('plugins/install-plugin', ['p' => 'admin/settings/plugins'])
235236237238239240241242243244245246247 * @param array $params
*
@return Response|null The result of the action, normalized into a Response object
*/
public function runAction($route, $params = [])
{
$result = parent::runAction($route, $params);
if ($result !== null) {
if ($result instanceof Response) {
return $result;
}
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/web/Application.php at line 380 – craft\web\Application::runAction('plugins/install-plugin', ['p' => 'admin/settings/plugins'])
374375376377378379380381382383384385386 $route = implode('/', $request->getActionSegments());
try {
Craft::trace("Route requested: '$route'", __METHOD__);
$this->requestedRoute = $route;
return $this->runAction($route, $_GET);
} catch (InvalidRouteException $e) {
throw new NotFoundHttpException(Craft::t('yii', 'Page not found.'), $e->getCode(), $e);
}
}
return null;
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/craftcms/cms/src/web/Application.php at line 201 – craft\web\Application::_processActionRequest(craft\web\Request)
195196197198199200201202203204205206207 throw new ForbiddenHttpException();
}
}
}
// If this is an action request, call the controller
if (($response = $this->_processActionRequest($request)) !== null) {
return $response;
}
// If we're still here, finally let Yii do it's thing.
return parent::handleRequest($request);
}
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/vendor/yiisoft/yii2/base/Application.php at line 380 – craft\web\Application::handleRequest(craft\web\Request)
in /Users/digikokki/Documents/_code-stuff/_digikokki/Git-projektit/craft-3-cms/web/index.php at line 21 – yii\base\Application::run()
15161718192021 $dotenv->load();
}
// Craft
define('CRAFT_BASE_PATH', $root);
$app = require $root.'/vendor/craftcms/cms/bootstrap/web.php';
$app->run();
$_GET = [
'p' => 'admin/settings/plugins',
];
$_POST = [
'pluginHandle' => 'code-mirror',
'CRAFT_CSRF_TOKEN' => 'XbI2FHIhh4vL2LReuijUXnDHeN-B0KuUIa8UGnmM8Ts0-a1qn5kqXIy4Ph_18F2lb9JtX0YlbF0hnK_22W7IoCadXPxUuaUgtq2mGOMBJfAfizZyLp6jchH59zceQ5ENaxUoICDRZwme8yw0DZ0GL9tJB_gPZnCrObskOk6jtTdc7aQAo1H2ZbjMnkLxfF8Dn05LrX-qFwDzr4ETYJUX1piuNtbBOUmJ7rEk48wKCeOXQuxzzvy6_4lv7RGvDOXka3B7RDmnG5r-wupElAeFbxCDcVwUb9fuo77TENMb4hBCgjOK5Kfj2k_oXEg-upNsVp7JJK7Nfy_w2w99xMA_klbhDDx_EAhoEP_Kle4LrJIfqWWdNYyVQ9SckCmBNUOTe79TQxaolktwzJYPfXTwOw52EUYTslA--L4dc0X7SH--IWGfQQ9DnXeJYXEbxsJ_EoPjSPEWwAfvrvkmv00LVuwyetFbmG4kwpyley7PWrqp6QKbl2Bx7dbyfbG7bHOV4my9A_21i7X6XapD-DjQryYlPzdKlC-sv4-JEt1jsRo=',
'action' => 'plugins/install-plugin',
];
$_COOKIE = [
'CraftSessionId' => 'd2573ad6ae0b6925ecbc7b1c40df48ab',
'1031b8c41dfff97a311a7ac99863bdc5_username' => '6e998ce83802f28e32426e1860733c11edb528f965396802767b5a7ac2142fb1a:2:{i:0;s:41:"1031b8c41dfff97a311a7ac99863bdc5_username";i:1;s:9:"digikokki";}',
'CRAFT_CSRF_TOKEN' => '03360ff1d090d0cf62e0df59baf79c71bc5f5774a15dbc56acf398407c064d17a:2:{i:0;s:16:"CRAFT_CSRF_TOKEN";i:1;s:208:"M1GHfNPehfgNi36N2EKUewHNnGHRG6bWbgdN1TUs|c1b10b793ac95d51cec7ed2949aa50cb161b4fcd4e18659a5a8c7a6ec9f3c77fM1GHfNPehfgNi36N2EKUewHNnGHRG6bWbgdN1TUs|1|$2y$13$hNZMl1G4MVY8d8CYRwfzvu.Qp3I1Js2GRW45KMUDss346AMcVId4u";}',
'1031b8c41dfff97a311a7ac99863bdc5_identity' => 'b176f68502912755168b07362e2ad72e1c5778ef525411a3ae26d1d07e7585b8a:2:{i:0;s:41:"1031b8c41dfff97a311a7ac99863bdc5_identity";i:1;s:286:"["1","[\"jY2ZMYkUJ3lGjhlM7HJGvYcn9tPB61ngc-GhkyIle3QKdlTifyPXrwOnVdtWutyAjsTkXpuX3mSpYBy9X4nW4RDdCOUg1xwhkvub\",\"7d4c2791-7af9-4b95-b2de-ad962bbbbb77\",\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36\"]",3600]";}',
];
$_SESSION = [
'bd62416aa8538ede709019a5e113eea5__flash' => [],
'bd62416aa8538ede709019a5e113eea5__auth_access' => [
'saveAssetInVolume:1',
],
'1031b8c41dfff97a311a7ac99863bdc5__id' => '1',
'1031b8c41dfff97a311a7ac99863bdc5__expire' => 1501768094,
];
Yii Framework
2017-08-03, 15:48:14
Apache
Yii Framework/2.0.12
Would be great if a custom theme could be configured so it can be referenced outside of the theme folder and therefore not deleted when updating the plugin.
Workaround is to use the CP CSS plugin to include the CodeMirror theme css.
Hello!
Please can you add Twigfield support
(https://twitter.com/nystudio107/status/1536233722558746625)
I have a Codemirror field that is required on an entry in my Craft instance. When I try to save the entry, the content that is entered in the Codemirror field gets deleted and the field throws an error saying "[Field name] cannot be blank." and the entry cannot be saved (since the field is required).
Craft CMS Version 3.2.1
I originally noticed this broke when my site updated to 3.2 beta versions and thought maybe the official release would fix, but looks like that's not the case.
If you need any additional information, please let me know! Thanks!
I have a client who was using this field and tried to embed a tweet that contained a 📣 emoji.
Upon saving the entry I get a Code Embed cannot contain emoji.
error (Code Embed is the name of the field).
I'm looking at other/better options for embedding tweets but is there some way that this field could be updated with emoji support?
CodeMirror JavaScript mode supports additional configuration options, allowing to display json, json-ld and typescript (doc)
I need the JSON mode, not sure how this could be configured right now.
CodeMirror supports using mime types as mode values, and then it automatically maps to correct mode, setting application/json
is internally replaced with json: true, mode: javascript
but setting mime type in the plugin config does not works correctly as it tries to load a js file mode/application/json.js
that actually is not there.
This could be fixed by using the same mode resolving logic that CodeMirror has - https://github.com/codemirror/codemirror5/blob/e84384b4210bc35300994de07c6333666f2a5c9e/src/modes.js#L20C1-L20C1 and https://github.com/codemirror/codemirror5/blob/e84384b4210bc35300994de07c6333666f2a5c9e/mode/javascript/javascript.js#L953
When a CodeMirror field is assigned to a non-default tab, the content of the field will not show until you click in the field.
Is it possible to use this field in custom plugins?
For example;
{% if craft.app.plugins.isPluginEnabled('code-mirror') %}
CODE MIRROR FIELD HERE
{% else %}
{{ forms.textareaField({
label: 'Template'|t('app'),
name: 'template',
value: template,
rows: 8,
errors: model.getErrors('template'),
}) }}
{% endif %}
Couldn't find anything about it.. do you know?
Any plans for an update to support Craft 5?
Adding codemirror.php to /config/ doesn't do anything. (Editing straight in the /src/config.php works, but yeah...)
As title. Doesn't layout properly, so it needs to init again to capture the input field and apply JS.
Hi,
We are using the craft3-codemirror plug-in for Craft CMS 3.5.13.2 and a recent VeraCode security scan came up with a medium security flaw for this plug-in.
The issue is reported on line 686 for /src/assets/addon/tern/tern.js
For more details: https://cwe.mitre.org/data/definitions/117.html
Can this be fixed ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.