Skip to content

Commit

Permalink
Merge branch 'hotfix-1.0.x' into hotfix-1.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Kaszt committed Apr 21, 2015
2 parents d8f5514 + f849679 commit 7401b25
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 14 deletions.
4 changes: 4 additions & 0 deletions build/changelog/entries/2015/04/10220.SUP-845.bugfix
@@ -0,0 +1,4 @@
The Word content handler now replaces unnecessary new line characters
added by Word with spaces. This fixes bug SUP-845, in which spaces got
lost, because new line characters are automatically stripped when using
the Text/HTML GCN tag part type.
4 changes: 4 additions & 0 deletions build/changelog/entries/2015/04/10221.SUP-827.bugfix
@@ -0,0 +1,4 @@
When a URL was pasted into the input field of the toolbar
using the context menu, the URL was not stored into the link, unless
a key was also pressed.
This has been fixed now.
15 changes: 15 additions & 0 deletions build/changelog/mappings/1.0.15.json
@@ -0,0 +1,15 @@
{
"version": "1.0.15",
"date": "15.04.2015",
"changeLogEntryFileNames": [
"10217.SUP-763.bugfix",
"10216.SUP-749.bugfix",
"10210.SUP-158.bugfix",
"10214.SUP-744.enhancement",
"10211.SUP-158.bugfix",
"10218.SUP-763.bugfix",
"10213.SUP-143.bugfix",
"10212.SUP-740.bugfix"
],
"genericProperties": {}
}
24 changes: 24 additions & 0 deletions src/plugins/common/contenthandler/lib/wordcontenthandler.js
Expand Up @@ -159,6 +159,29 @@ define([
}
}

/**
* Replaces unnecessary new line characters within text nodes in Word HTML
* with a space.
*
* @param {jQuery.<HTMLElement>} $content
*/
function replaceWordNewLines($content) {
var i;
var $nodes = $content.contents();
var node;

for (i = 0; i < $nodes.length; i++) {
node = $nodes[i];

if (Node.TEXT_NODE === node.nodeType) {
var text = node.nodeValue;
node.nodeValue = text.replace(/[\r\n]+/gm, ' ');
} else {
replaceWordNewLines($nodes.eq(i));
}
}
}

/**
* Cleanup MS Word HTML.
*
Expand Down Expand Up @@ -198,6 +221,7 @@ define([
}

removeUnrenderedChildNodes($content);
replaceWordNewLines($content);
}

/**
Expand Down
40 changes: 26 additions & 14 deletions src/plugins/common/ui/lib/port-helper-attribute-field.js
Expand Up @@ -131,7 +131,8 @@ define([
.bind("focus", onFocus)
.bind("blur", onBlur)
.bind("keydown", onKeyDown)
.bind("keyup", onKeyup);
.bind("keyup", onKeyup)
.bind("change", onChange);

setPlaceholder();

Expand All @@ -140,6 +141,25 @@ define([
// TODO unbind, otherwise mermory leak
Aloha.bind('aloha-editable-deactivated', onBlur);

/**
* Update the attribute in the target element
*/
function updateTarget() {
// If this attribute field currently refers to a repository
// item, and the user edits the contents of the input field,
// this attribute field seizes to refer to the repository item.
if (resourceItem && resourceValue !== getValue()) {
resourceItem = null;
resourceValue = null;
}

// This handles attribute updates for non-repository, literal urls typed into the input field.
// Input values that refer to a repository item are handled via setItem().
if ( ! resourceItem ) {
setAttribute(targetAttribute, getValue());
}
}

function onSelect(event, ui) {
if (ui.item) {
setItem(ui.item.obj);
Expand Down Expand Up @@ -180,19 +200,7 @@ define([
}

function onKeyup(event) {
// If this attribute field currently refers to a repository
// item, and the user edits the contents of the input field,
// this attribute field seizes to refer to the repository item.
if (resourceItem && resourceValue !== getValue()) {
resourceItem = null;
resourceValue = null;
}

// This handles attribute updates for non-repository, literal urls typed into the input field.
// Input values that refer to a repository item are handled via setItem().
if ( ! resourceItem ) {
setAttribute(targetAttribute, getValue());
}
updateTarget();

if ( ( event.keyCode == 13 || event.keyCode == 27 ) ) {
// Set focus to link element and select the object
Expand All @@ -201,6 +209,10 @@ define([
}
}

function onChange(event) {
updateTarget();
}

function finishEditing() {
restoreTargetBackground();

Expand Down

0 comments on commit 7401b25

Please sign in to comment.