A field for editing code in the SilverStripe CMS using Ace Editor

Overview

SilverStripe CodeEditorField

This module adds a CodeEditorField that uses Ace Editor (http://ace.c9.io/) to let you edit code (mostly HTML or JavaScript). Try it out here. It comes in two forms:

  • A regular CodeEditorField that can be used on an HTMLText field similar to HTMLEditorField
  • An optional replacement code view for TinyMCE that uses a CodeEditorField

Maintainer Contacts

Nathan Cox ([email protected])

Requirements

  • SilverStripe 3.1+

Documentation

GitHub

Installation Instructions

  1. Place the files in a directory called codeeditorfield in the root of your SilverStripe installation. You can most easily do this with composer require nathancox/codeeditorfield
  2. Configure your site's config.yml to define your defaults (optional).
  3. Visit yoursite.com/dev/build to rebuild the database

Usage Overview

Configuration via config.yml:

---
Name: codeeditorfield
---

CodeEditorField:
    # These are the pre-defined defaults for dark/light themes
    default_dark_theme: 'monokai'
    default_light_theme: 'github'
    
    # This will overwrite the above settings
    default_theme: 'tomorrow'
    

Using CodeEditorField in getCMSFields:

	
$fields->addFieldToTab('Root.Content', $codeField = new CodeEditorField('Configuration', 'Configuration'));
// set the field to use the full width of the CMS (optional, not included in screenshot)
$codeField->addExtraClass('stacked');

// set the height of the field (defaults to 8)
$codeField->setRows(30);

// set the syntax mode to yaml (defaults to html)
$codeField->setMode('yaml');

// optional - set theme (see codeeditorfield/thirdparty/ace/src-noconflict/theme-xxx.js files for available themes)
$codeField->setTheme('twilight');

produces the following:

example codeeditorfield

Note: If you opt not to set default_theme and don't set the theme specifically on the field, you will have the option to toggle between Dark and Light.

To replace the code editor in TinyMCE:

// copy this into your project's getCMSFields

HtmlEditorConfig::get('cms')->enablePlugins(array(
	'aceeditor' => sprintf('../../../codeeditorfield/javascript/tinymce/editor_plugin_src.js')
));
HtmlEditorConfig::get('cms')->insertButtonsBefore('fullscreen', 'aceeditor');
HtmlEditorConfig::get('cms')->removeButtons('code');

Known Issues

Issue Tracker

Comments
  • If theme defined in config.yml buttons don't work in modal editor

    If theme defined in config.yml buttons don't work in modal editor

    I've had an issue which took me a while to track down, but eventually I realised that setting theme in config.yml e.g.

    SSViewer:
      theme: 'myTheme'
    

    Breaks the word-wrap and theme buttons in the modal editor. Instead, they simply close the modal.

    opened by MattyBalaam 5
  • Feature bumps

    Feature bumps

    Hi Nathan!

    As you can see I forked this a while ago and totally forgot to make the PR back against your module. Rectifying that error now.

    In short - adds a Dark/Light theme switch, a word-wrap toggle button, and touches up the README.

    If this isn't something you maintain or care about any more, just let me know!

    Thanks!

    opened by andrewandante 2
  • silverstripe 3.2 problem

    silverstripe 3.2 problem

    hi in silverstripe 3.1 everything works very well I try install silverstripe-codeeditorfield on silverstripe 3.2-dev when I click on show: HTML Editor button on tinyMCE I get next error:

    GET http://webspilka.dev/autopodbor/TinyMCECodeEditor/PopupForm/forTemplate 404 Not Found 772ms jquery....3783829 (рядок 8240) "NetworkError: 404 Not Found - http://webspilka.dev/autopodbor/TinyMCECodeEditor/PopupForm/forTemplate"

    opened by webspilka 2
  • Fixes, enhancements, tidy ups

    Fixes, enhancements, tidy ups

    Hello, thanks for this great module. I've just used it on one of my clients sites and came across a couple of things..

    I've fixed a bug as described here - http://japhr.blogspot.com.au/2012/10/ace-and-disappearing-text.html, where on saving a page with a codeedtiorfield in the cms, the edit form would reload with the codeeditorfield only showing the first few lines of code inside.

    I've also added the ability to set the editor theme globally or per-instance, and tidied up some of the other configuration code.

    Cheers

    opened by sheadawson 2
  • Converted to PSR-2

    Converted to PSR-2

    Hello!

    I'm helpful robot. I noticed there were some deviations from PSR-2 in your code. The core committer team recently decided to transition SilverStripe Framework and CMS to PSR-2, and the supported module standard recommends following PSR-2. I've gone ahead and converted files in code and tests to PSR-2. If this sounds like something you'd like to merge then go right ahead! Feel free to ask questions or make suggestions for how I can help you more. I've been programmed with a wide range of responses.

    Have a nice day! [gzzzzrrrkt]

    opened by helpfulrobot 0
  • Incompatible with Silverstripe 3.3?

    Incompatible with Silverstripe 3.3?

    Hello @nathancox, I'm a happy user of the codeeditorfield module. Until now it survived every Silverstripe 3-upgrade. But since I upgraded to Silverstripe 3.3 there are some weird things going on here with the codeeditorfield. At the moment I'm debugging my code.

    This is the behaviour I get after the ss3.3 upgrade: The visible cursor is off-sync with the 'real' position in the text (so selections/edits happen on the wrong place in the text). The font of the codeeditorfield also changed from the Arial-like font into a Times-like font.

    To be honoust, I'm getting a littlebit clueless by now on where to look, so just to be sure: should this module be compatible with Silverstripe 3.3? Thanks in advance

    opened by Friksel 6
  • Added standard Scrutinizer config

    Added standard Scrutinizer config

    Hello!

    I'm helpful robot. I noticed you don't have a Scrutinizer config file. This one adds many code quality checks. If you are unsure of how to connect your repository to Scrutinizer, read the guide I wrote for you humans.

    Have a nice day! [brrrrb, click]

    opened by helpfulrobot 0
Releases(1.3.1)
Owner
Nathan Cox
Nathan Cox
Core code of NumberNine CMS

Introduction NumberNine is a CMS for building websites and web applications with Symfony. While generic enough to meet standard websites requirements,

NumberNine CMS 15 Oct 28, 2022
A dumb sharing site for photos and videos, made by me, using a bit of borrowed code.

ShitShare A dumb sharing site for photos and videos, made by me, using a bit of borrowed code. Information This was made on Windows, so when video upl

null 1 Dec 14, 2022
Backend of the Articly wiki/cms project

Documentation | Changelog | Roadmap Currently under heavy development & testing. Fast, easy and reliable wiki software running in the web. What is Art

null 4 Feb 14, 2022
Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony

Grav Grav is a Fast, Simple, and Flexible, file-based Web-platform. There is Zero installation required. Just extract the ZIP archive, and you are alr

Grav 13.6k Dec 24, 2022
Self-hosted CMS platform based on the Laravel PHP Framework.

October is a Content Management System (CMS) and web platform whose sole purpose is to make your development workflow simple again. It was born out of

October CMS 10.8k Dec 30, 2022
Bolt is a simple CMS written in PHP. It is based on Silex and Symfony components, uses Twig and either SQLite, MySQL or PostgreSQL.

⚠️ Note - Not the latest version This is the repository for Bolt 3. Please know that Bolt 5 has been released. If you are starting a new project, plea

Bolt 4.1k Dec 27, 2022
Laravel Shopping Cart CMS

This is Laravel shopping cart CMS with stripe payment gateway integration. You can use it for post page and product. You can also see orders. This cms

Itobuz 42 Nov 24, 2022
Multilingual PHP CMS built with Laravel and bootstrap

Lavalite This is an open source of Content Management System developed with Laravel framework. Documentation Visit Documentation section in the websit

LavaLite 2.6k Dec 26, 2022
Full symfony website application cms + app all in one

Symfony Web App All in one cms website + Inventori Invoice Accounting Application A new modern web app with content management system for build websit

Mesin Kasir 5 Sep 22, 2022
Source code of Strm.pl, brand-new social service.

Strimoid Source code of Strm.pl, brand-new social service.

Strimoid 67 Oct 20, 2022
Um modelo de loja virtual utilizando HTML, CSS, JS, Bootstrap e PHP, utilizando ferramentas de edição de texto (VS Code), Edição de imagens (Adobe photoshop) e de vetorização (Adobe Illustrator).

Loja virtual fictícia Um modelo de loja virtual utilizando HTML, CSS, JS, Bootstrap e PHP, utilizando ferramentas de edição de texto (VS Code), Edição

Emily Leme 2 Sep 8, 2021
This is the source code to my website built with the Laravel framework.

About This is the source code to my website built with the Laravel framework. Set-up Simply clone this repository, install composer and node dependenc

Octanna 6 Dec 29, 2021
Infopanel is a simple tool getting some information from source. It works basically like a slider that shows only title, image, a little bit description and QR-Code for links.

Infopanel is a simple tool getting some information from source. It works basically like a slider that shows only title, image, a little bit description and QR-Code for links. It has its own GUI for the editing. The GUI provides a very simple role concept. This tool can be used for digital signage, Information panels, News or Events or similar.

null 4 Aug 22, 2022
Code utilisé pour les démonstrations de ma conférence sur la Microtypographie pour Paris Web 2021

?? Microtypographie - Exemples de fixers Dans le cadre de ma conférence sur la microtypographie pour Paris Web 2021, je vous propose ce petit projet,

Marion Hurteau 5 Nov 11, 2021
The source code to Charlie’s old website.

About This is the source code to my website built with the Laravel framework. Set-up Simply clone this repository, install composer and node dependenc

Charlie Joseph 6 Dec 29, 2021
LaravelSnippets.com website | A repository of useful code snippets for Laravel PHP framework

LaravelSnippets.com website | A repository of useful code snippets for Laravel PHP framework. Submit, grab and share!

John Kenn 331 Nov 22, 2022
The source code for the Laravel Tricks website

Laravel-Tricks Laravel-Tricks is now under the ownership of Tighten, and all development is taking place under a private repo until we can extract som

CodepadME 973 Dec 27, 2022
This repository contains source code of my personal portfolio at naurislinde.com

The source code of naurislinde.com This repository contains source code of my personal portfolio at naurislinde.com Getting Started These instructions

Nauris Linde 7 Sep 12, 2022
Bulit PHP Twitter Clone IN OOP style and using MYSQL Database.

Bulit PHP Twitter Clone IN OOP style and using MYSQL Database. AJAX and Jquery for requests without reloading like Follow/unfollow, like, Search users, Show popups like comment , User lists, etc.

Amin 47 Dec 3, 2022