Skip to content

Commit

Permalink
source maps loaded into package json, and moved the markdown configs …
Browse files Browse the repository at this point in the history
…object on to ss global
  • Loading branch information
fonsekaean committed Oct 26, 2017
1 parent be9dad9 commit b81f566
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 34 deletions.
4 changes: 2 additions & 2 deletions client/dist/bundle.min.js

Large diffs are not rendered by default.

66 changes: 34 additions & 32 deletions client/src/components/MarkdownEditorField/MarkdownEditorField.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,60 @@ import { provideInjector } from 'lib/Injector';
import jQuery from 'jquery';


var ss = typeof window.ss !== 'undefined' ? window.ss : {};
if(typeof ss.markdownConfigs == 'undefined') {
ss.markdownConfigs = {};
}


const markdownConfigs = {
readToolbarConfigs: function(feed) {
let data = JSON.parse(feed);
let toolbar = [];
ss.markdownConfigs.readToolbarConfigs = function(feed) {
let data = JSON.parse(feed);
let toolbar = [];

for (var key in data) {
var element = data[key];
if(typeof element == 'string') {
toolbar.push(element);
for (var key in data) {
var element = data[key];
if(typeof element == 'string') {
toolbar.push(element);
}
else {
let action = element.action;
if(typeof SimpleMDE[element.action] !== 'undefined') {
toolbar.push({
name : element.name,
action : SimpleMDE[element.action],
className : element.className,
title : element.title
});
}
else {
let action = element.action;
if(typeof SimpleMDE[element.action] !== 'undefined') {
toolbar.push({
name : element.name,
action : SimpleMDE[element.action],
className : element.className,
title : element.title
});
}
else if(typeof markdownConfigs[element.action] !== 'undefined') {
toolbar.push({
name : element.name,
action : function(editor){
markdownConfigs[action](editor);
},
className : element.className,
title : element.title
});
}
else if(typeof ss.markdownConfigs[element.action] !== 'undefined') {
toolbar.push({
name : element.name,
action : function(editor){
ss.markdownConfigs[action](editor);
},
className : element.className,
title : element.title
});
}
}
return toolbar;
}
return toolbar;
}



class MarkdownEditorField extends React.Component {
constructor(props) {
super(props);
this.state = markdownConfigs;
this.state = ss.markdownConfigs;
}

handleChange(value) {
this.props.textarea.value = value;
}

static addCustomAction(key, action) {
markdownConfigs[key] = action;
ss.markdownConfigs[key] = action;
};

render() {
Expand Down Expand Up @@ -128,7 +130,7 @@ jQuery.entwine('ss', ($) => {
},
refresh() {
let textArea = $(this).parent().find('textarea')[0];
let toolbar = markdownConfigs.readToolbarConfigs(textArea.dataset.config);
let toolbar = ss.markdownConfigs.readToolbarConfigs(textArea.dataset.config);

ReactDOM.render(
<MarkdownEditorField textarea={textArea} toolbar={toolbar}></MarkdownEditorField>,
Expand Down
145 changes: 145 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"gulp-sass": "^2.3.2",
"gulp-sass-unicode": "^1.0.1",
"gulp-uglify": "^2.1.2",
"gulp-sourcemaps": "^2.6.1",
"react-redux": "^5.0.2",
"react-router": "^3.0.2",
"react-router-redux": "^4.0.7",
Expand Down
15 changes: 15 additions & 0 deletions src/forms/MarkdownEditorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public static function get_active_identifier()
return $identifier;
}

/**
* @return MarkdownEditorConfig
*/
public static function get_active()
{
$identifier = self::get_active_identifier();
Expand Down Expand Up @@ -162,6 +165,18 @@ public function getConfig()
return $this->settings;
}

public function addSeparator()
{
array_push($this->settings, '|');
return $this;
}

public function addButton($button)
{
array_push($this->settings, $button);
return $this;
}

public function getAttributes()
{
return [
Expand Down

0 comments on commit b81f566

Please sign in to comment.