Commit 3d40e26c authored by Martin's avatar Martin

record new upstream branch created by importing...

record new upstream branch created by importing trac-wysiwyg_0.12.0.5+r15671.orig.tar.gz and merge it
parents 81b5a97d 28f3b1ec
......@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
setup(
name = 'TracWysiwyg',
version = '0.10.0.3',
version = '0.10.0.5',
description = 'TracWiki WYSIWYG Editor',
license = 'BSD',
url = 'http://trac-hacks.org/wiki/TracWysiwygPlugin',
......
......@@ -3,6 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tracwysiwyg test</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="./chrome/common/css/trac.css" type="text/css" />
<link rel="stylesheet" href="../tracwysiwyg/htdocs/wysiwyg.css" type="text/css" />
<script type="text/javascript" src="./trac.js"></script>
......
......@@ -1430,6 +1430,17 @@ addEvent(window, "load", function() {
assertRangeText(" fox jumps over t", paragraph1, 3, paragraph1.childNodes[4], 2);
});
unit.add("insertHTML", function() {
var d = instance.contentDocument;
var body = d.body;
while (body.childNodes.length > 0) {
body.removeChild(body.lastChild);
}
instance.insertHTML('<p>blah</p>');
var paragraph1 = body.childNodes[0];
unit.assertEqual('blah', paragraph1.innerHTML);
});
unit.run();
}
......
# -*- coding: utf-8 -*-
from fnmatch import fnmatch
import re
from trac.core import Component, implements
......@@ -19,6 +20,11 @@ class WysiwygModule(Component):
wysiwyg_stylesheets = ListOption('tracwysiwyg', 'wysiwyg_stylesheets',
doc="""Add stylesheets to the WYSIWYG editor""")
templates = ListOption('tracwysiwyg', 'templates', doc="""\
List of template names that the plugin will show a WYSIWYG editor
on each TracWiki textarea. The plugin shows on all pages by
default.""")
# ITemplateProvider#get_htdocs_dirs
def get_htdocs_dirs(self):
from pkg_resources import resource_filename
......@@ -34,6 +40,9 @@ class WysiwygModule(Component):
# IRequestFilter#post_process_request
def post_process_request(self, req, template, content_type):
if not _is_wysiwyg_enabled(template, self.templates):
return template, content_type
add_link(req, 'tracwysiwyg-base', req.href() or '/')
stylesheets = ['chrome/common/css/trac.css', 'chrome/tracwysiwyg/editor.css']
stylesheets += self.wysiwyg_stylesheets
......@@ -43,7 +52,7 @@ class WysiwygModule(Component):
add_script(req, 'tracwysiwyg/wysiwyg.js')
footer = req.hdf['project.footer'] + '<script type="text/javascript">TracWysiwyg.initialize();</script>'
req.hdf['project.footer'] = Markup(footer)
return (template, content_type)
return template, content_type
def _expand_filename(req, filename):
......@@ -56,3 +65,13 @@ def _expand_filename(req, filename):
return req.href(filename)
def _is_wysiwyg_enabled(template, patterns):
if not patterns:
return True
for pattern in patterns:
positive = not pattern.startswith('!')
if not positive:
pattern = pattern[1:]
if fnmatch(template, pattern):
return positive
return False
......@@ -128,6 +128,5 @@ iframe.wysiwyg:focus {
.wysiwyg-menu a:hover, .wysiwyg-menu .selected a:hover {
border: 1px solid #fb2;
}
.wysiwyg-menu .menu {
font-size: 85%;
}
.wysiwyg-menu ul { font-size: 85% }
.wysiwyg-menu ul ul { font-size: 100% }
var TracWysiwyg = function(textarea) {
var self = this;
var editorMode = TracWysiwyg.getEditorMode();
textarea.setAttribute('data-tracwysiwyg-initialized', 'doing');
this.autolink = true;
this.textarea = textarea;
var wikitextToolbar = textarea.previousSibling;
......@@ -94,6 +94,9 @@ var TracWysiwyg = function(textarea) {
alert("Failed to activate the wysiwyg editor.");
throw exception;
}
else {
textarea.setAttribute('data-tracwysiwyg-initialized', 'done');
}
}
else {
setTimeout(lazySetup, 100);
......@@ -283,7 +286,7 @@ TracWysiwyg.prototype.createStyleMenu = function(d) {
TracWysiwyg.prototype.createDecorationMenu = function(d) {
var html = [
'<ul class="menu">',
'<ul>',
'<li><a id="wt-strike" href="#">Strike through</a></li>',
'<li><a id="wt-sup" href="#">Superscript</a></li>',
'<li><a id="wt-sub" href="#">Subscript</a></li>',
......@@ -297,7 +300,7 @@ TracWysiwyg.prototype.createDecorationMenu = function(d) {
TracWysiwyg.prototype.createTableMenu = function(d) {
var html = [
'<ul class="menu">',
'<ul>',
'<li><a id="wt-insert-row-before" href="#">Insert row before</a></li>',
'<li><a id="wt-insert-row-after" href="#">Insert row after</a></li>',
'<li><a id="wt-insert-col-before" href="#">Insert column before</a></li>',
......@@ -318,15 +321,16 @@ TracWysiwyg.prototype.setupMenuEvents = function() {
addEvent(element, "click", function(event) {
var w = self.contentWindow;
TracWysiwyg.stopEvent(event || w.event);
var keepMenus = false, exception;
try { keepMenus = method.apply(self, args) } catch (e) { exception = e }
if (!keepMenus) {
self.hideAllMenus();
var keepMenus = false;
try {
keepMenus = method.apply(self, args);
}
element.blur();
w.focus();
if (exception) {
throw exception;
finally {
if (!keepMenus) {
self.hideAllMenus();
}
element.blur();
w.focus();
}
});
}
......@@ -2836,6 +2840,36 @@ TracWysiwyg.prototype.domToWikitext = function(root, options) {
return texts.join("").replace(/^(?: *\n)+|(?: *\n)+$/g, "");
};
TracWysiwyg.prototype._msieInsertHTML = function(html) {
this.contentWindow.focus();
var selection = this.contentDocument.selection;
var range = selection.createRange();
range.pasteHTML(html.replace(/\t/g, "&#9;"));
range.collapse(false);
range.select();
};
TracWysiwyg.prototype._fragmentInsertHTML = function(html) {
var range = this.getNativeSelectionRange();
if (range) {
var d = this.contentDocument;
var tmp = d.createRange();
tmp.setStart(d.body, 0);
tmp.setEnd(d.body, 0);
var fragment = tmp.createContextualFragment(html);
range.deleteContents();
range.insertNode(fragment);
range.detach();
tmp.detach();
}
};
TracWysiwyg.prototype.insertLineBreak = function() {
this.insertHTML('<br>');
};
TracWysiwyg.prototype.insertLineBreakOnShiftEnter = null;
if (window.getSelection) {
TracWysiwyg.prototype.appendBogusLineBreak = function(element) {
var wikiInlineTags = this.wikiInlineTags;
......@@ -2903,13 +2937,7 @@ if (window.getSelection) {
TracWysiwyg.prototype.getFocusNode = function() {
return this.contentWindow.getSelection().focusNode;
};
if (window.opera) {
TracWysiwyg.prototype.insertLineBreak = function() {
this.execCommand("inserthtml", "<br>");
};
TracWysiwyg.prototype.insertLineBreakOnShiftEnter = null;
}
else if (window.getSelection().setBaseAndExtent) { // Safari 2+
if (window.getSelection().setBaseAndExtent) { // Safari 2+
TracWysiwyg.prototype.insertLineBreak = function() {
this.execCommand("insertlinebreak");
};
......@@ -2918,15 +2946,6 @@ if (window.getSelection) {
TracWysiwyg.stopEvent(event);
};
}
else { // Firefox 2+
TracWysiwyg.prototype.insertLineBreak = function() {
var d = this.contentDocument;
var event = d.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false, true, false, 0x000d, 0);
d.body.dispatchEvent(event);
};
TracWysiwyg.prototype.insertLineBreakOnShiftEnter = null;
}
if (window.getSelection().removeAllRanges) {
TracWysiwyg.prototype.selectNode = function(node) {
var selection = this.contentWindow.getSelection();
......@@ -2968,9 +2987,17 @@ if (window.getSelection) {
selection.addRange(range);
}
};
TracWysiwyg.prototype.insertHTML = function(html) {
this.execCommand("inserthtml", html);
};
if (window.TextRange === undefined || !TextRange.prototype.pasteHTML) {
TracWysiwyg.prototype.insertHTML = function(html) {
this.execCommand("inserthtml", html);
};
}
else if (document.selection === undefined) { // Internet Explorer 11
TracWysiwyg.prototype.insertHTML = TracWysiwyg.prototype._fragmentInsertHTML;
}
else { // Internet Explorer 9 or 10
TracWysiwyg.prototype.insertHTML = TracWysiwyg.prototype._msieInsertHTML;
}
}
else { // Safari 2
TracWysiwyg.prototype.selectNode = function(node) {
......@@ -3015,20 +3042,7 @@ if (window.getSelection) {
range.detach();
}
};
TracWysiwyg.prototype.insertHTML = function(html) {
var range = this.getNativeSelectionRange();
if (range) {
var d = this.contentDocument;
var tmp = d.createRange();
tmp.setStart(d.body, 0);
tmp.setEnd(d.body, 0);
var fragment = tmp.createContextualFragment(html);
range.deleteContents();
range.insertNode(fragment);
range.detach();
tmp.detach();
}
};
TracWysiwyg.prototype.insertHTML = TracWysiwyg.prototype._fragmentInsertHTML;
}
TracWysiwyg.prototype.getSelectionRange = TracWysiwyg.prototype.getNativeSelectionRange;
TracWysiwyg.prototype.getSelectionText = function() {
......@@ -3070,10 +3084,17 @@ if (window.getSelection) {
if (ancestor.nodeType != 1) {
return false;
}
var START_TO_END = Range.START_TO_END;
var END_TO_START = Range.END_TO_START;
var d = this.contentDocument;
var elements = ancestor.getElementsByTagName(name);
var length = elements.length;
for (var i = 0; i < length; i++) {
if (selection.containsNode(elements[i], true)) {
var source = d.createRange();
source.selectNode(elements[i]);
if (range.compareBoundaryPoints(START_TO_END, source) === -1 &&
range.compareBoundaryPoints(END_TO_START, source) === 1)
{
return true;
}
}
......@@ -3084,10 +3105,6 @@ else if (document.selection) {
TracWysiwyg.prototype.appendBogusLineBreak = function(element) { };
TracWysiwyg.prototype.isBogusLineBreak = function(node) { return false };
TracWysiwyg.prototype.insertParagraphOnEnter = null;
TracWysiwyg.prototype.insertLineBreak = function() {
this.insertHTML("<br>");
};
TracWysiwyg.prototype.insertLineBreakOnShiftEnter = null;
TracWysiwyg.prototype.tableHTML = function(id, row, col) {
var html = this._tableHTML(row, col);
return html.replace(/<td>/, '<td id="' + id + '">');
......@@ -3378,15 +3395,7 @@ else if (document.selection) {
}
return false;
};
TracWysiwyg.prototype.insertHTML = function(html) {
this.contentWindow.focus();
var selection = this.contentDocument.selection;
var range = selection.createRange();
range.pasteHTML(html.replace(/\t/g, "&#9;"));
range.collapse(false);
range.select();
range = this.contentDocument.selection.createRange();
};
TracWysiwyg.prototype.insertHTML = TracWysiwyg.prototype._msieInsertHTML;
}
else {
TracWysiwyg.prototype.appendBogusLineBreak = function(element) { };
......@@ -3689,20 +3698,23 @@ TracWysiwyg.getTextContent = (function() {
TracWysiwyg.initialize = function() {
if ("replace".replace(/[a-e]/g, function(m) { return "*" }) != "r*pl***") {
return;
return false;
}
if (typeof document.designMode == "undefined") {
return;
return false;
}
TracWysiwyg.tracPaths = TracWysiwyg.getTracPaths();
if (!TracWysiwyg.tracPaths) {
return;
return false;
}
var textareas = document.getElementsByTagName("textarea");
for (var i = 0; i < textareas.length; i++) {
var textarea = textareas[i];
if (/\bwikitext\b/.test(textarea.className || "")) {
if (/\bwikitext\b/.test(textarea.className || "") &&
textarea.getAttribute('data-tracwysiwyg-initialized') === null)
{
TracWysiwyg.newInstance(textarea);
}
}
return true;
};
......@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
setup(
name = 'TracWysiwyg',
version = '0.11.0.3',
version = '0.11.0.5',
description = 'TracWiki WYSIWYG Editor',
license = 'BSD',
url = 'http://trac-hacks.org/wiki/TracWysiwygPlugin',
......
......@@ -3,6 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tracwysiwyg test</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="./chrome/common/css/trac.css" type="text/css" />
<link rel="stylesheet" href="../tracwysiwyg/htdocs/wysiwyg.css" type="text/css" />
<script type="text/javascript" src="./trac.js"></script>
......
......@@ -1485,6 +1485,17 @@ addEvent(window, "load", function() {
assertRangeText(" fox jumps over t", paragraph1, 3, paragraph1.childNodes[4], 2);
});
unit.add("insertHTML", function() {
var d = instance.contentDocument;
var body = d.body;
while (body.childNodes.length > 0) {
body.removeChild(body.lastChild);
}
instance.insertHTML('<p>blah</p>');
var paragraph1 = body.childNodes[0];
unit.assertEqual('blah', paragraph1.innerHTML);
});
unit.run();
}
......
# -*- coding: utf-8 -*-
from fnmatch import fnmatch
import re
from genshi.builder import tag
......@@ -22,6 +23,11 @@ class WysiwygModule(Component):
wysiwyg_stylesheets = ListOption('tracwysiwyg', 'wysiwyg_stylesheets',
doc="""Add stylesheets to the WYSIWYG editor""")
templates = ListOption('tracwysiwyg', 'templates', doc="""\
List of template names that the plugin will show a WYSIWYG editor
on each TracWiki textarea. The plugin shows on all pages by
default.""")
# ITemplateProvider#get_htdocs_dirs
def get_htdocs_dirs(self):
from pkg_resources import resource_filename
......@@ -37,6 +43,9 @@ class WysiwygModule(Component):
# IRequestFilter#post_process_request
def post_process_request(self, req, template, data, content_type):
if not _is_wysiwyg_enabled(template, self.templates):
return template, data, content_type
add_link(req, 'tracwysiwyg.base', req.href() or '/')
stylesheets = ['chrome/common/css/trac.css', 'chrome/tracwysiwyg/editor.css']
stylesheets += self.wysiwyg_stylesheets
......@@ -44,20 +53,21 @@ class WysiwygModule(Component):
add_link(req, 'tracwysiwyg.stylesheet', _expand_filename(req, stylesheet))
add_stylesheet(req, 'tracwysiwyg/wysiwyg.css')
add_script(req, 'tracwysiwyg/wysiwyg.js')
add_script(req, 'tracwysiwyg/wysiwyg-load.js')
return (template, data, content_type)
return template, data, content_type
# ITemplateStreamFilter
def filter_stream(self, req, method, filename, stream, data):
if not _is_wysiwyg_enabled(filename, self.templates):
return stream
options = {}
if filename == 'ticket.html':
options['escapeNewlines'] = _preserve_newlines(self.env)
if options:
text = 'var _tracwysiwyg = %s' % _to_json(options)
stream |= Transformer('//head').append(tag.script(text, type='text/javascript'))
scripts = tag.script('var _tracwysiwyg = %s;' % _to_json(options),
type='text/javascript')
# insert <script> tag once
stream |= Transformer('//script').before(scripts.generate())
return stream
......@@ -122,3 +132,13 @@ def _to_json(value):
raise TypeError, 'Unsupported type "%s"' % type(value)
def _is_wysiwyg_enabled(template, patterns):
if not patterns:
return True
for pattern in patterns:
positive = not pattern.startswith('!')
if not positive:
pattern = pattern[1:]
if fnmatch(template, pattern):
return positive
return False
jQuery(document).ready(function($) {
setTimeout(TracWysiwyg.initialize, 10);
});
......@@ -128,6 +128,5 @@ iframe.wysiwyg:focus {
.wysiwyg-menu a:hover, .wysiwyg-menu .selected a:hover {
border: 1px solid #fb2;
}
.wysiwyg-menu .menu {
font-size: 85%;
}
.wysiwyg-menu ul { font-size: 85% }
.wysiwyg-menu ul ul { font-size: 100% }
This diff is collapsed.
[egg_info]
tag_svn_revision = true
......@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
setup(
name = 'TracWysiwyg',
version = '0.12.0.3',
version = '0.12.0.5',
description = 'TracWiki WYSIWYG Editor',
license = 'BSD',
url = 'http://trac-hacks.org/wiki/TracWysiwygPlugin',
......
......@@ -3,6 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tracwysiwyg test</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="./chrome/common/css/trac.css" type="text/css" />
<link rel="stylesheet" href="../tracwysiwyg/htdocs/wysiwyg.css" type="text/css" />
<script type="text/javascript" src="./trac.js"></script>
......
......@@ -1720,6 +1720,17 @@ addEvent(window, "load", function() {
assertRangeText(" fox jumps over t", paragraph1, 3, paragraph1.childNodes[4], 2);
});
unit.add("insertHTML", function() {
var d = instance.contentDocument;
var body = d.body;
while (body.childNodes.length > 0) {
body.removeChild(body.lastChild);
}
instance.insertHTML('<p>blah</p>');
var paragraph1 = body.childNodes[0];
unit.assertEqual('blah', paragraph1.innerHTML);
});
unit.run();
}
......
# -*- coding: utf-8 -*-
from fnmatch import fnmatch
import re
from trac.core import Component, implements
......@@ -19,6 +20,11 @@ class WysiwygModule(Component):
wysiwyg_stylesheets = ListOption('tracwysiwyg', 'wysiwyg_stylesheets',
doc="""Add stylesheets to the WYSIWYG editor""")
templates = ListOption('tracwysiwyg', 'templates', doc="""\
List of template names that the plugin will show a WYSIWYG editor
on each TracWiki textarea. The plugin shows on all pages by
default.""")
# ITemplateProvider#get_htdocs_dirs
def get_htdocs_dirs(self):
from pkg_resources import resource_filename
......@@ -34,14 +40,13 @@ class WysiwygModule(Component):
# IRequestFilter#post_process_request
def post_process_request(self, req, template, data, content_type):
if not _is_wysiwyg_enabled(template, self.templates):
return template, data, content_type
options = {}
options['escapeNewlines'] = False
if template == 'ticket.html':
options['escapeNewlines'] = TicketModule(self.env).must_preserve_newlines
if options:
add_script_data(req, { '_tracwysiwyg': options })
add_script_data(req, {'_tracwysiwyg': options})
add_link(req, 'tracwysiwyg.base', req.href() or '/')
stylesheets = ['chrome/common/css/trac.css', 'chrome/tracwysiwyg/editor.css']
stylesheets += self.wysiwyg_stylesheets
......@@ -49,9 +54,8 @@ class WysiwygModule(Component):
add_link(req, 'tracwysiwyg.stylesheet', _expand_filename(req, stylesheet))
add_stylesheet(req, 'tracwysiwyg/wysiwyg.css')
add_script(req, 'tracwysiwyg/wysiwyg.js')
add_script(req, 'tracwysiwyg/wysiwyg-load.js')
return (template, data, content_type)
return template, data, content_type
def _expand_filename(req, filename):
......@@ -64,3 +68,13 @@ def _expand_filename(req, filename):
return req.href(filename)
def _is_wysiwyg_enabled(template, patterns):
if not patterns:
return True
for pattern in patterns:
positive = not pattern.startswith('!')
if not positive:
pattern = pattern[1:]
if fnmatch(template, pattern):
return positive
return False
jQuery(document).ready(function($) {
setTimeout(TracWysiwyg.initialize, 10);
});
......@@ -135,6 +135,5 @@ iframe.wysiwyg:focus {
.wysiwyg-menu a:hover, .wysiwyg-menu .selected a:hover {
border: 1px solid #fb2;
}
.wysiwyg-menu .menu {
font-size: 85%;
}
.wysiwyg-menu ul { font-size: 85% }
.wysiwyg-menu ul ul { font-size: 100% }
This diff is collapsed.
# see git-dpm(1) from git-dpm package
8a4d772ed440de91bc2edc2521b56db4f79de82d
8a4d772ed440de91bc2edc2521b56db4f79de82d
8a4d772ed440de91bc2edc2521b56db4f79de82d
8a4d772ed440de91bc2edc2521b56db4f79de82d
trac-wysiwyg_0.12.0.3+r10725.orig.tar.gz
b503d92d5e45f31453910cf0357ec1259bb8decf
135148
28f3b1ece0875f6503e521220ba1fd7d34c6c283
28f3b1ece0875f6503e521220ba1fd7d34c6c283
28f3b1ece0875f6503e521220ba1fd7d34c6c283
28f3b1ece0875f6503e521220ba1fd7d34c6c283
trac-wysiwyg_0.12.0.5+r15671.orig.tar.gz
9fea26ef19c26223badf16f291fb0f35524d8c1f
135081
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment