Skip to content

Commit

Permalink
MDL-33114 import TinyMCE 3.5.1.1 and fix preview
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed May 24, 2012
1 parent 4b0992c commit 798f0de
Show file tree
Hide file tree
Showing 320 changed files with 746 additions and 339 deletions.
2 changes: 1 addition & 1 deletion lib/editor/tinymce/lib.php
Expand Up @@ -28,7 +28,7 @@

class tinymce_texteditor extends texteditor {
/** @var string active version - directory name */
public $version = '3.5';
public $version = '3.5.1.1';

public function supported_by_browser() {
if (check_browser_version('MSIE', 6)) {
Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -61,7 +61,7 @@

// We need at least five characters to form a URL,
// hence, at minimum, five characters from the beginning of the line.
r = ed.selection.getRng().cloneRange();
r = ed.selection.getRng(true).cloneRange();
if (r.startOffset < 5) {
// During testing, the caret is placed inbetween two text nodes.
// The previous text node contains the URL.
Expand Down Expand Up @@ -124,13 +124,19 @@
r.setEnd(endContainer, start);
}

// Exclude last . from word like "www.site.com."
var text = r.toString();
if (text.charAt(text.length - 1) == '.') {
r.setEnd(endContainer, start - 1);
}

text = r.toString();
matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|[A-Z0-9._%+-]+@)(.+)$/i);
matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+-]+@)(.+)$/i);

if (matches) {
if (matches[1] == 'www.') {
matches[1] = 'http://www.';
} else if (/@$/.test(matches[1])) {
} else if (/@$/.test(matches[1]) && !/^mailto:/.test(matches[1])) {
matches[1] = 'mailto:' + matches[1];
}

Expand Down
Expand Up @@ -25,24 +25,36 @@

require(dirname(__FILE__) . '/../../../../../../../config.php');
require_once($CFG->libdir . '/filelib.php');
require_once($CFG->libdir . '/editorlib.php');
require_once($CFG->libdir . '/editor/tinymce/lib.php');

// Must be logged in
require_login();

// Require path to draftfile.php file
$path = required_param('path', PARAM_PATH);

$editor = new tinymce_texteditor();

// Now output this file which is super-simple
$PAGE->set_pagelayout('embedded');
$PAGE->set_url(new moodle_url('/lib/editor/tinymce/tiny_mce/3.4.6/plugins/moodlemedia/preview.php',
$PAGE->set_url(new moodle_url('/lib/editor/tinymce/tiny_mce/'.$editor->version.'/plugins/moodlemedia/preview.php',
array('path' => $path)));
$PAGE->set_context(context_system::instance());
$PAGE->add_body_class('core_media_preview');

echo $OUTPUT->header();

$mediarenderer = $PAGE->get_renderer('core', 'media');
$url = new moodle_url('/draftfile.php/' . $path);

$path = '/'.trim($path, '/');

if (empty($CFG->slasharguments)) {
$url = new moodle_url('/draftfile.php', array('file'=>$path));
} else {
$url = new moodle_url('/draftfile.php');
$url->set_slashargument($path);
}
if ($mediarenderer->can_embed_url($url)) {
echo $mediarenderer->embed_url($url);
}
Expand Down
Expand Up @@ -93,7 +93,7 @@
<input type="submit" id="insert" name="insert" value="{#searchreplace_dlg.findnext}" />
<input type="button" class="button" id="replaceBtn" name="replaceBtn" value="{#searchreplace_dlg.replace}" onclick="SearchReplaceDialog.searchNext('current');" />
<input type="button" class="button" id="replaceAllBtn" name="replaceAllBtn" value="{#searchreplace_dlg.replaceall}" onclick="SearchReplaceDialog.searchNext('all');" />
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
<input type="button" id="cancel" name="close" value="{#close}" onclick="tinyMCEPopup.close();" />
</div>
</form>
</body>
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -1089,19 +1089,17 @@

p = getParent('A');
if (c = cm.get('link')) {
if (!p || !p.name) {
c.setDisabled(!p && co);
c.setActive(!!p);
}
c.setDisabled((!p && co) || (p && !p.href));
c.setActive(!!p && (!p.name && !p.id));
}

if (c = cm.get('unlink')) {
c.setDisabled(!p && co);
c.setActive(!!p && !p.name);
c.setActive(!!p && !p.name && !p.id);
}

if (c = cm.get('anchor')) {
c.setActive(!co && !!p && p.name);
c.setActive(!co && !!p && (p.name || (p.id && !p.href)));
}

p = getParent('IMG');
Expand Down
Expand Up @@ -6,7 +6,7 @@ var AnchorDialog = {

this.editor = ed;
elm = ed.dom.getParent(ed.selection.getNode(), 'A');
v = ed.dom.getAttrib(elm, 'name');
v = ed.dom.getAttrib(elm, 'name') || ed.dom.getAttrib(elm, 'id');

if (v) {
this.action = 'update';
Expand All @@ -17,7 +17,7 @@ var AnchorDialog = {
},

update : function() {
var ed = this.editor, elm, name = document.forms[0].anchorName.value;
var ed = this.editor, elm, name = document.forms[0].anchorName.value, attribName;

if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) {
tinyMCEPopup.alert('advanced_dlg.anchor_invalid');
Expand All @@ -29,13 +29,23 @@ var AnchorDialog = {
if (this.action != 'update')
ed.selection.collapse(1);

var aRule = ed.schema.getElementRule('a');
if (!aRule || aRule.attributes.name) {
attribName = 'name';
} else {
attribName = 'id';
}

elm = ed.dom.getParent(ed.selection.getNode(), 'A');
if (elm) {
elm.setAttribute('name', name);
elm.name = name;
} else
elm.setAttribute(attribName, name);
elm[attribName] = name;
} else {
// create with zero-sized nbsp so that in Webkit where anchor is on last line by itself caret cannot be placed after it
ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, '\uFEFF'));
var attrs = {'class' : 'mceItemAnchor'};
attrs[attribName] = name;
ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', attrs, '\uFEFF'));
}

tinyMCEPopup.close();
}
Expand Down

0 comments on commit 798f0de

Please sign in to comment.