Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	html-editor-syntax-highlighter.php
  • Loading branch information
arniebradfo committed Jun 12, 2016
2 parents 8818d0a + 4da344f commit 3201608
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 56 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Please report any issues or suggestions.

##Changelog

###1.7.1
* fixed bug: return key would create two new lines and ignore indent
* fixed bug: wp native "Add Media" button was not working
* added version string to .css and .js resources for cache-busting purposes

###1.7.0
* Ctrl-S / Cmd-S saving will now select "Save Draft" if the post has not been published yet
* Switched to an [npm](https://www.npmjs.com/) and [grunt.js](http://gruntjs.com/) based build so new versions of CodeMirror can be applied easier
Expand Down Expand Up @@ -139,6 +144,7 @@ Initial release.


##TODOs:
* [spellcheck](https://wordpress.org/support/topic/trying-to-enable-spell-check-inside-the-editor?replies=5)
* add image previews
* more options
- indenting: size and tabs/spaces
Expand Down
43 changes: 20 additions & 23 deletions dev/hesh.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* @link http://mukhortov.com/
* @author James Bradford
* @link http://arniebradfo.com/
* @since 1.7.0
* @since 1.7.1
*/

(function (document, window, CodeMirror, CodeMirrorCSS, wpLink, wpActiveEditor, switchEditors) {
(function (document, window, CodeMirror, CodeMirrorCSS, wpLink, switchEditors) {
'use strict';

function heshPlugin () {
var editor = null;
var isOn = 0;
var buttonsAdded = 0;
var isOn = false;
var buttonsAdded = false;
var target = document.getElementById('content');
var postID = document.getElementById('post_ID') != null ? document.getElementById('post_ID').value : 0;
var tab_html = document.getElementById('content-html');
Expand Down Expand Up @@ -88,8 +88,8 @@
}

resizeEditor();
addMedia();
isOn = 1;
remapAddMedia();
isOn = true;

updateTabBarPaddings();
window.addEventListener('resize', windowResized);
Expand Down Expand Up @@ -146,7 +146,7 @@
themeSwitcher();
fontSizeSwitcher();
fullscreen();
buttonsAdded = 1;
buttonsAdded = true;
}
};

Expand Down Expand Up @@ -181,7 +181,7 @@
if (switchEditors.switchto) switchEditors.switchto(this);
editor.toTextArea();
tab_html.onclick = toHTML;
isOn = 0;
isOn = false;
window.removeEventListener('resize', windowResized);
}
};
Expand All @@ -191,7 +191,6 @@
if (switchEditors.switchto) switchEditors.switchto(this);
window.setTimeout(runEditor, 300);
tab_tmce.onclick = toVisual;
// addMedia();
}
};

Expand Down Expand Up @@ -275,19 +274,17 @@
};
};

var addMedia = function () {
// We want to do it only oncs
if (!window.send_to_editor_wp) {
var send_to_editor = function (media) {
if (isOn && wpActiveEditor === 'content') {
editor.replaceSelection(media);
editor.save();
} else {
window.send_to_editor_wp(media);
}
};
window.send_to_editor_wp = send_to_editor;
}
var remapAddMedia = function () {
window.send_to_editor_wp = window.send_to_editor; // remap wp native func
var send_to_editor = function (html) {
if (isOn && window.wpActiveEditor === 'content') {
editor.replaceSelection(html);
editor.save();
} else {
window.send_to_editor_wp(html);
}
};
window.send_to_editor = send_to_editor;
};

// Initialise //
Expand All @@ -309,4 +306,4 @@
} else {
heshPlugin();
}
})(document, window, window.CodeMirror, CodeMirrorCSS, window.wpLink, window.wpActiveEditor, window.switchEditors);
})(document, window, window.CodeMirror, CodeMirrorCSS, window.wpLink, window.switchEditors);
2 changes: 1 addition & 1 deletion dev/hesh.dev.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Plugin Name: HTML Editor Syntax Highlighter
* Author: Peter Mukhortov
* Author URI: http://mukhortov.com/
* Version: 1.7.0
* Version: 1.7.1
*/

// @import "../.temp/codemirror";
Expand Down
4 changes: 2 additions & 2 deletions dev/wordpresspost.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
},

indent: function (state, textAfter) {
if (state.isInShortcode) return htmlmixedMode.indent(state.htmlmixedState, textAfter);
else if (!state.isInShortcode) return shortcodeMode.indent(state.shortcodeState, textAfter);
if (!state.isInShortcode) return htmlmixedMode.indent(state.htmlmixedState, textAfter);
else if (state.isInShortcode) return shortcodeMode.indent(state.shortcodeState, textAfter);
else return CodeMirror.Pass;
},

Expand Down
41 changes: 20 additions & 21 deletions html-editor-syntax-highlighter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
*
* @since 1.7.0
* @since 1.7.1
* @package HESH_plugin
*
* Plugin Name: HTML Editor Syntax Highlighter
Expand All @@ -16,41 +16,40 @@
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* GitHub Branch: master
* GitHub Plugin URI: https://github.com/mukhortov/HESH-WordPress-Plugin
* Version: 1.7.0
* Requires at least: 3.3
* Version: 1.7.1
* Requires at least: 4.0.11
* Tested up to: 4.5.2
* Stable tag: 1.7.0
* Stable tag: 1.7.1
**/

if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
if ( preg_match( '#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'] ) ) {
die('You are not allowed to call this page directly.');
}

define('HESH_LIBS', plugins_url('/lib/',__FILE__));
define( 'HESH_LIBS', plugins_url( '/lib/', __FILE__ ) );

class wp_html_editor_syntax {

public function __construct () {
if (!$this->is_editor()) return;
add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
add_action( 'admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts' ) );
}

// Enqueues scripts and styles for hesh.js
public function admin_enqueue_scripts () {
wp_enqueue_style('codemirror', HESH_LIBS.'codemirror.min.css');
wp_enqueue_style('heshcss', HESH_LIBS.'hesh.min.css');
wp_register_script('codemirror', HESH_LIBS.'codemirror.min.js', false, false, true);
wp_enqueue_script('codemirror');
wp_register_script('heshjs', HESH_LIBS.'hesh.min.js', array('codemirror'), false, true); // 'tiny_mce' dependency doesn't work?!
wp_enqueue_script('heshjs');
}

// returns whether or not the current page is a post editing admin page
private function is_editor () {
if (!strstr($_SERVER['SCRIPT_NAME'], 'post.php') &&
!strstr($_SERVER['SCRIPT_NAME'], 'post-new.php'))
return false;
return true;
if ( !post_type_supports( get_post_type(), 'editor' ) ) return;
$ver = get_plugin_data( __FILE__ )['Version'];

wp_enqueue_style( 'codemirror', HESH_LIBS.'codemirror.min.css', false, $ver );

wp_enqueue_style( 'heshcss', HESH_LIBS.'hesh.min.css', false, $ver );

wp_register_script( 'codemirror', HESH_LIBS.'codemirror.min.js', false, $ver, true );
wp_enqueue_script( 'codemirror' );

wp_register_script( 'heshjs', HESH_LIBS.'hesh.min.js', array('codemirror'), $ver, true );
wp_enqueue_script( 'heshjs' );

}

}
Expand Down
2 changes: 1 addition & 1 deletion lib/hesh.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "HESH-WordPress-Plugin",
"version": "1.7.0",
"version": "1.7.1",
"description": "Syntax Highlighting in WordPress HTML Editor",
"repository": {
"type": "git",
"url": "https://github.com/arniebradfo/HESH-WordPress-Plugin.git"
},
"author": "James Bradford",
"license": "MIT",
"license": "GPL-2.0",
"bugs": {
"url": "https://github.com/arniebradfo/HESH-WordPress-Plugin/issues"
},
Expand Down
21 changes: 15 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
=== HTML Editor Syntax Highlighter ===
Contributors: nixdns, James Bradford
Contributors: nixdns, arniebradfo, collinprice
Donate link: https://www.paypal.me/mukhortov/5
Tags: editor, html editor, text editor, post editor, syntax, highlighting, highlighter, syntax highlighting, syntax highlighter, codemirror, code, code highlighter, code coloring
Requires at least: 3.3
Requires at least: 4.0.11
Tested up to: 4.5.2
Stable tag: 1.7.0
Stable tag: 1.7.1
License: GPL-2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Add syntax highlighting to the HTML editor.

Expand All @@ -15,21 +17,28 @@ Add syntax highlighting to the Post/Page HTML editor.
= Features =

* Syntax highlighting in the Post/Page HTML editor
* _NEW:_ Syntax highlighting for WordPress shortcodes
* Save your posts and pages pressing Ctrl+S (Cmd+S on Mac)
* Restore cursor position after page is reloaded
* Light and Dark editor colour themes
* New fullscreen mode.
* Toggle fullscreen mode with F11/Esc hotkeys
* _NEW:_ Huge Selection of themes
* Fullscreen mode: toggle with F11/Esc hotkeys

If you like the plugin, please [donate](https://www.paypal.me/mukhortov/5) and leave a review :)

If you would like to contribute to this plugin, view the [github repo](https://github.com/mukhortov/HESH-WordPress-Plugin).

== Installation ==

1. Upload the 'html-editor-syntax-highlighter' directory to the '/wp-content/plugins/' directory
2. Activate the plugin on the 'Plugins' page

== Changelog ==

= 1.7.1 =
* fixed bug: return key would create two new lines and ignore indent
* fixed bug: wp native "Add Media" button was not working
* added version string to .css and .js resources for cache-busting purposes

= 1.7.0 =
* Ctrl-S / Cmd-S saving will now select "Save Draft" if the post has not been published yet
* Switched to an [npm](https://www.npmjs.com/) and [grunt.js](http://gruntjs.com/) based build so new versions of CodeMirror can be applied easier
Expand Down

0 comments on commit 3201608

Please sign in to comment.