Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Removes lodash as a dependency. Updates to Node 5. Merges in master
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Rees committed Apr 26, 2016
2 parents c67fc93 + 7c50acd commit 1f8760b
Show file tree
Hide file tree
Showing 18 changed files with 370 additions and 28 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
# 2.3.0

Introduces a destroy event that plugins can use to clean up after themselves.

This re-implements an initial implementation by [Craig Speath](https://github.com/craigspaeth), thanks for the contribution.

# 2.2.5

Switches the events from literal strings to using identities from an events module.

# 2.2.4

Attempts to simplify the code in the `inline-elements-mode` plugin as per the suggestions from [Rasmus Schultz](https://github.com/mindplay-dk).

This change also covers the code with a unit test in case it needs to be modified in future.

# 2.2.3

Removes unneeded paramters from calls to `setStartAfter` and `setEndAfter`.

Thanks to [Rasmus Schultz](https://github.com/mindplay-dk) for reporting the issue.

# 2.2.2

Removes the observable check function introduced in 2.1.0. As this was not exported I'm treating it as a non-breaking change.

# 2.2.1

Corrects a small style issue where one of the tests was relying on the default coercion of the empty string to the false boolean. The test is now explicit.

# 2.2.0

Addresses issue #456 where one of the core plugins (enforce-p-elements) would wrap empty text nodes in paragraph elements. This behaviour was hidden by the use of the HTML Sanitizer.

Text nodes consisting just of whitespace are not changed now when the plugin runs.

Thanks to [Rasmus Schultz](https://github.com/mindplay-dk) for reporting the issue.

# 2.1.2

Fixes an issue where the undo manager could not be disabled due to an unconditional execution of the manager code in the setHTML method (issue #452).
Expand Down
20 changes: 15 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ module.exports = function(grunt) {
src: ['test/**/*.spec.js']
}
},
requirejs: {
});

function requireConfiguration(optimize, outputFilename) {
return {
compile: {
options: {
baseUrl: "src",
Expand All @@ -23,15 +26,22 @@ module.exports = function(grunt) {
'lodash-amd': '../bower_components/lodash-amd',
'immutable': '../bower_components/immutable/dist/immutable'
},
optimize: "none",
optimize: optimize,
preserveLicenseComments: false,
generateSourceMaps: true,
out: "dist/scribe.js"
out: "build/" + outputFilename
}
}
}
});
}

grunt.registerTask('build', ['requirejs']);
grunt.registerTask('build', 'Build output files', function() {
grunt.config('requirejs', requireConfiguration('uglify2', 'scribe.min.js'));
grunt.task.run('requirejs');

grunt.config('requirejs', requireConfiguration('none', 'scribe.js'));
grunt.task.run('requirejs');
});

grunt.registerTask('test', ['mochaTest']);

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Scribe [![Build Status](https://travis-ci.org/guardian/scribe.svg?branch=master)](https://travis-ci.org/guardian/scribe)
Scribe [![Build Status](https://travis-ci.org/guardian/scribe.svg?branch=master)](https://travis-ci.org/guardian/scribe) <img src="https://david-dm.org/guardian/scribe.svg">
======

[![Join the chat at https://gitter.im/guardian/scribe](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/guardian/scribe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down
8 changes: 8 additions & 0 deletions decisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Decisions log

## 2016-04-16 Event namespacing

Events in Scribe are generally only propogated within the Scribe instance so we haven't namespaced them before. However within the Guardian products that Scribe is used we do tend to namespace all events as we have had problems with event clashes between browser extensions/add-ons and third-party code.

Therefore without removing the current legacy `content-changed` event, which would cause too much grief in the plugin ecosystem, event names in Scribe will now be prefixed with "scribe".
106 changes: 106 additions & 0 deletions examples/amd-inline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!--
This example demonstrates how to consume the Scribe
editor using RequireJS and the AMD module syntax.
Note that you'll need to install scribe's dependencies through
`bower install`. See http://bower.io/ if you are unfamiliar.
-->
<style>
button {
height: 3em;
}

.active {
border-style: inset;
}

.rte, .rte-toolbar {
display: block;
}

p {
margin-top: 0;
}

.rte {
border: 1px solid gray;
height: 300px;
overflow: auto;
}
.rte-output {
width: 100%;
height: 10em;
}
</style>
<script src="../bower_components/requirejs/require.js"></script>
<script>
require({
paths: {
'scribe-common': '../bower_components/scribe-common',
'lodash-amd': '../bower_components/lodash-amd',
'html-janitor': '../bower_components/html-janitor/html-janitor',
'immutable': '../bower_components/immutable/dist/immutable'
}
}, [
'../src/scribe',
'../bower_components/scribe-plugin-toolbar/src/scribe-plugin-toolbar',
'../bower_components/scribe-plugin-formatter-plain-text-convert-new-lines-to-html/src/scribe-plugin-formatter-plain-text-convert-new-lines-to-html',
'../bower_components/scribe-plugin-sanitizer/src/scribe-plugin-sanitizer',
'../bower_components/scribe-plugin-inline-styles-to-elements/src/scribe-plugin-inline-styles-to-elements',
'../bower_components/scribe-plugin-heading-command/src/scribe-plugin-heading-command',
'../bower_components/scribe-plugin-link-prompt-command/src/scribe-plugin-link-prompt-command',
'../bower_components/scribe-plugin-blockquote-command/src/scribe-plugin-blockquote-command'

], function (
Scribe,
scribePluginToolbar,
scribePluginFormatterPlainTextConvertNewLinesToHtml,
scribePluginSanitizer,
scribePluginInlineStyles,
scribePluginHeadingCommand,
scribePluginLinkPromptCommand,
scribePluginBlockquoteCommand
) {
var scribe = new Scribe(document.querySelector('.rte'),
{allowBlockElements: false});
window.scribe = scribe;

scribe.setContent('<p>Hello, World!<\/p>');

scribe.use(scribePluginToolbar(document.querySelector('.rte-toolbar')));
scribe.use(scribePluginFormatterPlainTextConvertNewLinesToHtml());
scribe.use(scribePluginInlineStyles());
scribe.use(scribePluginHeadingCommand(2));
scribe.use(scribePluginBlockquoteCommand());
scribe.use(scribePluginSanitizer({ tags: {
p: {},
b: {},
i: {},
br: {},
h2: {},
a: {},
blockquote: {}
}}));
scribe.use(scribePluginLinkPromptCommand());

scribe.on('content-changed', updateHtml);

function updateHtml() {
document.querySelector('.rte-output').value = scribe.getHTML();
}

updateHtml();
});
</script>
<div class="rte-toolbar">
<button data-command-name="bold">Bold</button>
<button data-command-name="italic">Italic</button>
<button data-command-name="linkPrompt">Link</button>
<button data-command-name="h2">H2</button>
<button data-command-name="blockquote">Blockquote</button>
</div>
<div class="rte"></div>
<section>
<h1>Output</h1>
<textarea class="rte-output" readonly></textarea>
</section>
2 changes: 2 additions & 0 deletions examples/amd.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Note that you'll need to install scribe's dependencies through
`bower install`. See http://bower.io/ if you are unfamiliar.
-->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<style>
button {
height: 3em;
Expand Down
3 changes: 1 addition & 2 deletions examples/build.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'lodash-amd': '../bower_components/lodash-amd',
'html-janitor': '../bower_components/html-janitor/html-janitor',
'immutable': '../bower_components/immutable/dist/immutable',
'scribe': '../dist/scribe'
'scribe': '../build/scribe'
}
}, [
'scribe',
Expand All @@ -63,7 +63,6 @@
scribePluginLinkPromptCommand,
scribePluginBlockquoteCommand
) {
console.log(Scribe);

var scribe = new Scribe(document.querySelector('.rte'));
window.scribe = scribe;
Expand Down
89 changes: 89 additions & 0 deletions examples/raw.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!--
This example demonstrates how to consume the Scribe
editor using RequireJS and the AMD module syntax.
Note that you'll need to install scribe's dependencies through
`bower install`. See http://bower.io/ if you are unfamiliar.
-->
<style>
button {
height: 3em;
}

.active {
border-style: inset;
}

.rte, .rte-toolbar {
display: block;
}

p {
margin-top: 0;
}

.rte {
border: 1px solid gray;
height: 300px;
overflow: auto;
}
.rte-output {
width: 100%;
height: 10em;
}

.raw-content-editable {
width: 100%;
min-height: 2rem;
border: solid 1px lightgray;
}
</style>
<script src="../bower_components/requirejs/require.js"></script>
<script>
require({
paths: {
'lodash-amd': '../bower_components/lodash-amd',
'immutable': '../bower_components/immutable/dist/immutable'
}
}, [
'../src/scribe',
'../bower_components/scribe-plugin-toolbar/src/scribe-plugin-toolbar',
'../bower_components/scribe-plugin-formatter-plain-text-convert-new-lines-to-html/src/scribe-plugin-formatter-plain-text-convert-new-lines-to-html',
], function (
Scribe,
scribePluginToolbar
) {
var scribe = new Scribe(document.querySelector('.rte'));
window.scribe = scribe;

scribe.setContent('<p>Hello, World!<\/p>');

scribe.use(scribePluginToolbar(document.querySelector('.rte-toolbar')));

scribe.on('content-changed', updateHtml);

function updateHtml() {
document.querySelector('.rte-output').value = scribe.getHTML();
}

updateHtml();
});
</script>
<div class="rte-toolbar">
<button data-command-name="bold">Bold</button>
<button data-command-name="italic">Italic</button>
<button data-command-name="h2">H2</button>
</div>
<div class="rte">
</div>

<section>
<h1>Output</h1>
<textarea class="rte-output" readonly></textarea>
</section>

<section>
<h1>Basic content-editable</h1>

<div class="raw-content-editable" contenteditable="true"></div>
</section>
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "scribe-editor",
"version": "2.1.2",
"version": "2.3.0",
"license": "Apache-2.0",
"main": "src/scribe.js",
"dependencies": {
"lodash-amd": "~3.5.0",
"immutable": "~3.7.3"
},
"devDependencies": {
Expand All @@ -17,7 +16,7 @@
"http-server": "~0.6.1",
"lodash-node": "~2.4.1",
"mocha": "~2.4",
"mock-browser": "0.90.33",
"mock-browser": "0.92.11",
"mversion": "~0.4.3",
"node-amd-require": "^0.2.2",
"npm": "^2.5.0",
Expand Down
10 changes: 10 additions & 0 deletions src/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
define([], function() {

'use strict';

return {
contentChanged: "scribe:content-changed",
legacyContentChanged: "content-changed",
destroy: "scribe:destroy"
};
});
Loading

0 comments on commit 1f8760b

Please sign in to comment.