author: Sylvain Viollon
date: Fri Aug 02 17:43:42 2013 +0200
revision: 252:198a287e08b5 in silva.core.editor
branch:
details: https://hg.infrae.com/silva.core.editor?cmd=changeset;node=198a287e08b5
modified: src/silva/core/editor/static/plugins/silvaimage/dialogs/image.js src/silva/core/editor/static/plugins/silvaimage/plugin.js src/silva/core/editor/static/plugins/silvalink/dialogs/link.js src/silva/core/editor/static/plugins/silvalink/plugin.js src/silva/core/editor/static/plugins/silvautils/plugin.js src/silva/core/editor/tests/test_transform_input.py src/silva/core/editor/tests/test_transform_input_image.py src/silva/core/editor/tests/test_transform_input_link.py src/silva/core/editor/transform/editor/input.py
added:
removed:
log: Fixes, refactoring.
diffstat:
src/silva/core/editor/static/plugins/silvaimage/dialogs/image.js | 36 +-
src/silva/core/editor/static/plugins/silvaimage/plugin.js | 177 +++++----
src/silva/core/editor/static/plugins/silvalink/dialogs/link.js | 6 +-
src/silva/core/editor/static/plugins/silvalink/plugin.js | 2 +-
src/silva/core/editor/static/plugins/silvautils/plugin.js | 151 ++++++++-
src/silva/core/editor/tests/test_transform_input.py | 4 +-
src/silva/core/editor/tests/test_transform_input_image.py | 4 +-
src/silva/core/editor/tests/test_transform_input_link.py | 40 +-
src/silva/core/editor/transform/editor/input.py | 4 +-
9 files changed, 301 insertions(+), 123 deletions(-)
diffs (843 lines):
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/static/plugins/silvaimage/dialogs/image.js
--- a/src/silva/core/editor/static/plugins/silvaimage/dialogs/image.js Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/static/plugins/silvaimage/dialogs/image.js Fri Aug 02 17:43:42 2013 +0200
@@ -302,9 +302,10 @@
}
],
onShow: function() {
- var data = {};
- var editor = this.getParentEditor();
- var div = CKEDITOR.plugins.silvaimage.getCurrentImage(editor);
+ var data = {},
+ editor = this.getParentEditor(),
+ div = CKEDITOR.plugins.silvaimage.getCurrentImage(editor),
+ ALIGNEMENT = new CKEDITOR.silva.RE(/^image (.*)$/, 'default');
var defaultSettings = function() {
data.link = {};
@@ -359,13 +360,7 @@
};
if (div != null) {
- var parse_alignment = /^image\s+([a-z-]+)\s*$/;
- var info_alignment = parse_alignment.exec(
- div.getAttribute('class'));
-
- if (info_alignment != null) {
- data.image.align = info_alignment[1];
- }
+ data.image.align = ALIGNEMENT.extract(div.getAttribute('class'));
if (div.getChildCount()) {
var a = div.getChild(0);
@@ -381,7 +376,7 @@
} else {
var href = a.getAttribute('data-silva-url');
- if (!href || href == 'javascript:void()') {
+ if (!href || href == 'javascript:void(0)') {
data.link.type = 'anchor';
} else {
data.link.type = 'extern';
@@ -437,13 +432,16 @@
// We are adding a new image. Create a new div and select it.
var selection = editor.getSelection();
var ranges = selection.getRanges(true);
+ var container = new CKEDITOR.dom.element('span');
+ container.setAttributes({'class': 'inline-container image-container ' + data.image.align});
+ div = new CKEDITOR.dom.element('div');
+ div_attributes['contenteditable'] = false;
+ container.append(div);
+ ranges[0].insertNode(container);
+ selection.selectElement(container);
+ } else {
+ div.getParent().setAttribute('class', 'inline-container image-container ' + data.image.align);
- div = new CKEDITOR.dom.element('div');
- div.unselectable();
- div_attributes['contenteditable'] = false;
- ranges[0].insertNode(div);
- selection.selectElement(div);
- } else {
// Edit an image. Inspect div content.
start = 0,
node = null;
@@ -506,7 +504,7 @@
if (a == null) {
a = new CKEDITOR.dom.element('a');
- attributes['href'] = 'javascript:void()';
+ attributes['href'] = 'javascript:void(0)';
attributes['class'] = 'image-link';
div.append(a);
if (img) {
@@ -541,7 +539,7 @@
attributes_to_clean.push('data-silva-url');
break;
case 'extern':
- attributes['href'] = 'javascript:void()';
+ attributes['href'] = 'javascript:void(0)';
attributes['data-silva-url'] = data.link.url;
attributes_to_clean.push('data-silva-reference');
attributes_to_clean.push('data-silva-target');
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/static/plugins/silvaimage/plugin.js
--- a/src/silva/core/editor/static/plugins/silvaimage/plugin.js Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/static/plugins/silvaimage/plugin.js Fri Aug 02 17:43:42 2013 +0200
@@ -1,8 +1,31 @@
(function(CKEDITOR, $){
+ /**
+ * CKEditor Plugin for Images in Silva. They are represented in
+ * the editor like this:
+ *
+ * <span class="inline-container image-container alignement">
+ * <div class="image">
+ * <a class="image-link" href="">
+ * <img alt="Alt text" />
+ * </a>
+ * <span class="image-caption">Caption</span>
+ * </div>
+ * </span>
+ */
CKEDITOR.plugins.silvaimage = {
+ isImageWrapper: function(element) {
+ // Return true if the element is an image wrapper.
+ if (element != null &&
+ element.type == CKEDITOR.NODE_ELEMENT &&
+ element.is('span') &&
+ element.hasClass('image-container')) {
+ return true;
+ }
+ return false;
+ },
isImage: function(element) {
// Given an element return true if it is an image.
if (element != null &&
@@ -17,8 +40,19 @@
var image;
if (element !== null) {
+ image = element.getAscendant('span', true);
+ if (API.isImageWrapper(image)) {
+ var children = image.getChildren(),
+ i, len, child;
+ for (i=0, len=children.count(); i < len; i++) {
+ child = children.getItem(i);
+ if (API.isImage(child)) {
+ return child;
+ };
+ };
+ };
+
image = element.getAscendant('div', true);
-
if (API.isImage(image)) {
return image;
};
@@ -43,13 +77,20 @@
},
getSelectedImage: function(editor, no_selection) {
// Find the currently selected image. Correct the selection if needed.
- var selected = CKEDITOR.plugins.silvautils.getSelectedElement(editor),
- image = API.findImage(selected);
+ var selected = CKEDITOR.silva.utils.getSelectedElement(editor),
+ image = API.findImage(selected),
+ wrapper = null;
- console.log(selected && selected.$);
if (image !== null) {
- if (!no_selection && selected.$ !== image.$) {
- CKEDITOR.plugins.silvautils.selectBlock(editor, image);
+ if (!no_selection) {
+ wrapper = image.getParent();
+ if (!API.isImageWrapper(wrapper)) {
+ wrapper = image;
+ };
+ // Select the wrapper if needed.
+ if (selected.$ !== wrapper.$) {
+ CKEDITOR.silva.utils.selectBlock(editor, wrapper);
+ };
};
return image;
};
@@ -63,7 +104,7 @@
CKEDITOR.plugins.add('silvaimage', {
requires: ['dialog', 'silvautils', 'silvalink'],
init: function(editor) {
- var UTILS = CKEDITOR.plugins.silvautils;
+ var UTILS = CKEDITOR.silva.utils;
editor.addCommand(
'silvaimage',
@@ -81,37 +122,15 @@
'display: inline-block;' +
'}');
editor.addCss(
+ 'div.image img {' +
+ 'z-index: -1;' +
+ '}');
+ editor.addCss(
'div.image span.image-caption {' +
'display: block;' +
'padding-left: 5px' +
'}');
- editor.addCss(
- 'div.image.float-left {' +
- 'float: left;' +
- '}');
- editor.addCss(
- 'div.image.float-right {' +
- 'float: right;' +
- '}');
- editor.addCss(
- 'div.image.align-left {' +
- 'text-align: left;' +
- 'display: block;' +
- '}');
- editor.addCss(
- 'div.image.align-right {' +
- 'text-align: right;' +
- 'display: block;' +
- '}');
- editor.addCss(
- 'div.image.align-center {' +
- 'text-align: center;' +
- 'display: block;' +
- '}');
- editor.addCss(
- 'div.image img {' +
- 'z-index: -1;' +
- '}');
+
// Events
editor.on('selectionChange', function(event) {
var image = API.getSelectedImage(editor),
@@ -136,12 +155,17 @@
editor.on('contentDom', function() {
editor.document.on('mousedown', function(event) {
var selected,
- image = API.findImage(event.data.getTarget());
+ image = API.findImage(event.data.getTarget()),
+ wrapper;
if (image !== null) {
+ wrapper = image.getParent();
+ if (!API.isImageWrapper(wrapper)) {
+ wrapper = image;
+ };
selected = UTILS.getSelectedElement(editor);
- if (selected === null || selected.$ !== image.$) {
- UTILS.selectBlock(editor, image);
+ if (selected === null || selected.$ !== wrapper.$) {
+ UTILS.selectBlock(editor, wrapper);
};
// Prevent broken drag'n drop.
event.data.preventDefault();
@@ -150,20 +174,25 @@
});
};
editor.on('key', function(event) {
+ // Improve the navigation before and after the image with the arrows.
if (editor.mode != 'wysiwyg')
return;
var code = event.data.keyCode;
- // Improve the navigation before and after the code source with the arrows.
if (code in {9:1, 37:1, 38:1, 39:1, 40:1}) {
setTimeout(function() {
var image = API.getSelectedImage(editor, true),
+ parent = null,
on_top = code in {37:1, 38:1};
if (image !== null) {
- UTILS.selectText(editor, UTILS.getParagraph(editor, image, on_top), on_top);
+ parent = image.getParent();
+ if (!API.isImageWrapper(parent)) {
+ parent = image;
+ };
+ UTILS.selectText(editor, UTILS.getParagraph(editor, parent, on_top), on_top);
};
- }, 25);
+ }, 0);
};
});
@@ -192,10 +221,6 @@
};
},
afterInit: function(editor) {
- // Input / Output transformations
- var dataProcessor = editor.dataProcessor;
- var dataFilter = dataProcessor && dataProcessor.dataFilter;
- var htmlFilter = dataProcessor && dataProcessor.htmlFilter;
var remove = function(attributes, name) {
// Remove an attribute from an object.
@@ -203,38 +228,47 @@
delete attributes[name];
};
};
- var is_img_div = function(element) {
+ var is_container = function(element) {
// Test if the given element is an image div.
return (element &&
element.name == 'div' &&
element.attributes['class'] != undefined &&
element.attributes['class'].match('image'));
};
- var is_img_a = function(element) {
+ var is_link = function(element) {
// Test if the given element is image link.
return (element &&
element.name == 'a' &&
element.attributes['class'] == 'image-link');
};
+ // Input / Output transformations
+ var dataProcessor = editor.dataProcessor,
+ dataFilter = dataProcessor && dataProcessor.dataFilter,
+ htmlFilter = dataProcessor && dataProcessor.htmlFilter,
+ WRAPPER = new CKEDITOR.silva.parser.Wrapper(is_container, 'image-container'),
+ ALIGNEMENT = new CKEDITOR.silva.RE(/^image (.*)$/, 'default');
+
+
if (dataFilter) {
dataFilter.addRules({
elements: {
div: function(element) {
- var attributes = element.attributes;
-
- if (is_img_div(element)) {
- attributes['contenteditable'] = 'false';
+ if (is_container(element)) {
+ element.attributes['contenteditable'] = 'false';
+ return WRAPPER.wrap(
+ element,
+ ALIGNEMENT.extract(element.attributes['class']));
} else {
- remove(attributes, 'style');
+ remove(element.attributes, 'style');
};
return null;
},
img: function(element) {
- var parent = element.parent;
- var attributes = element.attributes;
+ var parent = element.parent,
+ attributes = element.attributes;
- if (!is_img_div(parent) && !is_img_a(parent)) {
+ if (!is_container(parent) && !is_link(parent)) {
// This is an image from the outside world.
// Prepare a structure.
var div = new CKEDITOR.htmlParser.fragment.fromHtml(
@@ -256,19 +290,18 @@
attributes['data-cke-saved-src'] ||
attributes['src'];
};
- return div;
- } else {
- if (!attributes['src']){
- var src = attributes['data-silva-url'] || attributes['data-silva-backup'];
- if (src) {
- attributes['src'] = src;
- attributes['data-cke-saved-src'] = src;
- };
- } else if (attributes['data-silva-reference']) {
- // Backup URL is used by reference to keep URL between
- // source and edit mode.
- attributes['data-silva-backup'] = attributes['src'];
+ return WRAPPER.wrap(div, 'default');
+ };
+ if (!attributes['src']){
+ var src = attributes['data-silva-url'] || attributes['data-silva-backup'];
+ if (src) {
+ attributes['src'] = src;
+ attributes['data-cke-saved-src'] = src;
};
+ } else if (attributes['data-silva-reference']) {
+ // Backup URL is used by reference to keep URL between
+ // source and edit mode.
+ attributes['data-silva-backup'] = attributes['src'];
};
return null;
}
@@ -278,13 +311,15 @@
if (htmlFilter) {
htmlFilter.addRules({
elements: {
+ span: function(element) {
+ return WRAPPER.remove(element);
+ },
div: function(element) {
- if (is_img_div(element)) {
- var attributes = element.attributes;
-
- remove(attributes, 'contenteditable');
- remove(attributes, 'style');
+ if (is_container(element)) {
+ remove(element.attributes, 'contenteditable');
+ remove(element.attributes, 'style');
};
+ return null;
},
a: function(element) {
var attributes = element.attributes;
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/static/plugins/silvalink/dialogs/link.js
--- a/src/silva/core/editor/static/plugins/silvalink/dialogs/link.js Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/static/plugins/silvalink/dialogs/link.js Fri Aug 02 17:43:42 2013 +0200
@@ -33,7 +33,7 @@
} else {
var href = link.getAttribute('data-silva-url');
- if (!href || href == 'javascript:void()') {
+ if (!href || href == 'javascript:void(0)') {
data.link.type = 'anchor';
} else {
data.link.type = 'extern';
@@ -49,7 +49,7 @@
},
onOk: function() {
var data = {};
- var attributes = {href: 'javascript:void()'};
+ var attributes = {href: 'javascript:void(0)'};
var attributes_to_clean = [];
var editor = this.getParentEditor();
var element = CKEDITOR.plugins.silvalink.getSelectedLink(editor);
@@ -81,7 +81,7 @@
case 'extern':
// We save the value into data-silva-url. We set the href
// attribute to get the link underlined.
- attributes['href'] = 'javascript:void()';
+ attributes['href'] = 'javascript:void(0)';
attributes['data-silva-url'] = data.link.url;
attributes_to_clean.push('data-silva-reference');
attributes_to_clean.push('data-silva-target');
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/static/plugins/silvalink/plugin.js
--- a/src/silva/core/editor/static/plugins/silvalink/plugin.js Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/static/plugins/silvalink/plugin.js Fri Aug 02 17:43:42 2013 +0200
@@ -474,7 +474,7 @@
};
if (!attributes['href']) {
// Ensure we have a disabled link;
- attributes['href'] = 'javascript:void()';
+ attributes['href'] = 'javascript:void(0)';
};
};
return null;
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/static/plugins/silvautils/plugin.js
--- a/src/silva/core/editor/static/plugins/silvautils/plugin.js Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/static/plugins/silvautils/plugin.js Fri Aug 02 17:43:42 2013 +0200
@@ -1,6 +1,106 @@
(function($, jsontemplate, CKEDITOR) {
+ /**
+ * Silva module
+ */
+ CKEDITOR.silva = {};
+
+ /**
+ * Regular expression helper.
+ */
+ CKEDITOR.silva.RE = function(pattern, fallback, position) {
+ this.pattern = pattern;
+ this.fallback = fallback;
+ this.position = position !== undefined ? position : 1;
+ };
+ CKEDITOR.silva.RE.prototype.extract = function(value) {
+ var result = this.pattern.exec(value);
+
+ if (result !== null) {
+ return result[this.position];
+ }
+ return this.fallback;
+ };
+
+ /**
+ * htmlParser helper for wrapper, used in the editor for
+ * non-editable blocks (like images and external sources).
+ */
+ CKEDITOR.silva.parser = {};
+ CKEDITOR.silva.parser.Wrapper = function(test, category) {
+ this.test = test;
+ this.category = category;
+ if (category) {
+ this.css = 'inline-container ' + category + ' ';
+ this.pattern = new RegExp('^inline-container ' + category);
+ } else {
+ this.css = 'inline-container ';
+ this.pattern = new RegExp('^inline-container');
+ };
+ };
+ CKEDITOR.silva.parser.Wrapper.prototype = {
+ /**
+ * Return true if the element is a wrapper.
+ */
+ is: function(element) {
+ return (element &&
+ element.name == 'span' &&
+ element.attributes['class'] != null &&
+ element.attributes['class'].match(this.pattern));
+ },
+ /**
+ * Wrap the element inside a wrapper.
+ */
+ wrap: function(element, alignement) {
+ var parent = element.parent,
+ container;
+
+ if (!this.is(parent)) {
+ container = new CKEDITOR.htmlParser.element(
+ 'span', {'class': this.css + alignement});
+ if (CKEDITOR.env.webkit) {
+ // To help the selection in
+ // Chrome we add a space before
+ // and after each source.
+ container.children = [
+ new CKEDITOR.htmlParser.text(''),
+ element,
+ new CKEDITOR.htmlParser.text('')];
+ } else {
+ container.children = [element];
+ };
+ if (!CKEDITOR.env.gecko) {
+ container.attributes['contenteditable'] = 'false';
+ };
+ container.parent = parent;
+ element.parent = container;
+ return container;
+ };
+ return null;
+ },
+ /**
+ * Remove an existing wrapper.
+ */
+ remove: function(element) {
+ var i, len, children = [];
+
+ if (this.is(element)) {
+ for (i=0, len=element.children.length; i < len; i++) {
+ if (this.test(element.children[i])) {
+ children.push(element.children[i]);
+ break;
+ };
+ };
+ return children[0];
+ };
+ return null;
+ }
+ };
+
+ /**
+ * Utilities functions.
+ */
if (CKEDITOR.env.ie) {
- CKEDITOR.plugins.silvautils = {
+ CKEDITOR.silva.utils = {
/**
* Return a element where the current selection points to
* (IE implementation).
@@ -85,7 +185,7 @@
}
};
} else {
- CKEDITOR.plugins.silvautils = {
+ CKEDITOR.silva.utils = {
/**
* Return a element where the current selection points to
* (non-IE implementation).
@@ -138,7 +238,7 @@
}
};
};
- CKEDITOR.plugins.silvautils = CKEDITOR.tools.extend(CKEDITOR.plugins.silvautils, {
+ CKEDITOR.silva.utils = CKEDITOR.tools.extend(CKEDITOR.silva.utils, {
/**
* Get (or add) a paragraph before (or after) the targeted
* element.
@@ -186,6 +286,51 @@
};
};
})();
+ (function() {
+ // Patch dtd. Span are like div now, because of the support for inline-container.
+ for (var key in CKEDITOR.dtd) {
+ if (!!CKEDITOR.dtd[key]['span']) {
+ delete CKEDITOR.dtd[key]['span'];
+ };
+ if (!!CKEDITOR.dtd[key]['div']) {
+ CKEDITOR.dtd[key]['span'] = 1;
+ };
+ CKEDITOR.dtd['span']['div'] = 1;
+ CKEDITOR.dtd['span']['a'] = 1; // For image link (the caption).
+ }
+ })();
+
+ /**
+ * Support for inline-container helper, used for
+ * non-editable block in CKEditor.
+ */
+ editor.addCss(
+ 'span.inline-container {' +
+ 'display: inline-block;' +
+ '}');
+ editor.addCss(
+ 'span.inline-container.float-left {' +
+ 'float: left;' +
+ '}');
+ editor.addCss(
+ 'span.inline-container.float-right {' +
+ 'float: right;' +
+ '}');
+ editor.addCss(
+ 'span.inline-container.align-left {' +
+ 'text-align: left;' +
+ 'display: block;' +
+ '}');
+ editor.addCss(
+ 'span.inline-container.align-right {' +
+ 'text-align: right;' +
+ 'display: block;' +
+ '}');
+ editor.addCss(
+ 'span.inline-container.align-center {' +
+ 'text-align: center;' +
+ 'display: block;' +
+ '}');
/**
* Support for the reference widget inside CKEditor.
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/tests/test_transform_input.py
--- a/src/silva/core/editor/tests/test_transform_input.py Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/tests/test_transform_input.py Fri Aug 02 17:43:42 2013 +0200
@@ -138,7 +138,7 @@
intern_format = self.transform(
"""
<p>
- <a class="anchor" name="simple" title="Simple Anchor" href="javascript:void()">
+ <a class="anchor" name="simple" title="Simple Anchor" href="javascript:void(0)">
Simple Anchor
</a>
The ultimate store of the anchors.
@@ -242,7 +242,7 @@
intern_format = self.transform(
"""
<p>
- <a class="anchor" name="missing" href="javascript:void()">Missing Title</a>
+ <a class="anchor" name="missing" href="javascript:void(0)">Missing Title</a>
The ultimate store of the anchors.
<a class="anchor" name="empty" title="">Empty Title</a>
<a class="anchor" name="space" title=" ">Title with a space</a>
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/tests/test_transform_input_image.py
--- a/src/silva/core/editor/tests/test_transform_input_image.py Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/tests/test_transform_input_image.py Fri Aug 02 17:43:42 2013 +0200
@@ -433,7 +433,7 @@
<a class="image-link"
data-silva-reference="%s"
data-silva-target="%s"
- href="javascript:void()">
+ href="javascript:void(0)">
<img alt="image"
data-silva-reference="%s"
data-silva-target="%s"
@@ -528,7 +528,7 @@
data-silva-reference="%s"
data-silva-target="%s"
data-silva-query="hires"
- href="javascript:void()">
+ href="javascript:void(0)">
<img alt="image"
data-silva-reference="%s"
data-silva-target="%s"
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/tests/test_transform_input_link.py
--- a/src/silva/core/editor/tests/test_transform_input_link.py Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/tests/test_transform_input_link.py Fri Aug 02 17:43:42 2013 +0200
@@ -51,7 +51,7 @@
"""
<p>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
title="Silva"
data-silva-url=" /silva/some-broken/path ">
<i>To Silva</i></a>
@@ -78,7 +78,7 @@
<p>
<a class="link broken-link"
title="Silva"
- href="javascript:void()"
+ href="javascript:void(0)"
data-silva-url="/silva/some-broken/path">
<i>To Silva</i></a>
</p>
@@ -94,7 +94,7 @@
"""
<p>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
title="Silva"
data-silva-url="mail to: /silva/some-broken/path ">
<i>To Silva</i></a>
@@ -120,7 +120,7 @@
<p>
<a class="link broken-link"
title="Silva"
- href="javascript:void()"
+ href="javascript:void(0)"
data-silva-url="broken:mail%20to:%20/silva/some-broken/path">
<i>To Silva</i></a>
</p>
@@ -136,7 +136,7 @@
"""
<p>
<a class="link broken-link"
- href="javascript:void()"
+ href="javascript:void(0)"
title="Silva"
data-silva-url="broken:mail%20to:%20/silva/some-broken/path ">
<i>To Silva</i></a>
@@ -162,7 +162,7 @@
<p>
<a class="link broken-link"
title="Silva"
- href="javascript:void()"
+ href="javascript:void(0)"
data-silva-url="broken:mail%20to:%20/silva/some-broken/path">
<i>To Silva</i></a>
</p>
@@ -175,7 +175,7 @@
"""
<p>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
title="Silva"
data-silva-url="javascript:window.open('http://hack.org') ">
<i>To Silva</i></a>
@@ -198,7 +198,7 @@
"""
<p>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
title="Silva"
data-silva-url="http://infrae.com/products/silva">
<i>To Silva</i></a>
@@ -225,7 +225,7 @@
<p>
<a class="link"
title="Silva"
- href="javascript:void()"
+ href="javascript:void(0)"
data-silva-url="http://infrae.com/products/silva">
<i>To Silva</i></a>
</p>
@@ -238,7 +238,7 @@
"""
<p>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
target="_blank"
data-silva-anchor="bar">
<b>To the nearest local bar</b></a>
@@ -266,7 +266,7 @@
<a class="link"
target="_blank"
data-silva-anchor="bar"
- href="javascript:void()">
+ href="javascript:void(0)">
<b>To the nearest local bar</b></a>
</p>
""")
@@ -279,9 +279,9 @@
"""
<p>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
target="_blank"
- data-silva-url="javascript:void()"
+ data-silva-url="javascript:void(0)"
data-silva-anchor="bar">
<b>To the nearest local bar</b></a>
</p>
@@ -310,7 +310,7 @@
"""
<p>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
data-silva-reference="new"
data-silva-target="%s">To Target</a>
</p>
@@ -350,7 +350,7 @@
<a class="link"
data-silva-reference="%s"
data-silva-target="%s"
- href="javascript:void()">
+ href="javascript:void(0)">
To Target</a>
</p>
""" % (reference_name, target_id))
@@ -377,7 +377,7 @@
extern_format,
"""
<p>
- <a class="link broken-link" data-silva-reference="broken-link-id" data-silva-target="0" data-silva-anchor="world" href="javascript:void()">
+ <a class="link broken-link" data-silva-reference="broken-link-id" data-silva-target="0" data-silva-anchor="world" href="javascript:void(0)">
Access the world
</a>
</p>
@@ -458,7 +458,7 @@
data-silva-reference="original-link-id"
data-silva-target="%s"
data-silva-anchor="world"
- href="javascript:void()">
+ href="javascript:void(0)">
Access the world</a>
</p>
""" % (target_id))
@@ -521,7 +521,7 @@
data-silva-anchor="world"
data-silva-target="%s">Access the world</a>
<a class="link"
- href="javascript:void()"
+ href="javascript:void(0)"
data-silva-reference="original-link-id"
data-silva-target="%s">Other part of the world</a>
</p>
@@ -555,11 +555,11 @@
data-silva-reference="original-link-id"
data-silva-target="%s"
data-silva-anchor="world"
- href="javascript:void()">Access the world</a>
+ href="javascript:void(0)">Access the world</a>
<a class="link"
data-silva-reference="%s"
data-silva-target="%s"
- href="javascript:void()">Other part of the world</a>
+ href="javascript:void(0)">Other part of the world</a>
</p>
""" % (target_id, reference_name, target_id))
diff -r dcaecb1a2e77 -r 198a287e08b5 src/silva/core/editor/transform/editor/input.py
--- a/src/silva/core/editor/transform/editor/input.py Fri Aug 02 13:29:48 2013 +0200
+++ b/src/silva/core/editor/transform/editor/input.py Fri Aug 02 17:43:42 2013 +0200
@@ -44,7 +44,7 @@
link.attrib['data-silva-anchor'] = link.attrib['anchor']
del link.attrib['anchor']
# Ensure href is always disabled.
- link.attrib['href'] = 'javascript:void()'
+ link.attrib['href'] = 'javascript:void(0)'
class AnchorTransformer(TransformationFilter):
@@ -124,4 +124,4 @@
link.attrib['data-silva-anchor'] = link.attrib['anchor']
del link.attrib['anchor']
# Ensure link is always disabled.
- link.attrib['href'] = 'javascript:void()'
+ link.attrib['href'] = 'javascript:void(0)'
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.