This repository has been archived by the owner on Jun 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Builtin-plugins: stop wrapping whitespace text nodes
Issue #456 revealed some strange behaviour that is normally masked by the use of the Sanitizer plugin (hence the addition of a test page that is minimal in terms of plugins). This turned out to be because we were wrapping text nodes that had no content. To fix the issue these nodes are currently ignore in the wrapping process but it would probably be better to delete them from the content. The easiest way I've found to have this be repeatable is to change the default content to contain some indented paragraphs. If you then bold any word in the content all the whitespace becomes wrapped in a paragraph creating noticeable changes to the visual spacing.
- Loading branch information
Robert Rees
committed
Mar 13, 2016
1 parent
6127eb2
commit 63ea4cb
Showing
4 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63ea4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :-)