Skip to content

Commit 03fc651

Browse files
author
Tom Boutell
committed
When you paste text from a website you tend to lose it all if you then add a widget above it. This is because paragraph tags creep in and get nested under divs. Fix that by adding p tags to the list of tags we hoist to the top level. Unfortunately there is a new issue which is that if you paste multiple paragraphs, the caret winds up positioned after the first one, because rangy isn't quite smart enough at saving and restoring it. TODO: write our own save and restore for the case of a collapsed range that is smart enough.
1 parent 9d1d853 commit 03fc651

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

public/js/editor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ apos.Editor = function(options) {
270270
// blowtorch, except during resize when it breaks preview of resize
271271

272272
if (!resizing) {
273-
apos.log('torching');
274273
self.$editable.find('[style]').removeAttr('style');
275274
}
276275

@@ -279,12 +278,12 @@ apos.Editor = function(options) {
279278
// Flatten the DOM, but don't tangle with anything inside a
280279
// apos-widget. apos-widgets themselves are fair game.
281280

282-
self.$editable.find('h1, h2, h3, h4, h5, h6, div').each(function() {
281+
self.$editable.find('h1, h2, h3, h4, h5, h6, div, p').each(function() {
283282
var outer = $(this);
284283
if (outer.closest('.apos-widget').length) {
285284
return;
286285
}
287-
$(this).find('h1, h2, h3, h4, h5, h6, div').each(function() {
286+
$(this).find('h1, h2, h3, h4, h5, h6, div, p').each(function() {
288287
var inner = $(this);
289288
if (inner.parents('.apos-widget').length) {
290289
return;

0 commit comments

Comments
 (0)