mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 23:02:45 +00:00
Added a bunch of random generators
This commit is contained in:
@@ -1,69 +1,8 @@
|
||||
var React = require('react');
|
||||
var _ = require('lodash');
|
||||
var cx = require('classnames');
|
||||
var SnippetIcons = require('./snippets/snippets.js');
|
||||
|
||||
var Snippets = require('./snippets.js');
|
||||
|
||||
|
||||
var Icons = [
|
||||
{
|
||||
icon : 'fa-book',
|
||||
snippet : Snippets.intro,
|
||||
tooltip : 'Intro'
|
||||
},
|
||||
{
|
||||
icon : 'fa-magic',
|
||||
snippet : Snippets.spell,
|
||||
tooltip : 'Spell'
|
||||
},
|
||||
{
|
||||
icon : 'fa-bookmark',
|
||||
snippet : Snippets.classFeatures,
|
||||
tooltip : 'Class Intro'
|
||||
},
|
||||
{
|
||||
icon : 'fa-trophy',
|
||||
snippet : Snippets.destroyUndead,
|
||||
tooltip : 'Class Feature'
|
||||
},
|
||||
{
|
||||
icon : 'fa-sticky-note',
|
||||
snippet : Snippets.note,
|
||||
tooltip : 'Note'
|
||||
},
|
||||
{
|
||||
icon : 'fa-bug',
|
||||
snippet : Snippets.statBlock,
|
||||
tooltip : 'Monster Stat Block'
|
||||
},
|
||||
{
|
||||
icon : 'fa-table',
|
||||
snippet : Snippets.classTable,
|
||||
tooltip : "Class Table"
|
||||
},
|
||||
{
|
||||
icon : 'fa-columns',
|
||||
snippet : "```\n```\n\n",
|
||||
tooltip : "Column Break"
|
||||
},
|
||||
{
|
||||
icon : 'fa-file-text',
|
||||
snippet : "\\pagen\n\n",
|
||||
tooltip : "New Page"
|
||||
},
|
||||
{
|
||||
icon : 'fa-arrows-v',
|
||||
snippet : "<div style='margin-top:140px'></div>\n\n",
|
||||
tooltip : "Vertical Spacing"
|
||||
},
|
||||
{
|
||||
icon : 'fa-image',
|
||||
snippet : "<img />",
|
||||
tooltip : "Insert Image"
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
|
||||
var Editor = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
@@ -81,15 +20,15 @@ var Editor = React.createClass({
|
||||
this.props.onChange(e.target.value);
|
||||
},
|
||||
|
||||
iconClick : function(snippet){
|
||||
iconClick : function(snippetFn){
|
||||
var curPos = this.refs.textarea.selectionStart;
|
||||
this.props.onChange(this.props.text.slice(0, curPos) +
|
||||
snippet +
|
||||
snippetFn() +
|
||||
this.props.text.slice(curPos + 1));
|
||||
},
|
||||
|
||||
renderTemplateIcons : function(){
|
||||
return _.map(Icons, (t) => {
|
||||
return _.map(SnippetIcons, (t) => {
|
||||
return <div className='icon' key={t.icon}
|
||||
onClick={this.iconClick.bind(this, t.snippet)}
|
||||
data-tooltip={t.tooltip}>
|
||||
@@ -104,7 +43,6 @@ var Editor = React.createClass({
|
||||
<div className='editor'>
|
||||
<div className='textIcons'>
|
||||
{this.renderTemplateIcons()}
|
||||
|
||||
</div>
|
||||
<textarea
|
||||
ref='textarea'
|
||||
|
||||
Reference in New Issue
Block a user