MDL-43858 atto_charmap: New plugin to insert special characters

This commit is contained in:
Frederic Massart 2014-01-30 19:06:49 +08:00 committed by Damyon Wiese
parent 48bdf86f31
commit c7829b26e1
11 changed files with 1957 additions and 1 deletions

View File

@ -0,0 +1,281 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'atto_charmap', language 'en'.
*
* @package atto_charmap
* @copyright 2014 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['insertcharacter'] = 'Insert character';
$string['pluginname'] = 'Insert character';
// The following are not ordered on purpose, they are kept
// in the order in which they appear in the user interface.
$string['nobreakspace'] = 'no-break space';
$string['ampersand'] = 'ampersand';
$string['quotationmark'] = 'quotation mark';
$string['centsign'] = 'cent sign';
$string['eurosign'] = 'euro sign';
$string['poundsign'] = 'pound sign';
$string['yensign'] = 'yen sign';
$string['copyrightsign'] = 'copyright sign';
$string['registeredsign'] = 'registered sign';
$string['trademarksign'] = 'trade mark sign';
$string['permillesign'] = 'per mille sign';
$string['microsign'] = 'micro sign';
$string['middledot'] = 'middle dot';
$string['bullet'] = 'bullet';
$string['threedotleader'] = 'three dot leader';
$string['minutesfeet'] = 'minutes / feet';
$string['secondsinches'] = 'seconds / inches';
$string['sectionsign'] = 'section sign';
$string['paragraphsign'] = 'paragraph sign';
$string['sharpsesszed'] = 'sharp s / ess-zed';
$string['singleleftpointinganglequotationmark'] = 'single left-pointing angle quotation mark';
$string['singlerightpointinganglequotationmark'] = 'single right-pointing angle quotation mark';
$string['leftpointingguillemet'] = 'left pointing guillemet';
$string['rightpointingguillemet'] = 'right pointing guillemet';
$string['leftsinglequotationmark'] = 'left single quotation mark';
$string['rightsinglequotationmark'] = 'right single quotation mark';
$string['leftdoublequotationmark'] = 'left double quotation mark';
$string['rightdoublequotationmark'] = 'right double quotation mark';
$string['singlelow9quotationmark'] = 'single low-9 quotation mark';
$string['doublelow9quotationmark'] = 'double low-9 quotation mark';
$string['lessthansign'] = 'less-than sign';
$string['greaterthansign'] = 'greater-than sign';
$string['lessthanorequalto'] = 'less-than or equal to';
$string['greaterthanorequalto'] = 'greater-than or equal to';
$string['endash'] = 'en dash';
$string['emdash'] = 'em dash';
$string['macron'] = 'macron';
$string['overline'] = 'overline';
$string['currencysign'] = 'currency sign';
$string['brokenbar'] = 'broken bar';
$string['diaeresis'] = 'diaeresis';
$string['invertedexclamationmark'] = 'inverted exclamation mark';
$string['turnedquestionmark'] = 'turned question mark';
$string['circumflexaccent'] = 'circumflex accent';
$string['smalltilde'] = 'small tilde';
$string['degreesign'] = 'degree sign';
$string['minussign'] = 'minus sign';
$string['plusminussign'] = 'plus-minus sign';
$string['divisionsign'] = 'division sign';
$string['fractionslash'] = 'fraction slash';
$string['multiplicationsign'] = 'multiplication sign';
$string['superscriptone'] = 'superscript one';
$string['superscripttwo'] = 'superscript two';
$string['superscriptthree'] = 'superscript three';
$string['fractiononequarter'] = 'fraction one quarter';
$string['fractiononehalf'] = 'fraction one half';
$string['fractionthreequarters'] = 'fraction three quarters';
$string['functionflorin'] = 'function / florin';
$string['integral'] = 'integral';
$string['narysumation'] = 'n-ary sumation';
$string['infinity'] = 'infinity';
$string['squareroot'] = 'square root';
$string['similarto'] = 'similar to';
$string['approximatelyequalto'] = 'approximately equal to';
$string['almostequalto'] = 'almost equal to';
$string['notequalto'] = 'not equal to';
$string['identicalto'] = 'identical to';
$string['elementof'] = 'element of';
$string['notanelementof'] = 'not an element of';
$string['containsasmember'] = 'contains as member';
$string['naryproduct'] = 'n-ary product';
$string['logicaland'] = 'logical and';
$string['logicalor'] = 'logical or';
$string['notsign'] = 'not sign';
$string['intersection'] = 'intersection';
$string['union'] = 'union';
$string['partialdifferential'] = 'partial differential';
$string['forall'] = 'for all';
$string['thereexists'] = 'there exists';
$string['diameter'] = 'diameter';
$string['backwarddifference'] = 'backward difference';
$string['asteriskoperator'] = 'asterisk operator';
$string['proportionalto'] = 'proportional to';
$string['angle'] = 'angle';
$string['acuteaccent'] = 'acute accent';
$string['cedilla'] = 'cedilla';
$string['feminineordinalindicator'] = 'feminine ordinal indicator';
$string['masculineordinalindicator'] = 'masculine ordinal indicator';
$string['dagger'] = 'dagger';
$string['doubledagger'] = 'double dagger';
$string['agrave_caps'] = 'A - grave';
$string['aacute_caps'] = 'A - acute';
$string['acircumflex_caps'] = 'A - circumflex';
$string['atilde_caps'] = 'A - tilde';
$string['adiaeresis_caps'] = 'A - diaeresis';
$string['aringabove_caps'] = 'A - ring above';
$string['ligatureae_caps'] = 'ligature AE';
$string['ccedilla_caps'] = 'C - cedilla';
$string['egrave_caps'] = 'E - grave';
$string['eacute_caps'] = 'E - acute';
$string['ecircumflex_caps'] = 'E - circumflex';
$string['ediaeresis_caps'] = 'E - diaeresis';
$string['igrave_caps'] = 'I - grave';
$string['iacute_caps'] = 'I - acute';
$string['icircumflex_caps'] = 'I - circumflex';
$string['idiaeresis_caps'] = 'I - diaeresis';
$string['eth_caps'] = 'ETH';
$string['ntilde_caps'] = 'N - tilde';
$string['ograve_caps'] = 'O - grave';
$string['oacute_caps'] = 'O - acute';
$string['ocircumflex_caps'] = 'O - circumflex';
$string['otilde_caps'] = 'O - tilde';
$string['odiaeresis_caps'] = 'O - diaeresis';
$string['oslash_caps'] = 'O - slash';
$string['ligatureoe_caps'] = 'ligature OE';
$string['scaron_caps'] = 'S - caron';
$string['ugrave_caps'] = 'U - grave';
$string['uacute_caps'] = 'U - acute';
$string['ucircumflex_caps'] = 'U - circumflex';
$string['udiaeresis_caps'] = 'U - diaeresis';
$string['yacute_caps'] = 'Y - acute';
$string['ydiaeresis_caps'] = 'Y - diaeresis';
$string['thorn_caps'] = 'THORN';
$string['agrave'] = 'a - grave';
$string['aacute'] = 'a - acute';
$string['acircumflex'] = 'a - circumflex';
$string['atilde'] = 'a - tilde';
$string['adiaeresis'] = 'a - diaeresis';
$string['aringabove'] = 'a - ring above';
$string['ligatureae'] = 'ligature ae';
$string['ccedilla'] = 'c - cedilla';
$string['egrave'] = 'e - grave';
$string['eacute'] = 'e - acute';
$string['ecircumflex'] = 'e - circumflex';
$string['ediaeresis'] = 'e - diaeresis';
$string['igrave'] = 'i - grave';
$string['iacute'] = 'i - acute';
$string['icircumflex'] = 'i - circumflex';
$string['idiaeresis'] = 'i - diaeresis';
$string['eth'] = 'eth';
$string['ntilde'] = 'n - tilde';
$string['ograve'] = 'o - grave';
$string['oacute'] = 'o - acute';
$string['ocircumflex'] = 'o - circumflex';
$string['otilde'] = 'o - tilde';
$string['odiaeresis'] = 'o - diaeresis';
$string['oslash'] = 'o slash';
$string['ligatureoe'] = 'ligature oe';
$string['scaron'] = 's - caron';
$string['ugrave'] = 'u - grave';
$string['uacute'] = 'u - acute';
$string['ucircumflex'] = 'u - circumflex';
$string['udiaeresis'] = 'u - diaeresis';
$string['yacute'] = 'y - acute';
$string['thorn'] = 'thorn';
$string['ydiaeresis'] = 'y - diaeresis';
$string['alpha_caps'] = 'Alpha';
$string['beta_caps'] = 'Beta';
$string['gamma_caps'] = 'Gamma';
$string['delta_caps'] = 'Delta';
$string['epsilon_caps'] = 'Epsilon';
$string['zeta_caps'] = 'Zeta';
$string['eta_caps'] = 'Eta';
$string['theta_caps'] = 'Theta';
$string['iota_caps'] = 'Iota';
$string['kappa_caps'] = 'Kappa';
$string['lambda_caps'] = 'Lambda';
$string['mu_caps'] = 'Mu';
$string['nu_caps'] = 'Nu';
$string['xi_caps'] = 'Xi';
$string['omicron_caps'] = 'Omicron';
$string['pi_caps'] = 'Pi';
$string['rho_caps'] = 'Rho';
$string['sigma_caps'] = 'Sigma';
$string['tau_caps'] = 'Tau';
$string['upsilon_caps'] = 'Upsilon';
$string['phi_caps'] = 'Phi';
$string['chi_caps'] = 'Chi';
$string['psi_caps'] = 'Psi';
$string['omega_caps'] = 'Omega';
$string['alpha'] = 'alpha';
$string['beta'] = 'beta';
$string['gamma'] = 'gamma';
$string['delta'] = 'delta';
$string['epsilon'] = 'epsilon';
$string['zeta'] = 'zeta';
$string['eta'] = 'eta';
$string['theta'] = 'theta';
$string['iota'] = 'iota';
$string['kappa'] = 'kappa';
$string['lambda'] = 'lambda';
$string['mu'] = 'mu';
$string['nu'] = 'nu';
$string['xi'] = 'xi';
$string['omicron'] = 'omicron';
$string['pi'] = 'pi';
$string['rho'] = 'rho';
$string['finalsigma'] = 'final sigma';
$string['sigma'] = 'sigma';
$string['tau'] = 'tau';
$string['upsilon'] = 'upsilon';
$string['phi'] = 'phi';
$string['chi'] = 'chi';
$string['psi'] = 'psi';
$string['omega'] = 'omega';
$string['alefsymbol'] = 'alef symbol';
$string['pisymbol'] = 'pi symbol';
$string['realpartsymbol'] = 'real part symbol';
$string['thetasymbol'] = 'theta symbol';
$string['upsilonhooksymbol'] = 'upsilon - hook symbol';
$string['weierstrassp'] = 'Weierstrass p';
$string['imaginarypart'] = 'imaginary part';
$string['leftwardsarrow'] = 'leftwards arrow';
$string['upwardsarrow'] = 'upwards arrow';
$string['rightwardsarrow'] = 'rightwards arrow';
$string['downwardsarrow'] = 'downwards arrow';
$string['leftrightarrow'] = 'left right arrow';
$string['carriagereturn'] = 'carriage return';
$string['leftwardsdoublearrow'] = 'leftwards double arrow';
$string['upwardsdoublearrow'] = 'upwards double arrow';
$string['rightwardsdoublearrow'] = 'rightwards double arrow';
$string['downwardsdoublearrow'] = 'downwards double arrow';
$string['leftrightdoublearrow'] = 'left right double arrow';
$string['therefore'] = 'therefore';
$string['subsetof'] = 'subset of';
$string['supersetof'] = 'superset of';
$string['notasubsetof'] = 'not a subset of';
$string['subsetoforequalto'] = 'subset of or equal to';
$string['supersetoforequalto'] = 'superset of or equal to';
$string['circledplus'] = 'circled plus';
$string['circledtimes'] = 'circled times';
$string['perpendicular'] = 'perpendicular';
$string['dotoperator'] = 'dot operator';
$string['leftceiling'] = 'left ceiling';
$string['rightceiling'] = 'right ceiling';
$string['leftfloor'] = 'left floor';
$string['rightfloor'] = 'right floor';
$string['leftpointinganglebracket'] = 'left-pointing angle bracket';
$string['rightpointinganglebracket'] = 'right-pointing angle bracket';
$string['lozenge'] = 'lozenge';
$string['blackspadesuit'] = 'black spade suit';
$string['blackclubsuit'] = 'black club suit';
$string['blackheartsuit'] = 'black heart suit';
$string['blackdiamondsuit'] = 'black diamond suit';
$string['enspace'] = 'en space';
$string['emspace'] = 'em space';
$string['thinspace'] = 'thin space';
$string['zerowidthnonjoiner'] = 'zero width non-joiner';
$string['zerowidthjoiner'] = 'zero width joiner';
$string['lefttorightmark'] = 'left-to-right mark';
$string['righttoleftmark'] = 'right-to-left mark';
$string['softhyphen'] = 'soft hyphen';

View File

@ -0,0 +1,295 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Atto text editor charmap plugin lib.
*
* @package atto_charmap
* @copyright 2014 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Initialise the strings required for JS.
*
* @return void
*/
function atto_charmap_strings_for_js() {
global $PAGE;
// In order to prevent extra strings to be imported, comment/uncomment the characters
// which are enabled in the JavaScript part of this plugin.
$PAGE->requires->strings_for_js(
array(
'insertcharacter',
'nobreakspace',
'ampersand',
'quotationmark',
'centsign',
'eurosign',
'poundsign',
'yensign',
'copyrightsign',
'registeredsign',
'trademarksign',
'permillesign',
'microsign',
'middledot',
'bullet',
'threedotleader',
'minutesfeet',
'secondsinches',
'sectionsign',
'paragraphsign',
'sharpsesszed',
'singleleftpointinganglequotationmark',
'singlerightpointinganglequotationmark',
'leftpointingguillemet',
'rightpointingguillemet',
'leftsinglequotationmark',
'rightsinglequotationmark',
'leftdoublequotationmark',
'rightdoublequotationmark',
'singlelow9quotationmark',
'doublelow9quotationmark',
'lessthansign',
'greaterthansign',
'lessthanorequalto',
'greaterthanorequalto',
'endash',
'emdash',
'macron',
'overline',
'currencysign',
'brokenbar',
'diaeresis',
'invertedexclamationmark',
'turnedquestionmark',
'circumflexaccent',
'smalltilde',
'degreesign',
'minussign',
'plusminussign',
'divisionsign',
'fractionslash',
'multiplicationsign',
'superscriptone',
'superscripttwo',
'superscriptthree',
'fractiononequarter',
'fractiononehalf',
'fractionthreequarters',
'functionflorin',
'integral',
'narysumation',
'infinity',
'squareroot',
// 'similarto',
// 'approximatelyequalto',
'almostequalto',
'notequalto',
'identicalto',
// 'elementof',
// 'notanelementof',
// 'containsasmember',
'naryproduct',
// 'logicaland',
// 'logicalor',
'notsign',
'intersection',
// 'union',
'partialdifferential',
// 'forall',
// 'thereexists',
// 'diameter',
// 'backwarddifference',
// 'asteriskoperator',
// 'proportionalto',
// 'angle',
'acuteaccent',
'cedilla',
'feminineordinalindicator',
'masculineordinalindicator',
'dagger',
'doubledagger',
'agrave_caps',
'aacute_caps',
'acircumflex_caps',
'atilde_caps',
'adiaeresis_caps',
'aringabove_caps',
'ligatureae_caps',
'ccedilla_caps',
'egrave_caps',
'eacute_caps',
'ecircumflex_caps',
'ediaeresis_caps',
'igrave_caps',
'iacute_caps',
'icircumflex_caps',
'idiaeresis_caps',
'eth_caps',
'ntilde_caps',
'ograve_caps',
'oacute_caps',
'ocircumflex_caps',
'otilde_caps',
'odiaeresis_caps',
'oslash_caps',
'ligatureoe_caps',
'scaron_caps',
'ugrave_caps',
'uacute_caps',
'ucircumflex_caps',
'udiaeresis_caps',
'yacute_caps',
'ydiaeresis_caps',
'thorn_caps',
'agrave',
'aacute',
'acircumflex',
'atilde',
'adiaeresis',
'aringabove',
'ligatureae',
'ccedilla',
'egrave',
'eacute',
'ecircumflex',
'ediaeresis',
'igrave',
'iacute',
'icircumflex',
'idiaeresis',
'eth',
'ntilde',
'ograve',
'oacute',
'ocircumflex',
'otilde',
'odiaeresis',
'oslash',
'ligatureoe',
'scaron',
'ugrave',
'uacute',
'ucircumflex',
'udiaeresis',
'yacute',
'thorn',
'ydiaeresis',
'alpha_caps',
'beta_caps',
'gamma_caps',
'delta_caps',
'epsilon_caps',
'zeta_caps',
'eta_caps',
'theta_caps',
'iota_caps',
'kappa_caps',
'lambda_caps',
'mu_caps',
'nu_caps',
'xi_caps',
'omicron_caps',
'pi_caps',
'rho_caps',
'sigma_caps',
'tau_caps',
'upsilon_caps',
'phi_caps',
'chi_caps',
'psi_caps',
'omega_caps',
'alpha',
'beta',
'gamma',
'delta',
'epsilon',
'zeta',
'eta',
'theta',
'iota',
'kappa',
'lambda',
'mu',
'nu',
'xi',
'omicron',
'pi',
'rho',
'finalsigma',
'sigma',
'tau',
'upsilon',
'phi',
'chi',
'psi',
'omega',
// 'alefsymbol',
// 'pisymbol',
// 'realpartsymbol',
// 'thetasymbol',
// 'upsilonhooksymbol',
// 'weierstrassp',
// 'imaginarypart',
'leftwardsarrow',
'upwardsarrow',
'rightwardsarrow',
'downwardsarrow',
'leftrightarrow',
// 'carriagereturn',
// 'leftwardsdoublearrow',
// 'upwardsdoublearrow',
// 'rightwardsdoublearrow',
// 'downwardsdoublearrow',
// 'leftrightdoublearrow',
// 'therefore',
// 'subsetof',
// 'supersetof',
// 'notasubsetof',
// 'subsetoforequalto',
// 'supersetoforequalto',
// 'circledplus',
// 'circledtimes',
// 'perpendicular',
// 'dotoperator',
// 'leftceiling',
// 'rightceiling',
// 'leftfloor',
// 'rightfloor',
// 'leftpointinganglebracket',
// 'rightpointinganglebracket',
'lozenge',
'blackspadesuit',
'blackclubsuit',
'blackheartsuit',
'blackdiamondsuit',
// 'enspace',
// 'emspace',
// 'thinspace',
// 'zerowidthnonjoiner',
// 'zerowidthjoiner',
// 'lefttorightmark',
// 'righttoleftmark',
// 'softhyphen',
),
'atto_charmap'
);
}

View File

@ -0,0 +1,4 @@
.atto_charmap_selector button {
width: 2em;
padding: 0 3px;
}

View File

@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Atto text editor charmap plugin version file.
*
* @package atto_charmap
* @copyright 2014 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2014013000; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2013110500; // Requires this Moodle version.
$plugin->component = 'atto_charmap'; // Full name of the plugin (used for diagnostics).

View File

@ -0,0 +1,444 @@
YUI.add('moodle-atto_charmap-button', function (Y, NAME) {
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Atto text editor charmap plugin.
*
* @package atto_charmap
* @copyright 2014 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* CSS classes and IDs.
*
* @type {Object}
*/
var CSS = {
BUTTON: 'atto_charmap_character',
CHARMAP: 'atto_charmap_selector'
},
/**
* Selectors.
*
* @type {Object}
*/
SELECTORS = {
BUTTON: '.atto_charmap_character'
},
/**
* Map of special characters, kindly borrowed from TinyMCE.
*
* Each entries contains in order:
* - {String} HTML code
* - {String} HTML numerical code
* - {Boolean} Whether or not to include it in the list
* - {String} The language string key
*
* @type {Array}
*/
CHARMAP = [
['&nbsp;', '&#160;', true, 'nobreakspace'],
['&amp;', '&#38;', true, 'ampersand'],
['&quot;', '&#34;', true, 'quotationmark'],
// Finance.
['&cent;', '&#162;', true, 'centsign'],
['&euro;', '&#8364;', true, 'eurosign'],
['&pound;', '&#163;', true, 'poundsign'],
['&yen;', '&#165;', true, 'yensign'],
// Signs.
['&copy;', '&#169;', true, 'copyrightsign'],
['&reg;', '&#174;', true, 'registeredsign'],
['&trade;', '&#8482;', true, 'trademarksign'],
['&permil;', '&#8240;', true, 'permillesign'],
['&micro;', '&#181;', true, 'microsign'],
['&middot;', '&#183;', true, 'middledot'],
['&bull;', '&#8226;', true, 'bullet'],
['&hellip;', '&#8230;', true, 'threedotleader'],
['&prime;', '&#8242;', true, 'minutesfeet'],
['&Prime;', '&#8243;', true, 'secondsinches'],
['&sect;', '&#167;', true, 'sectionsign'],
['&para;', '&#182;', true, 'paragraphsign'],
['&szlig;', '&#223;', true, 'sharpsesszed'],
// Quotations.
['&lsaquo;', '&#8249;', true, 'singleleftpointinganglequotationmark'],
['&rsaquo;', '&#8250;', true, 'singlerightpointinganglequotationmark'],
['&laquo;', '&#171;', true, 'leftpointingguillemet'],
['&raquo;', '&#187;', true, 'rightpointingguillemet'],
['&lsquo;', '&#8216;', true, 'leftsinglequotationmark'],
['&rsquo;', '&#8217;', true, 'rightsinglequotationmark'],
['&ldquo;', '&#8220;', true, 'leftdoublequotationmark'],
['&rdquo;', '&#8221;', true, 'rightdoublequotationmark'],
['&sbquo;', '&#8218;', true, 'singlelow9quotationmark'],
['&bdquo;', '&#8222;', true, 'doublelow9quotationmark'],
['&lt;', '&#60;', true, 'lessthansign'],
['&gt;', '&#62;', true, 'greaterthansign'],
['&le;', '&#8804;', true, 'lessthanorequalto'],
['&ge;', '&#8805;', true, 'greaterthanorequalto'],
['&ndash;', '&#8211;', true, 'endash'],
['&mdash;', '&#8212;', true, 'emdash'],
['&macr;', '&#175;', true, 'macron'],
['&oline;', '&#8254;', true, 'overline'],
['&curren;', '&#164;', true, 'currencysign'],
['&brvbar;', '&#166;', true, 'brokenbar'],
['&uml;', '&#168;', true, 'diaeresis'],
['&iexcl;', '&#161;', true, 'invertedexclamationmark'],
['&iquest;', '&#191;', true, 'turnedquestionmark'],
['&circ;', '&#710;', true, 'circumflexaccent'],
['&tilde;', '&#732;', true, 'smalltilde'],
['&deg;', '&#176;', true, 'degreesign'],
['&minus;', '&#8722;', true, 'minussign'],
['&plusmn;', '&#177;', true, 'plusminussign'],
['&divide;', '&#247;', true, 'divisionsign'],
['&frasl;', '&#8260;', true, 'fractionslash'],
['&times;', '&#215;', true, 'multiplicationsign'],
['&sup1;', '&#185;', true, 'superscriptone'],
['&sup2;', '&#178;', true, 'superscripttwo'],
['&sup3;', '&#179;', true, 'superscriptthree'],
['&frac14;', '&#188;', true, 'fractiononequarter'],
['&frac12;', '&#189;', true, 'fractiononehalf'],
['&frac34;', '&#190;', true, 'fractionthreequarters'],
// Math / logical.
['&fnof;', '&#402;', true, 'functionflorin'],
['&int;', '&#8747;', true, 'integral'],
['&sum;', '&#8721;', true, 'narysumation'],
['&infin;', '&#8734;', true, 'infinity'],
['&radic;', '&#8730;', true, 'squareroot'],
['&sim;', '&#8764;', false,'similarto'],
['&cong;', '&#8773;', false,'approximatelyequalto'],
['&asymp;', '&#8776;', true, 'almostequalto'],
['&ne;', '&#8800;', true, 'notequalto'],
['&equiv;', '&#8801;', true, 'identicalto'],
['&isin;', '&#8712;', false,'elementof'],
['&notin;', '&#8713;', false,'notanelementof'],
['&ni;', '&#8715;', false,'containsasmember'],
['&prod;', '&#8719;', true, 'naryproduct'],
['&and;', '&#8743;', false,'logicaland'],
['&or;', '&#8744;', false,'logicalor'],
['&not;', '&#172;', true, 'notsign'],
['&cap;', '&#8745;', true, 'intersection'],
['&cup;', '&#8746;', false,'union'],
['&part;', '&#8706;', true, 'partialdifferential'],
['&forall;', '&#8704;', false,'forall'],
['&exist;', '&#8707;', false,'thereexists'],
['&empty;', '&#8709;', false,'diameter'],
['&nabla;', '&#8711;', false,'backwarddifference'],
['&lowast;', '&#8727;', false,'asteriskoperator'],
['&prop;', '&#8733;', false,'proportionalto'],
['&ang;', '&#8736;', false,'angle'],
// Undefined.
['&acute;', '&#180;', true, 'acuteaccent'],
['&cedil;', '&#184;', true, 'cedilla'],
['&ordf;', '&#170;', true, 'feminineordinalindicator'],
['&ordm;', '&#186;', true, 'masculineordinalindicator'],
['&dagger;', '&#8224;', true, 'dagger'],
['&Dagger;', '&#8225;', true, 'doubledagger'],
// Alphabetical special chars.
['&Agrave;', '&#192;', true, 'agrave_caps'],
['&Aacute;', '&#193;', true, 'aacute_caps'],
['&Acirc;', '&#194;', true, 'acircumflex_caps'],
['&Atilde;', '&#195;', true, 'atilde_caps'],
['&Auml;', '&#196;', true, 'adiaeresis_caps'],
['&Aring;', '&#197;', true, 'aringabove_caps'],
['&AElig;', '&#198;', true, 'ligatureae_caps'],
['&Ccedil;', '&#199;', true, 'ccedilla_caps'],
['&Egrave;', '&#200;', true, 'egrave_caps'],
['&Eacute;', '&#201;', true, 'eacute_caps'],
['&Ecirc;', '&#202;', true, 'ecircumflex_caps'],
['&Euml;', '&#203;', true, 'ediaeresis_caps'],
['&Igrave;', '&#204;', true, 'igrave_caps'],
['&Iacute;', '&#205;', true, 'iacute_caps'],
['&Icirc;', '&#206;', true, 'icircumflex_caps'],
['&Iuml;', '&#207;', true, 'idiaeresis_caps'],
['&ETH;', '&#208;', true, 'eth_caps'],
['&Ntilde;', '&#209;', true, 'ntilde_caps'],
['&Ograve;', '&#210;', true, 'ograve_caps'],
['&Oacute;', '&#211;', true, 'oacute_caps'],
['&Ocirc;', '&#212;', true, 'ocircumflex_caps'],
['&Otilde;', '&#213;', true, 'otilde_caps'],
['&Ouml;', '&#214;', true, 'odiaeresis_caps'],
['&Oslash;', '&#216;', true, 'oslash_caps'],
['&OElig;', '&#338;', true, 'ligatureoe_caps'],
['&Scaron;', '&#352;', true, 'scaron_caps'],
['&Ugrave;', '&#217;', true, 'ugrave_caps'],
['&Uacute;', '&#218;', true, 'uacute_caps'],
['&Ucirc;', '&#219;', true, 'ucircumflex_caps'],
['&Uuml;', '&#220;', true, 'udiaeresis_caps'],
['&Yacute;', '&#221;', true, 'yacute_caps'],
['&Yuml;', '&#376;', true, 'ydiaeresis_caps'],
['&THORN;', '&#222;', true, 'thorn_caps'],
['&agrave;', '&#224;', true, 'agrave'],
['&aacute;', '&#225;', true, 'aacute'],
['&acirc;', '&#226;', true, 'acircumflex'],
['&atilde;', '&#227;', true, 'atilde'],
['&auml;', '&#228;', true, 'adiaeresis'],
['&aring;', '&#229;', true, 'aringabove'],
['&aelig;', '&#230;', true, 'ligatureae'],
['&ccedil;', '&#231;', true, 'ccedilla'],
['&egrave;', '&#232;', true, 'egrave'],
['&eacute;', '&#233;', true, 'eacute'],
['&ecirc;', '&#234;', true, 'ecircumflex'],
['&euml;', '&#235;', true, 'ediaeresis'],
['&igrave;', '&#236;', true, 'igrave'],
['&iacute;', '&#237;', true, 'iacute'],
['&icirc;', '&#238;', true, 'icircumflex'],
['&iuml;', '&#239;', true, 'idiaeresis'],
['&eth;', '&#240;', true, 'eth'],
['&ntilde;', '&#241;', true, 'ntilde'],
['&ograve;', '&#242;', true, 'ograve'],
['&oacute;', '&#243;', true, 'oacute'],
['&ocirc;', '&#244;', true, 'ocircumflex'],
['&otilde;', '&#245;', true, 'otilde'],
['&ouml;', '&#246;', true, 'odiaeresis'],
['&oslash;', '&#248;', true, 'oslash'],
['&oelig;', '&#339;', true, 'ligatureoe'],
['&scaron;', '&#353;', true, 'scaron'],
['&ugrave;', '&#249;', true, 'ugrave'],
['&uacute;', '&#250;', true, 'uacute'],
['&ucirc;', '&#251;', true, 'ucircumflex'],
['&uuml;', '&#252;', true, 'udiaeresis'],
['&yacute;', '&#253;', true, 'yacute'],
['&thorn;', '&#254;', true, 'thorn'],
['&yuml;', '&#255;', true, 'ydiaeresis'],
['&Alpha;', '&#913;', true, 'alpha_caps'],
['&Beta;', '&#914;', true, 'beta_caps'],
['&Gamma;', '&#915;', true, 'gamma_caps'],
['&Delta;', '&#916;', true, 'delta_caps'],
['&Epsilon;', '&#917;', true, 'epsilon_caps'],
['&Zeta;', '&#918;', true, 'zeta_caps'],
['&Eta;', '&#919;', true, 'eta_caps'],
['&Theta;', '&#920;', true, 'theta_caps'],
['&Iota;', '&#921;', true, 'iota_caps'],
['&Kappa;', '&#922;', true, 'kappa_caps'],
['&Lambda;', '&#923;', true, 'lambda_caps'],
['&Mu;', '&#924;', true, 'mu_caps'],
['&Nu;', '&#925;', true, 'nu_caps'],
['&Xi;', '&#926;', true, 'xi_caps'],
['&Omicron;', '&#927;', true, 'omicron_caps'],
['&Pi;', '&#928;', true, 'pi_caps'],
['&Rho;', '&#929;', true, 'rho_caps'],
['&Sigma;', '&#931;', true, 'sigma_caps'],
['&Tau;', '&#932;', true, 'tau_caps'],
['&Upsilon;', '&#933;', true, 'upsilon_caps'],
['&Phi;', '&#934;', true, 'phi_caps'],
['&Chi;', '&#935;', true, 'chi_caps'],
['&Psi;', '&#936;', true, 'psi_caps'],
['&Omega;', '&#937;', true, 'omega_caps'],
['&alpha;', '&#945;', true, 'alpha'],
['&beta;', '&#946;', true, 'beta'],
['&gamma;', '&#947;', true, 'gamma'],
['&delta;', '&#948;', true, 'delta'],
['&epsilon;', '&#949;', true, 'epsilon'],
['&zeta;', '&#950;', true, 'zeta'],
['&eta;', '&#951;', true, 'eta'],
['&theta;', '&#952;', true, 'theta'],
['&iota;', '&#953;', true, 'iota'],
['&kappa;', '&#954;', true, 'kappa'],
['&lambda;', '&#955;', true, 'lambda'],
['&mu;', '&#956;', true, 'mu'],
['&nu;', '&#957;', true, 'nu'],
['&xi;', '&#958;', true, 'xi'],
['&omicron;', '&#959;', true, 'omicron'],
['&pi;', '&#960;', true, 'pi'],
['&rho;', '&#961;', true, 'rho'],
['&sigmaf;', '&#962;', true, 'finalsigma'],
['&sigma;', '&#963;', true, 'sigma'],
['&tau;', '&#964;', true, 'tau'],
['&upsilon;', '&#965;', true, 'upsilon'],
['&phi;', '&#966;', true, 'phi'],
['&chi;', '&#967;', true, 'chi'],
['&psi;', '&#968;', true, 'psi'],
['&omega;', '&#969;', true, 'omega'],
// Symbols.
['&alefsym;', '&#8501;', false,'alefsymbol'],
['&piv;', '&#982;', false,'pisymbol'],
['&real;', '&#8476;', false,'realpartsymbol'],
['&thetasym;','&#977;', false,'thetasymbol'],
['&upsih;', '&#978;', false,'upsilonhooksymbol'],
['&weierp;', '&#8472;', false,'weierstrassp'],
['&image;', '&#8465;', false,'imaginarypart'],
// Arrows.
['&larr;', '&#8592;', true, 'leftwardsarrow'],
['&uarr;', '&#8593;', true, 'upwardsarrow'],
['&rarr;', '&#8594;', true, 'rightwardsarrow'],
['&darr;', '&#8595;', true, 'downwardsarrow'],
['&harr;', '&#8596;', true, 'leftrightarrow'],
['&crarr;', '&#8629;', false,'carriagereturn'],
['&lArr;', '&#8656;', false,'leftwardsdoublearrow'],
['&uArr;', '&#8657;', false,'upwardsdoublearrow'],
['&rArr;', '&#8658;', false,'rightwardsdoublearrow'],
['&dArr;', '&#8659;', false,'downwardsdoublearrow'],
['&hArr;', '&#8660;', false,'leftrightdoublearrow'],
['&there4;', '&#8756;', false,'therefore'],
['&sub;', '&#8834;', false,'subsetof'],
['&sup;', '&#8835;', false,'supersetof'],
['&nsub;', '&#8836;', false,'notasubsetof'],
['&sube;', '&#8838;', false,'subsetoforequalto'],
['&supe;', '&#8839;', false,'supersetoforequalto'],
['&oplus;', '&#8853;', false,'circledplus'],
['&otimes;', '&#8855;', false,'circledtimes'],
['&perp;', '&#8869;', false,'perpendicular'],
['&sdot;', '&#8901;', false,'dotoperator'],
['&lceil;', '&#8968;', false,'leftceiling'],
['&rceil;', '&#8969;', false,'rightceiling'],
['&lfloor;', '&#8970;', false,'leftfloor'],
['&rfloor;', '&#8971;', false,'rightfloor'],
['&lang;', '&#9001;', false,'leftpointinganglebracket'],
['&rang;', '&#9002;', false,'rightpointinganglebracket'],
['&loz;', '&#9674;', true, 'lozenge'],
['&spades;', '&#9824;', true, 'blackspadesuit'],
['&clubs;', '&#9827;', true, 'blackclubsuit'],
['&hearts;', '&#9829;', true, 'blackheartsuit'],
['&diams;', '&#9830;', true, 'blackdiamondsuit'],
['&ensp;', '&#8194;', false,'enspace'],
['&emsp;', '&#8195;', false,'emspace'],
['&thinsp;', '&#8201;', false,'thinspace'],
['&zwnj;', '&#8204;', false,'zerowidthnonjoiner'],
['&zwj;', '&#8205;', false,'zerowidthjoiner'],
['&lrm;', '&#8206;', false,'lefttorightmark'],
['&rlm;', '&#8207;', false,'righttoleftmark'],
['&shy;', '&#173;', false,'softhyphen']
];
M.atto_charmap = M.atto_charmap || {
/**
* The ID of the current editor.
*
* @type {String}
*/
currentElementId: null,
/**
* The dialogue to select a character.
*
* @type {M.core.dialogue}
*/
dialogue: null,
/**
* Keeps track of the selection made by the user.
*
* @type {Mixed}
*/
selection: null,
/**
* Init.
*
* @param {Object} params
*
* @return {Void}
*/
init: function(params) {
var display_chooser = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
M.atto_charmap.selection = M.editor_atto.get_selection();
if (M.atto_charmap.selection === false) {
return;
}
// Stores what editor we are working on.
M.atto_charmap.currentElementId = elementid;
// Initialising the dialogue.
var dialogue;
if (!M.atto_charmap.dialogue) {
dialogue = new M.core.dialogue({
visible: false,
modal: true,
close: true,
draggable: true
});
// Setting up the content of the dialogue.
dialogue.set('bodyContent', M.atto_charmap.getDialogueContent());
dialogue.set('headerContent', M.util.get_string('insertcharacter', 'atto_charmap'));
dialogue.render();
dialogue.centerDialogue();
M.atto_charmap.dialogue = dialogue;
} else {
dialogue = M.atto_charmap.dialogue;
}
dialogue.show();
};
var iconurl = M.util.image_url('e/special_character', 'core');
M.editor_atto.add_toolbar_button(params.elementid, 'charmap', iconurl, params.group, display_chooser);
},
/**
* Generates the content of the dialogue.
*
* @return {Node} Node containing the dialogue content
*/
getDialogueContent: function() {
var content,
html = '<div class="' + CSS.CHARMAP + '">',
i;
for (i = 0; i < CHARMAP.length; i++) {
if (!CHARMAP[i][2]) {
continue;
}
html += '<button class="' + CSS.BUTTON + '" ' +
'aria-label="' + Y.Escape.html(M.util.get_string(CHARMAP[i][3], 'atto_charmap')) + '" ' +
'title="' + Y.Escape.html(M.util.get_string(CHARMAP[i][3], 'atto_charmap')) + '" ' +
'data-character="' + CHARMAP[i][0] + '" ' +
'>' +
CHARMAP[i][0] +
'</button>';
}
html += '</div>';
content = Y.Node.create(html);
Y.delegate('click', M.atto_charmap.insertChar, content, SELECTORS.BUTTON, this);
return content;
},
/**
* Insert the picked character in Atto.
*
* @param {Event} e The event
* @return {Void}
*/
insertChar: function(e) {
var character = e.target.getData('character');
e.preventDefault();
e.stopPropagation();
M.atto_charmap.dialogue.hide();
M.editor_atto.set_selection(M.atto_charmap.selection);
if (document.selection && document.selection.createRange().pasteHTML) {
document.selection.createRange().pasteHTML(character);
} else {
document.execCommand('insertHTML', false, character);
}
// Clean the YUI ids from the HTML.
M.editor_atto.text_updated(M.atto_charmap.currentElementId);
}
};
}, '@VERSION@', {"requires": ["node", "escape"]});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,444 @@
YUI.add('moodle-atto_charmap-button', function (Y, NAME) {
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Atto text editor charmap plugin.
*
* @package atto_charmap
* @copyright 2014 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* CSS classes and IDs.
*
* @type {Object}
*/
var CSS = {
BUTTON: 'atto_charmap_character',
CHARMAP: 'atto_charmap_selector'
},
/**
* Selectors.
*
* @type {Object}
*/
SELECTORS = {
BUTTON: '.atto_charmap_character'
},
/**
* Map of special characters, kindly borrowed from TinyMCE.
*
* Each entries contains in order:
* - {String} HTML code
* - {String} HTML numerical code
* - {Boolean} Whether or not to include it in the list
* - {String} The language string key
*
* @type {Array}
*/
CHARMAP = [
['&nbsp;', '&#160;', true, 'nobreakspace'],
['&amp;', '&#38;', true, 'ampersand'],
['&quot;', '&#34;', true, 'quotationmark'],
// Finance.
['&cent;', '&#162;', true, 'centsign'],
['&euro;', '&#8364;', true, 'eurosign'],
['&pound;', '&#163;', true, 'poundsign'],
['&yen;', '&#165;', true, 'yensign'],
// Signs.
['&copy;', '&#169;', true, 'copyrightsign'],
['&reg;', '&#174;', true, 'registeredsign'],
['&trade;', '&#8482;', true, 'trademarksign'],
['&permil;', '&#8240;', true, 'permillesign'],
['&micro;', '&#181;', true, 'microsign'],
['&middot;', '&#183;', true, 'middledot'],
['&bull;', '&#8226;', true, 'bullet'],
['&hellip;', '&#8230;', true, 'threedotleader'],
['&prime;', '&#8242;', true, 'minutesfeet'],
['&Prime;', '&#8243;', true, 'secondsinches'],
['&sect;', '&#167;', true, 'sectionsign'],
['&para;', '&#182;', true, 'paragraphsign'],
['&szlig;', '&#223;', true, 'sharpsesszed'],
// Quotations.
['&lsaquo;', '&#8249;', true, 'singleleftpointinganglequotationmark'],
['&rsaquo;', '&#8250;', true, 'singlerightpointinganglequotationmark'],
['&laquo;', '&#171;', true, 'leftpointingguillemet'],
['&raquo;', '&#187;', true, 'rightpointingguillemet'],
['&lsquo;', '&#8216;', true, 'leftsinglequotationmark'],
['&rsquo;', '&#8217;', true, 'rightsinglequotationmark'],
['&ldquo;', '&#8220;', true, 'leftdoublequotationmark'],
['&rdquo;', '&#8221;', true, 'rightdoublequotationmark'],
['&sbquo;', '&#8218;', true, 'singlelow9quotationmark'],
['&bdquo;', '&#8222;', true, 'doublelow9quotationmark'],
['&lt;', '&#60;', true, 'lessthansign'],
['&gt;', '&#62;', true, 'greaterthansign'],
['&le;', '&#8804;', true, 'lessthanorequalto'],
['&ge;', '&#8805;', true, 'greaterthanorequalto'],
['&ndash;', '&#8211;', true, 'endash'],
['&mdash;', '&#8212;', true, 'emdash'],
['&macr;', '&#175;', true, 'macron'],
['&oline;', '&#8254;', true, 'overline'],
['&curren;', '&#164;', true, 'currencysign'],
['&brvbar;', '&#166;', true, 'brokenbar'],
['&uml;', '&#168;', true, 'diaeresis'],
['&iexcl;', '&#161;', true, 'invertedexclamationmark'],
['&iquest;', '&#191;', true, 'turnedquestionmark'],
['&circ;', '&#710;', true, 'circumflexaccent'],
['&tilde;', '&#732;', true, 'smalltilde'],
['&deg;', '&#176;', true, 'degreesign'],
['&minus;', '&#8722;', true, 'minussign'],
['&plusmn;', '&#177;', true, 'plusminussign'],
['&divide;', '&#247;', true, 'divisionsign'],
['&frasl;', '&#8260;', true, 'fractionslash'],
['&times;', '&#215;', true, 'multiplicationsign'],
['&sup1;', '&#185;', true, 'superscriptone'],
['&sup2;', '&#178;', true, 'superscripttwo'],
['&sup3;', '&#179;', true, 'superscriptthree'],
['&frac14;', '&#188;', true, 'fractiononequarter'],
['&frac12;', '&#189;', true, 'fractiononehalf'],
['&frac34;', '&#190;', true, 'fractionthreequarters'],
// Math / logical.
['&fnof;', '&#402;', true, 'functionflorin'],
['&int;', '&#8747;', true, 'integral'],
['&sum;', '&#8721;', true, 'narysumation'],
['&infin;', '&#8734;', true, 'infinity'],
['&radic;', '&#8730;', true, 'squareroot'],
['&sim;', '&#8764;', false,'similarto'],
['&cong;', '&#8773;', false,'approximatelyequalto'],
['&asymp;', '&#8776;', true, 'almostequalto'],
['&ne;', '&#8800;', true, 'notequalto'],
['&equiv;', '&#8801;', true, 'identicalto'],
['&isin;', '&#8712;', false,'elementof'],
['&notin;', '&#8713;', false,'notanelementof'],
['&ni;', '&#8715;', false,'containsasmember'],
['&prod;', '&#8719;', true, 'naryproduct'],
['&and;', '&#8743;', false,'logicaland'],
['&or;', '&#8744;', false,'logicalor'],
['&not;', '&#172;', true, 'notsign'],
['&cap;', '&#8745;', true, 'intersection'],
['&cup;', '&#8746;', false,'union'],
['&part;', '&#8706;', true, 'partialdifferential'],
['&forall;', '&#8704;', false,'forall'],
['&exist;', '&#8707;', false,'thereexists'],
['&empty;', '&#8709;', false,'diameter'],
['&nabla;', '&#8711;', false,'backwarddifference'],
['&lowast;', '&#8727;', false,'asteriskoperator'],
['&prop;', '&#8733;', false,'proportionalto'],
['&ang;', '&#8736;', false,'angle'],
// Undefined.
['&acute;', '&#180;', true, 'acuteaccent'],
['&cedil;', '&#184;', true, 'cedilla'],
['&ordf;', '&#170;', true, 'feminineordinalindicator'],
['&ordm;', '&#186;', true, 'masculineordinalindicator'],
['&dagger;', '&#8224;', true, 'dagger'],
['&Dagger;', '&#8225;', true, 'doubledagger'],
// Alphabetical special chars.
['&Agrave;', '&#192;', true, 'agrave_caps'],
['&Aacute;', '&#193;', true, 'aacute_caps'],
['&Acirc;', '&#194;', true, 'acircumflex_caps'],
['&Atilde;', '&#195;', true, 'atilde_caps'],
['&Auml;', '&#196;', true, 'adiaeresis_caps'],
['&Aring;', '&#197;', true, 'aringabove_caps'],
['&AElig;', '&#198;', true, 'ligatureae_caps'],
['&Ccedil;', '&#199;', true, 'ccedilla_caps'],
['&Egrave;', '&#200;', true, 'egrave_caps'],
['&Eacute;', '&#201;', true, 'eacute_caps'],
['&Ecirc;', '&#202;', true, 'ecircumflex_caps'],
['&Euml;', '&#203;', true, 'ediaeresis_caps'],
['&Igrave;', '&#204;', true, 'igrave_caps'],
['&Iacute;', '&#205;', true, 'iacute_caps'],
['&Icirc;', '&#206;', true, 'icircumflex_caps'],
['&Iuml;', '&#207;', true, 'idiaeresis_caps'],
['&ETH;', '&#208;', true, 'eth_caps'],
['&Ntilde;', '&#209;', true, 'ntilde_caps'],
['&Ograve;', '&#210;', true, 'ograve_caps'],
['&Oacute;', '&#211;', true, 'oacute_caps'],
['&Ocirc;', '&#212;', true, 'ocircumflex_caps'],
['&Otilde;', '&#213;', true, 'otilde_caps'],
['&Ouml;', '&#214;', true, 'odiaeresis_caps'],
['&Oslash;', '&#216;', true, 'oslash_caps'],
['&OElig;', '&#338;', true, 'ligatureoe_caps'],
['&Scaron;', '&#352;', true, 'scaron_caps'],
['&Ugrave;', '&#217;', true, 'ugrave_caps'],
['&Uacute;', '&#218;', true, 'uacute_caps'],
['&Ucirc;', '&#219;', true, 'ucircumflex_caps'],
['&Uuml;', '&#220;', true, 'udiaeresis_caps'],
['&Yacute;', '&#221;', true, 'yacute_caps'],
['&Yuml;', '&#376;', true, 'ydiaeresis_caps'],
['&THORN;', '&#222;', true, 'thorn_caps'],
['&agrave;', '&#224;', true, 'agrave'],
['&aacute;', '&#225;', true, 'aacute'],
['&acirc;', '&#226;', true, 'acircumflex'],
['&atilde;', '&#227;', true, 'atilde'],
['&auml;', '&#228;', true, 'adiaeresis'],
['&aring;', '&#229;', true, 'aringabove'],
['&aelig;', '&#230;', true, 'ligatureae'],
['&ccedil;', '&#231;', true, 'ccedilla'],
['&egrave;', '&#232;', true, 'egrave'],
['&eacute;', '&#233;', true, 'eacute'],
['&ecirc;', '&#234;', true, 'ecircumflex'],
['&euml;', '&#235;', true, 'ediaeresis'],
['&igrave;', '&#236;', true, 'igrave'],
['&iacute;', '&#237;', true, 'iacute'],
['&icirc;', '&#238;', true, 'icircumflex'],
['&iuml;', '&#239;', true, 'idiaeresis'],
['&eth;', '&#240;', true, 'eth'],
['&ntilde;', '&#241;', true, 'ntilde'],
['&ograve;', '&#242;', true, 'ograve'],
['&oacute;', '&#243;', true, 'oacute'],
['&ocirc;', '&#244;', true, 'ocircumflex'],
['&otilde;', '&#245;', true, 'otilde'],
['&ouml;', '&#246;', true, 'odiaeresis'],
['&oslash;', '&#248;', true, 'oslash'],
['&oelig;', '&#339;', true, 'ligatureoe'],
['&scaron;', '&#353;', true, 'scaron'],
['&ugrave;', '&#249;', true, 'ugrave'],
['&uacute;', '&#250;', true, 'uacute'],
['&ucirc;', '&#251;', true, 'ucircumflex'],
['&uuml;', '&#252;', true, 'udiaeresis'],
['&yacute;', '&#253;', true, 'yacute'],
['&thorn;', '&#254;', true, 'thorn'],
['&yuml;', '&#255;', true, 'ydiaeresis'],
['&Alpha;', '&#913;', true, 'alpha_caps'],
['&Beta;', '&#914;', true, 'beta_caps'],
['&Gamma;', '&#915;', true, 'gamma_caps'],
['&Delta;', '&#916;', true, 'delta_caps'],
['&Epsilon;', '&#917;', true, 'epsilon_caps'],
['&Zeta;', '&#918;', true, 'zeta_caps'],
['&Eta;', '&#919;', true, 'eta_caps'],
['&Theta;', '&#920;', true, 'theta_caps'],
['&Iota;', '&#921;', true, 'iota_caps'],
['&Kappa;', '&#922;', true, 'kappa_caps'],
['&Lambda;', '&#923;', true, 'lambda_caps'],
['&Mu;', '&#924;', true, 'mu_caps'],
['&Nu;', '&#925;', true, 'nu_caps'],
['&Xi;', '&#926;', true, 'xi_caps'],
['&Omicron;', '&#927;', true, 'omicron_caps'],
['&Pi;', '&#928;', true, 'pi_caps'],
['&Rho;', '&#929;', true, 'rho_caps'],
['&Sigma;', '&#931;', true, 'sigma_caps'],
['&Tau;', '&#932;', true, 'tau_caps'],
['&Upsilon;', '&#933;', true, 'upsilon_caps'],
['&Phi;', '&#934;', true, 'phi_caps'],
['&Chi;', '&#935;', true, 'chi_caps'],
['&Psi;', '&#936;', true, 'psi_caps'],
['&Omega;', '&#937;', true, 'omega_caps'],
['&alpha;', '&#945;', true, 'alpha'],
['&beta;', '&#946;', true, 'beta'],
['&gamma;', '&#947;', true, 'gamma'],
['&delta;', '&#948;', true, 'delta'],
['&epsilon;', '&#949;', true, 'epsilon'],
['&zeta;', '&#950;', true, 'zeta'],
['&eta;', '&#951;', true, 'eta'],
['&theta;', '&#952;', true, 'theta'],
['&iota;', '&#953;', true, 'iota'],
['&kappa;', '&#954;', true, 'kappa'],
['&lambda;', '&#955;', true, 'lambda'],
['&mu;', '&#956;', true, 'mu'],
['&nu;', '&#957;', true, 'nu'],
['&xi;', '&#958;', true, 'xi'],
['&omicron;', '&#959;', true, 'omicron'],
['&pi;', '&#960;', true, 'pi'],
['&rho;', '&#961;', true, 'rho'],
['&sigmaf;', '&#962;', true, 'finalsigma'],
['&sigma;', '&#963;', true, 'sigma'],
['&tau;', '&#964;', true, 'tau'],
['&upsilon;', '&#965;', true, 'upsilon'],
['&phi;', '&#966;', true, 'phi'],
['&chi;', '&#967;', true, 'chi'],
['&psi;', '&#968;', true, 'psi'],
['&omega;', '&#969;', true, 'omega'],
// Symbols.
['&alefsym;', '&#8501;', false,'alefsymbol'],
['&piv;', '&#982;', false,'pisymbol'],
['&real;', '&#8476;', false,'realpartsymbol'],
['&thetasym;','&#977;', false,'thetasymbol'],
['&upsih;', '&#978;', false,'upsilonhooksymbol'],
['&weierp;', '&#8472;', false,'weierstrassp'],
['&image;', '&#8465;', false,'imaginarypart'],
// Arrows.
['&larr;', '&#8592;', true, 'leftwardsarrow'],
['&uarr;', '&#8593;', true, 'upwardsarrow'],
['&rarr;', '&#8594;', true, 'rightwardsarrow'],
['&darr;', '&#8595;', true, 'downwardsarrow'],
['&harr;', '&#8596;', true, 'leftrightarrow'],
['&crarr;', '&#8629;', false,'carriagereturn'],
['&lArr;', '&#8656;', false,'leftwardsdoublearrow'],
['&uArr;', '&#8657;', false,'upwardsdoublearrow'],
['&rArr;', '&#8658;', false,'rightwardsdoublearrow'],
['&dArr;', '&#8659;', false,'downwardsdoublearrow'],
['&hArr;', '&#8660;', false,'leftrightdoublearrow'],
['&there4;', '&#8756;', false,'therefore'],
['&sub;', '&#8834;', false,'subsetof'],
['&sup;', '&#8835;', false,'supersetof'],
['&nsub;', '&#8836;', false,'notasubsetof'],
['&sube;', '&#8838;', false,'subsetoforequalto'],
['&supe;', '&#8839;', false,'supersetoforequalto'],
['&oplus;', '&#8853;', false,'circledplus'],
['&otimes;', '&#8855;', false,'circledtimes'],
['&perp;', '&#8869;', false,'perpendicular'],
['&sdot;', '&#8901;', false,'dotoperator'],
['&lceil;', '&#8968;', false,'leftceiling'],
['&rceil;', '&#8969;', false,'rightceiling'],
['&lfloor;', '&#8970;', false,'leftfloor'],
['&rfloor;', '&#8971;', false,'rightfloor'],
['&lang;', '&#9001;', false,'leftpointinganglebracket'],
['&rang;', '&#9002;', false,'rightpointinganglebracket'],
['&loz;', '&#9674;', true, 'lozenge'],
['&spades;', '&#9824;', true, 'blackspadesuit'],
['&clubs;', '&#9827;', true, 'blackclubsuit'],
['&hearts;', '&#9829;', true, 'blackheartsuit'],
['&diams;', '&#9830;', true, 'blackdiamondsuit'],
['&ensp;', '&#8194;', false,'enspace'],
['&emsp;', '&#8195;', false,'emspace'],
['&thinsp;', '&#8201;', false,'thinspace'],
['&zwnj;', '&#8204;', false,'zerowidthnonjoiner'],
['&zwj;', '&#8205;', false,'zerowidthjoiner'],
['&lrm;', '&#8206;', false,'lefttorightmark'],
['&rlm;', '&#8207;', false,'righttoleftmark'],
['&shy;', '&#173;', false,'softhyphen']
];
M.atto_charmap = M.atto_charmap || {
/**
* The ID of the current editor.
*
* @type {String}
*/
currentElementId: null,
/**
* The dialogue to select a character.
*
* @type {M.core.dialogue}
*/
dialogue: null,
/**
* Keeps track of the selection made by the user.
*
* @type {Mixed}
*/
selection: null,
/**
* Init.
*
* @param {Object} params
*
* @return {Void}
*/
init: function(params) {
var display_chooser = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
M.atto_charmap.selection = M.editor_atto.get_selection();
if (M.atto_charmap.selection === false) {
return;
}
// Stores what editor we are working on.
M.atto_charmap.currentElementId = elementid;
// Initialising the dialogue.
var dialogue;
if (!M.atto_charmap.dialogue) {
dialogue = new M.core.dialogue({
visible: false,
modal: true,
close: true,
draggable: true
});
// Setting up the content of the dialogue.
dialogue.set('bodyContent', M.atto_charmap.getDialogueContent());
dialogue.set('headerContent', M.util.get_string('insertcharacter', 'atto_charmap'));
dialogue.render();
dialogue.centerDialogue();
M.atto_charmap.dialogue = dialogue;
} else {
dialogue = M.atto_charmap.dialogue;
}
dialogue.show();
};
var iconurl = M.util.image_url('e/special_character', 'core');
M.editor_atto.add_toolbar_button(params.elementid, 'charmap', iconurl, params.group, display_chooser);
},
/**
* Generates the content of the dialogue.
*
* @return {Node} Node containing the dialogue content
*/
getDialogueContent: function() {
var content,
html = '<div class="' + CSS.CHARMAP + '">',
i;
for (i = 0; i < CHARMAP.length; i++) {
if (!CHARMAP[i][2]) {
continue;
}
html += '<button class="' + CSS.BUTTON + '" ' +
'aria-label="' + Y.Escape.html(M.util.get_string(CHARMAP[i][3], 'atto_charmap')) + '" ' +
'title="' + Y.Escape.html(M.util.get_string(CHARMAP[i][3], 'atto_charmap')) + '" ' +
'data-character="' + CHARMAP[i][0] + '" ' +
'>' +
CHARMAP[i][0] +
'</button>';
}
html += '</div>';
content = Y.Node.create(html);
Y.delegate('click', M.atto_charmap.insertChar, content, SELECTORS.BUTTON, this);
return content;
},
/**
* Insert the picked character in Atto.
*
* @param {Event} e The event
* @return {Void}
*/
insertChar: function(e) {
var character = e.target.getData('character');
e.preventDefault();
e.stopPropagation();
M.atto_charmap.dialogue.hide();
M.editor_atto.set_selection(M.atto_charmap.selection);
if (document.selection && document.selection.createRange().pasteHTML) {
document.selection.createRange().pasteHTML(character);
} else {
document.execCommand('insertHTML', false, character);
}
// Clean the YUI ids from the HTML.
M.editor_atto.text_updated(M.atto_charmap.currentElementId);
}
};
}, '@VERSION@', {"requires": ["node", "escape"]});

View File

@ -0,0 +1,10 @@
{
"name": "moodle-atto_charmap-button",
"builds": {
"moodle-atto_charmap-button": {
"jsfiles": [
"button.js"
]
}
}
}

View File

@ -0,0 +1,439 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Atto text editor charmap plugin.
*
* @package atto_charmap
* @copyright 2014 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* CSS classes and IDs.
*
* @type {Object}
*/
var CSS = {
BUTTON: 'atto_charmap_character',
CHARMAP: 'atto_charmap_selector'
},
/**
* Selectors.
*
* @type {Object}
*/
SELECTORS = {
BUTTON: '.atto_charmap_character'
},
/**
* Map of special characters, kindly borrowed from TinyMCE.
*
* Each entries contains in order:
* - {String} HTML code
* - {String} HTML numerical code
* - {Boolean} Whether or not to include it in the list
* - {String} The language string key
*
* @type {Array}
*/
CHARMAP = [
['&nbsp;', '&#160;', true, 'nobreakspace'],
['&amp;', '&#38;', true, 'ampersand'],
['&quot;', '&#34;', true, 'quotationmark'],
// Finance.
['&cent;', '&#162;', true, 'centsign'],
['&euro;', '&#8364;', true, 'eurosign'],
['&pound;', '&#163;', true, 'poundsign'],
['&yen;', '&#165;', true, 'yensign'],
// Signs.
['&copy;', '&#169;', true, 'copyrightsign'],
['&reg;', '&#174;', true, 'registeredsign'],
['&trade;', '&#8482;', true, 'trademarksign'],
['&permil;', '&#8240;', true, 'permillesign'],
['&micro;', '&#181;', true, 'microsign'],
['&middot;', '&#183;', true, 'middledot'],
['&bull;', '&#8226;', true, 'bullet'],
['&hellip;', '&#8230;', true, 'threedotleader'],
['&prime;', '&#8242;', true, 'minutesfeet'],
['&Prime;', '&#8243;', true, 'secondsinches'],
['&sect;', '&#167;', true, 'sectionsign'],
['&para;', '&#182;', true, 'paragraphsign'],
['&szlig;', '&#223;', true, 'sharpsesszed'],
// Quotations.
['&lsaquo;', '&#8249;', true, 'singleleftpointinganglequotationmark'],
['&rsaquo;', '&#8250;', true, 'singlerightpointinganglequotationmark'],
['&laquo;', '&#171;', true, 'leftpointingguillemet'],
['&raquo;', '&#187;', true, 'rightpointingguillemet'],
['&lsquo;', '&#8216;', true, 'leftsinglequotationmark'],
['&rsquo;', '&#8217;', true, 'rightsinglequotationmark'],
['&ldquo;', '&#8220;', true, 'leftdoublequotationmark'],
['&rdquo;', '&#8221;', true, 'rightdoublequotationmark'],
['&sbquo;', '&#8218;', true, 'singlelow9quotationmark'],
['&bdquo;', '&#8222;', true, 'doublelow9quotationmark'],
['&lt;', '&#60;', true, 'lessthansign'],
['&gt;', '&#62;', true, 'greaterthansign'],
['&le;', '&#8804;', true, 'lessthanorequalto'],
['&ge;', '&#8805;', true, 'greaterthanorequalto'],
['&ndash;', '&#8211;', true, 'endash'],
['&mdash;', '&#8212;', true, 'emdash'],
['&macr;', '&#175;', true, 'macron'],
['&oline;', '&#8254;', true, 'overline'],
['&curren;', '&#164;', true, 'currencysign'],
['&brvbar;', '&#166;', true, 'brokenbar'],
['&uml;', '&#168;', true, 'diaeresis'],
['&iexcl;', '&#161;', true, 'invertedexclamationmark'],
['&iquest;', '&#191;', true, 'turnedquestionmark'],
['&circ;', '&#710;', true, 'circumflexaccent'],
['&tilde;', '&#732;', true, 'smalltilde'],
['&deg;', '&#176;', true, 'degreesign'],
['&minus;', '&#8722;', true, 'minussign'],
['&plusmn;', '&#177;', true, 'plusminussign'],
['&divide;', '&#247;', true, 'divisionsign'],
['&frasl;', '&#8260;', true, 'fractionslash'],
['&times;', '&#215;', true, 'multiplicationsign'],
['&sup1;', '&#185;', true, 'superscriptone'],
['&sup2;', '&#178;', true, 'superscripttwo'],
['&sup3;', '&#179;', true, 'superscriptthree'],
['&frac14;', '&#188;', true, 'fractiononequarter'],
['&frac12;', '&#189;', true, 'fractiononehalf'],
['&frac34;', '&#190;', true, 'fractionthreequarters'],
// Math / logical.
['&fnof;', '&#402;', true, 'functionflorin'],
['&int;', '&#8747;', true, 'integral'],
['&sum;', '&#8721;', true, 'narysumation'],
['&infin;', '&#8734;', true, 'infinity'],
['&radic;', '&#8730;', true, 'squareroot'],
['&sim;', '&#8764;', false,'similarto'],
['&cong;', '&#8773;', false,'approximatelyequalto'],
['&asymp;', '&#8776;', true, 'almostequalto'],
['&ne;', '&#8800;', true, 'notequalto'],
['&equiv;', '&#8801;', true, 'identicalto'],
['&isin;', '&#8712;', false,'elementof'],
['&notin;', '&#8713;', false,'notanelementof'],
['&ni;', '&#8715;', false,'containsasmember'],
['&prod;', '&#8719;', true, 'naryproduct'],
['&and;', '&#8743;', false,'logicaland'],
['&or;', '&#8744;', false,'logicalor'],
['&not;', '&#172;', true, 'notsign'],
['&cap;', '&#8745;', true, 'intersection'],
['&cup;', '&#8746;', false,'union'],
['&part;', '&#8706;', true, 'partialdifferential'],
['&forall;', '&#8704;', false,'forall'],
['&exist;', '&#8707;', false,'thereexists'],
['&empty;', '&#8709;', false,'diameter'],
['&nabla;', '&#8711;', false,'backwarddifference'],
['&lowast;', '&#8727;', false,'asteriskoperator'],
['&prop;', '&#8733;', false,'proportionalto'],
['&ang;', '&#8736;', false,'angle'],
// Undefined.
['&acute;', '&#180;', true, 'acuteaccent'],
['&cedil;', '&#184;', true, 'cedilla'],
['&ordf;', '&#170;', true, 'feminineordinalindicator'],
['&ordm;', '&#186;', true, 'masculineordinalindicator'],
['&dagger;', '&#8224;', true, 'dagger'],
['&Dagger;', '&#8225;', true, 'doubledagger'],
// Alphabetical special chars.
['&Agrave;', '&#192;', true, 'agrave_caps'],
['&Aacute;', '&#193;', true, 'aacute_caps'],
['&Acirc;', '&#194;', true, 'acircumflex_caps'],
['&Atilde;', '&#195;', true, 'atilde_caps'],
['&Auml;', '&#196;', true, 'adiaeresis_caps'],
['&Aring;', '&#197;', true, 'aringabove_caps'],
['&AElig;', '&#198;', true, 'ligatureae_caps'],
['&Ccedil;', '&#199;', true, 'ccedilla_caps'],
['&Egrave;', '&#200;', true, 'egrave_caps'],
['&Eacute;', '&#201;', true, 'eacute_caps'],
['&Ecirc;', '&#202;', true, 'ecircumflex_caps'],
['&Euml;', '&#203;', true, 'ediaeresis_caps'],
['&Igrave;', '&#204;', true, 'igrave_caps'],
['&Iacute;', '&#205;', true, 'iacute_caps'],
['&Icirc;', '&#206;', true, 'icircumflex_caps'],
['&Iuml;', '&#207;', true, 'idiaeresis_caps'],
['&ETH;', '&#208;', true, 'eth_caps'],
['&Ntilde;', '&#209;', true, 'ntilde_caps'],
['&Ograve;', '&#210;', true, 'ograve_caps'],
['&Oacute;', '&#211;', true, 'oacute_caps'],
['&Ocirc;', '&#212;', true, 'ocircumflex_caps'],
['&Otilde;', '&#213;', true, 'otilde_caps'],
['&Ouml;', '&#214;', true, 'odiaeresis_caps'],
['&Oslash;', '&#216;', true, 'oslash_caps'],
['&OElig;', '&#338;', true, 'ligatureoe_caps'],
['&Scaron;', '&#352;', true, 'scaron_caps'],
['&Ugrave;', '&#217;', true, 'ugrave_caps'],
['&Uacute;', '&#218;', true, 'uacute_caps'],
['&Ucirc;', '&#219;', true, 'ucircumflex_caps'],
['&Uuml;', '&#220;', true, 'udiaeresis_caps'],
['&Yacute;', '&#221;', true, 'yacute_caps'],
['&Yuml;', '&#376;', true, 'ydiaeresis_caps'],
['&THORN;', '&#222;', true, 'thorn_caps'],
['&agrave;', '&#224;', true, 'agrave'],
['&aacute;', '&#225;', true, 'aacute'],
['&acirc;', '&#226;', true, 'acircumflex'],
['&atilde;', '&#227;', true, 'atilde'],
['&auml;', '&#228;', true, 'adiaeresis'],
['&aring;', '&#229;', true, 'aringabove'],
['&aelig;', '&#230;', true, 'ligatureae'],
['&ccedil;', '&#231;', true, 'ccedilla'],
['&egrave;', '&#232;', true, 'egrave'],
['&eacute;', '&#233;', true, 'eacute'],
['&ecirc;', '&#234;', true, 'ecircumflex'],
['&euml;', '&#235;', true, 'ediaeresis'],
['&igrave;', '&#236;', true, 'igrave'],
['&iacute;', '&#237;', true, 'iacute'],
['&icirc;', '&#238;', true, 'icircumflex'],
['&iuml;', '&#239;', true, 'idiaeresis'],
['&eth;', '&#240;', true, 'eth'],
['&ntilde;', '&#241;', true, 'ntilde'],
['&ograve;', '&#242;', true, 'ograve'],
['&oacute;', '&#243;', true, 'oacute'],
['&ocirc;', '&#244;', true, 'ocircumflex'],
['&otilde;', '&#245;', true, 'otilde'],
['&ouml;', '&#246;', true, 'odiaeresis'],
['&oslash;', '&#248;', true, 'oslash'],
['&oelig;', '&#339;', true, 'ligatureoe'],
['&scaron;', '&#353;', true, 'scaron'],
['&ugrave;', '&#249;', true, 'ugrave'],
['&uacute;', '&#250;', true, 'uacute'],
['&ucirc;', '&#251;', true, 'ucircumflex'],
['&uuml;', '&#252;', true, 'udiaeresis'],
['&yacute;', '&#253;', true, 'yacute'],
['&thorn;', '&#254;', true, 'thorn'],
['&yuml;', '&#255;', true, 'ydiaeresis'],
['&Alpha;', '&#913;', true, 'alpha_caps'],
['&Beta;', '&#914;', true, 'beta_caps'],
['&Gamma;', '&#915;', true, 'gamma_caps'],
['&Delta;', '&#916;', true, 'delta_caps'],
['&Epsilon;', '&#917;', true, 'epsilon_caps'],
['&Zeta;', '&#918;', true, 'zeta_caps'],
['&Eta;', '&#919;', true, 'eta_caps'],
['&Theta;', '&#920;', true, 'theta_caps'],
['&Iota;', '&#921;', true, 'iota_caps'],
['&Kappa;', '&#922;', true, 'kappa_caps'],
['&Lambda;', '&#923;', true, 'lambda_caps'],
['&Mu;', '&#924;', true, 'mu_caps'],
['&Nu;', '&#925;', true, 'nu_caps'],
['&Xi;', '&#926;', true, 'xi_caps'],
['&Omicron;', '&#927;', true, 'omicron_caps'],
['&Pi;', '&#928;', true, 'pi_caps'],
['&Rho;', '&#929;', true, 'rho_caps'],
['&Sigma;', '&#931;', true, 'sigma_caps'],
['&Tau;', '&#932;', true, 'tau_caps'],
['&Upsilon;', '&#933;', true, 'upsilon_caps'],
['&Phi;', '&#934;', true, 'phi_caps'],
['&Chi;', '&#935;', true, 'chi_caps'],
['&Psi;', '&#936;', true, 'psi_caps'],
['&Omega;', '&#937;', true, 'omega_caps'],
['&alpha;', '&#945;', true, 'alpha'],
['&beta;', '&#946;', true, 'beta'],
['&gamma;', '&#947;', true, 'gamma'],
['&delta;', '&#948;', true, 'delta'],
['&epsilon;', '&#949;', true, 'epsilon'],
['&zeta;', '&#950;', true, 'zeta'],
['&eta;', '&#951;', true, 'eta'],
['&theta;', '&#952;', true, 'theta'],
['&iota;', '&#953;', true, 'iota'],
['&kappa;', '&#954;', true, 'kappa'],
['&lambda;', '&#955;', true, 'lambda'],
['&mu;', '&#956;', true, 'mu'],
['&nu;', '&#957;', true, 'nu'],
['&xi;', '&#958;', true, 'xi'],
['&omicron;', '&#959;', true, 'omicron'],
['&pi;', '&#960;', true, 'pi'],
['&rho;', '&#961;', true, 'rho'],
['&sigmaf;', '&#962;', true, 'finalsigma'],
['&sigma;', '&#963;', true, 'sigma'],
['&tau;', '&#964;', true, 'tau'],
['&upsilon;', '&#965;', true, 'upsilon'],
['&phi;', '&#966;', true, 'phi'],
['&chi;', '&#967;', true, 'chi'],
['&psi;', '&#968;', true, 'psi'],
['&omega;', '&#969;', true, 'omega'],
// Symbols.
['&alefsym;', '&#8501;', false,'alefsymbol'],
['&piv;', '&#982;', false,'pisymbol'],
['&real;', '&#8476;', false,'realpartsymbol'],
['&thetasym;','&#977;', false,'thetasymbol'],
['&upsih;', '&#978;', false,'upsilonhooksymbol'],
['&weierp;', '&#8472;', false,'weierstrassp'],
['&image;', '&#8465;', false,'imaginarypart'],
// Arrows.
['&larr;', '&#8592;', true, 'leftwardsarrow'],
['&uarr;', '&#8593;', true, 'upwardsarrow'],
['&rarr;', '&#8594;', true, 'rightwardsarrow'],
['&darr;', '&#8595;', true, 'downwardsarrow'],
['&harr;', '&#8596;', true, 'leftrightarrow'],
['&crarr;', '&#8629;', false,'carriagereturn'],
['&lArr;', '&#8656;', false,'leftwardsdoublearrow'],
['&uArr;', '&#8657;', false,'upwardsdoublearrow'],
['&rArr;', '&#8658;', false,'rightwardsdoublearrow'],
['&dArr;', '&#8659;', false,'downwardsdoublearrow'],
['&hArr;', '&#8660;', false,'leftrightdoublearrow'],
['&there4;', '&#8756;', false,'therefore'],
['&sub;', '&#8834;', false,'subsetof'],
['&sup;', '&#8835;', false,'supersetof'],
['&nsub;', '&#8836;', false,'notasubsetof'],
['&sube;', '&#8838;', false,'subsetoforequalto'],
['&supe;', '&#8839;', false,'supersetoforequalto'],
['&oplus;', '&#8853;', false,'circledplus'],
['&otimes;', '&#8855;', false,'circledtimes'],
['&perp;', '&#8869;', false,'perpendicular'],
['&sdot;', '&#8901;', false,'dotoperator'],
['&lceil;', '&#8968;', false,'leftceiling'],
['&rceil;', '&#8969;', false,'rightceiling'],
['&lfloor;', '&#8970;', false,'leftfloor'],
['&rfloor;', '&#8971;', false,'rightfloor'],
['&lang;', '&#9001;', false,'leftpointinganglebracket'],
['&rang;', '&#9002;', false,'rightpointinganglebracket'],
['&loz;', '&#9674;', true, 'lozenge'],
['&spades;', '&#9824;', true, 'blackspadesuit'],
['&clubs;', '&#9827;', true, 'blackclubsuit'],
['&hearts;', '&#9829;', true, 'blackheartsuit'],
['&diams;', '&#9830;', true, 'blackdiamondsuit'],
['&ensp;', '&#8194;', false,'enspace'],
['&emsp;', '&#8195;', false,'emspace'],
['&thinsp;', '&#8201;', false,'thinspace'],
['&zwnj;', '&#8204;', false,'zerowidthnonjoiner'],
['&zwj;', '&#8205;', false,'zerowidthjoiner'],
['&lrm;', '&#8206;', false,'lefttorightmark'],
['&rlm;', '&#8207;', false,'righttoleftmark'],
['&shy;', '&#173;', false,'softhyphen']
];
M.atto_charmap = M.atto_charmap || {
/**
* The ID of the current editor.
*
* @type {String}
*/
currentElementId: null,
/**
* The dialogue to select a character.
*
* @type {M.core.dialogue}
*/
dialogue: null,
/**
* Keeps track of the selection made by the user.
*
* @type {Mixed}
*/
selection: null,
/**
* Init.
*
* @param {Object} params
*
* @return {Void}
*/
init: function(params) {
var display_chooser = function(e, elementid) {
e.preventDefault();
if (!M.editor_atto.is_active(elementid)) {
M.editor_atto.focus(elementid);
}
M.atto_charmap.selection = M.editor_atto.get_selection();
if (M.atto_charmap.selection === false) {
return;
}
// Stores what editor we are working on.
M.atto_charmap.currentElementId = elementid;
// Initialising the dialogue.
var dialogue;
if (!M.atto_charmap.dialogue) {
dialogue = new M.core.dialogue({
visible: false,
modal: true,
close: true,
draggable: true
});
// Setting up the content of the dialogue.
dialogue.set('bodyContent', M.atto_charmap.getDialogueContent());
dialogue.set('headerContent', M.util.get_string('insertcharacter', 'atto_charmap'));
dialogue.render();
dialogue.centerDialogue();
M.atto_charmap.dialogue = dialogue;
} else {
dialogue = M.atto_charmap.dialogue;
}
dialogue.show();
};
var iconurl = M.util.image_url('e/special_character', 'core');
M.editor_atto.add_toolbar_button(params.elementid, 'charmap', iconurl, params.group, display_chooser);
},
/**
* Generates the content of the dialogue.
*
* @return {Node} Node containing the dialogue content
*/
getDialogueContent: function() {
var content,
html = '<div class="' + CSS.CHARMAP + '">',
i;
for (i = 0; i < CHARMAP.length; i++) {
if (!CHARMAP[i][2]) {
continue;
}
html += '<button class="' + CSS.BUTTON + '" ' +
'aria-label="' + Y.Escape.html(M.util.get_string(CHARMAP[i][3], 'atto_charmap')) + '" ' +
'title="' + Y.Escape.html(M.util.get_string(CHARMAP[i][3], 'atto_charmap')) + '" ' +
'data-character="' + CHARMAP[i][0] + '" ' +
'>' +
CHARMAP[i][0] +
'</button>';
}
html += '</div>';
content = Y.Node.create(html);
Y.delegate('click', M.atto_charmap.insertChar, content, SELECTORS.BUTTON, this);
return content;
},
/**
* Insert the picked character in Atto.
*
* @param {Event} e The event
* @return {Void}
*/
insertChar: function(e) {
var character = e.target.getData('character');
e.preventDefault();
e.stopPropagation();
M.atto_charmap.dialogue.hide();
M.editor_atto.set_selection(M.atto_charmap.selection);
if (document.selection && document.selection.createRange().pasteHTML) {
document.selection.createRange().pasteHTML(character);
} else {
document.execCommand('insertHTML', false, character);
}
// Clean the YUI ids from the HTML.
M.editor_atto.text_updated(M.atto_charmap.currentElementId);
}
};

View File

@ -0,0 +1,8 @@
{
"moodle-atto_charmap-button": {
"requires": [
"node",
"escape"
]
}
}

View File

@ -33,7 +33,7 @@ if ($ADMIN->fulltree) {
$default = 'style = bold, italic, underline, strike, clear, title' . "\n" .
'paragraph = indent, outdent, orderedlist, unorderedlist' . "\n" .
'links = link, unlink' . "\n" .
'insert = table, image, media' . "\n" .
'insert = table, image, media, charmap' . "\n" .
'other = html';
$setting = new admin_setting_configtextarea('editor_atto/toolbar',
$name,