Skip to content

helpfulrobot/nathancox-codeeditorfield

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SilverStripe CodeEditorField

This module adds a CodeEditorField that uses Ace Editor (http://ace.c9.io/) to let you edit code (mostly HTML or JavaScript). I 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 (me@nathan.net.nz)

Requirements

  • SilverStripe 3.1+

Documentation

GitHub

Installation Instructions

  1. Place the files in a directory called codeeditorfield in the root of your SilverStripe installation
  2. Visit yoursite.com/dev/build to rebuild the database

Usage Overview

Using CodeEditorField in getCMSFields:

	
	$fields->addFieldToTab('Root.Content', $codeField = new CodeEditorField('ExtraTags', 'Extra tags'));
	$codeField->addExtraClass('stacked');
	
	// set the height of the field (defaults to 8)
	$codeField->setRows(15);
	
	// set the syntax mode to javascript (defaults to html)
	$codeField->setMode('javascript');

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

produces

example codeeditorfield

Replace the code editor in TinyMCE:

// copy this into your project's getCMSFields (you can find this code in codeeditorfield/_config.php)

	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

About

A field for editing code in the SilverStripe CMS using Ace Editor (http://ace.c9.io/)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 45.4%
  • PHP 29.8%
  • CSS 14.1%
  • HTML 8.6%
  • Scheme 2.1%