alloy-editor-config.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. CKEDITOR.lang['en'] = {"editor":"Rich Text Editor","editorPanel":"Rich Text Editor panel","common":{"editorHelp":"Press ALT 0 for help","browseServer":"Browse Server","url":"URL","protocol":"Protocol","upload":"Upload","uploadSubmit":"Send it to the Server","image":"Image","flash":"Flash","form":"Form","checkbox":"Checkbox","radio":"Radio Button","textField":"Text Field","textarea":"Textarea","hiddenField":"Hidden Field","button":"Button","select":"Selection Field","imageButton":"Image Button","notSet":"<not set>","id":"Id","name":"Name","langDir":"Language Direction","langDirLtr":"Left to Right (LTR)","langDirRtl":"Right to Left (RTL)","langCode":"Language Code","longDescr":"Long Description URL","cssClass":"Stylesheet Classes","advisoryTitle":"Advisory Title","cssStyle":"Style","ok":"OK","cancel":"Cancel","close":"Close","preview":"Preview","resize":"Resize","generalTab":"General","advancedTab":"Advanced","validateNumberFailed":"This value is not a number.","confirmNewPage":"Any unsaved changes to this content will be lost. Are you sure you want to load new page?","confirmCancel":"You have changed some options. Are you sure you want to close the dialog window?","options":"Options","target":"Target","targetNew":"New Window (_blank)","targetTop":"Topmost Window (_top)","targetSelf":"Same Window (_self)","targetParent":"Parent Window (_parent)","langDirLTR":"Left to Right (LTR)","langDirRTL":"Right to Left (RTL)","styles":"Style","cssClasses":"Stylesheet Classes","width":"Width","height":"Height","align":"Alignment","alignLeft":"Left","alignRight":"Right","alignCenter":"Center","alignJustify":"Justify","alignTop":"Top","alignMiddle":"Middle","alignBottom":"Bottom","alignNone":"None","invalidValue":"Invalid value.","invalidHeight":"Height must be a number.","invalidWidth":"Width must be a number.","invalidCssLength":"Value specified for the \"%1\" field must be a positive number with or without a valid CSS measurement unit (px, %, in, cm, mm, em, ex, pt, or pc).","invalidHtmlLength":"Value specified for the \"%1\" field must be a positive number with or without a valid HTML measurement unit (px or %).","invalidInlineStyle":"Value specified for the inline style must consist of one or more tuples with the format of \"name : value\", separated by semi-colons.","cssLengthTooltip":"Enter a number for a value in pixels or a number with a valid CSS unit (px, %, in, cm, mm, em, ex, pt, or pc).","unavailable":"%1<span class=\"cke_accessibility\">, unavailable</span>","keyboard":{"8":"Backspace","13":"Enter","16":"Shift","17":"Ctrl","18":"Alt","32":"Space","35":"End","36":"Home","46":"Delete","224":"Command"},"keyboardShortcut":"Keyboard shortcut"},"basicstyles":{"bold":"Bold","italic":"Italic","strike":"Strikethrough","subscript":"Subscript","superscript":"Superscript","underline":"Underline"},"blockquote":{"toolbar":"Block Quote"},"clipboard":{"copy":"Copy","copyError":"Your browser security settings don't permit the editor to automatically execute copying operations. Please use the keyboard for that (Ctrl/Cmd+C).","cut":"Cut","cutError":"Your browser security settings don't permit the editor to automatically execute cutting operations. Please use the keyboard for that (Ctrl/Cmd+X).","paste":"Paste","pasteArea":"Paste Area","pasteMsg":"Please paste inside the following box using the keyboard (<strong>Ctrl/Cmd+V</strong>) and hit OK","securityMsg":"Because of your browser security settings, the editor is not able to access your clipboard data directly. You are required to paste it again in this window.","title":"Paste"},"horizontalrule":{"toolbar":"Insert Horizontal Line"},"indent":{"indent":"Increase Indent","outdent":"Decrease Indent"},"justify":{"block":"Justify","center":"Center","left":"Align Left","right":"Align Right"},"list":{"bulletedlist":"Insert/Remove Bulleted List","numberedlist":"Insert/Remove Numbered List"},"pastefromword":{"confirmCleanup":"The text you want to paste seems to be copied from Word. Do you want to clean it before pasting?","error":"It was not possible to clean up the pasted data due to an internal error","title":"Paste from Word","toolbar":"Paste from Word"},"removeformat":{"toolbar":"Remove Format"},"undo":{"redo":"Redo","undo":"Undo"},"widget":{"move":"Click and drag to move","label":"%1 widget"}};
  2. CKEDITOR.config.stylesSet = []; // We don't need styles.js
  3. CKEDITOR.document.appendStyleSheet = function(e) { return e }; // We load editor.css manually
  4. AlloyEditor.Strings = {"alignCenter":"Center","alignJustify":"Justify","alignLeft":"Left","alignRight":"Right","bold":"Bold","bulletedlist":"Insert/Remove Bulleted List","cancel":"Cancel","horizontalrule":"Insert Horizontal Line","italic":"Italic","numberedlist":"Insert/Remove Numbered List","quote":"Block Quote","removeformat":"Remove Format","strike":"Strikethrough","subscript":"Subscript","superscript":"Superscript","underline":"Underline","formatted":"Formatted","h1":"Heading 1","h2":"Heading 2","normal":"Normal","blockStyles":"Block Styles","inlineStyles":"Inline Styles","objectStyles":"Object Styles","styles":"Styles","cell":"Cell","cellDelete":"Delete Cells","cellInsertAfter":"Insert Cell After","cellInsertBefore":"Insert Cell Before","cellMerge":"Merge Cells","cellMergeDown":"Merge Down","cellMergeRight":"Merge Right","cellSplitHorizontal":"Split Cell Horizontally","cellSplitVertical":"Split Cell Vertically","column":"Column","columnDelete":"Delete Columns","columnInsertAfter":"Insert Column After","columnInsertBefore":"Insert Column Before","deleteTable":"Delete Table","row":"Row","rowDelete":"Delete Rows","rowInsertAfter":"Insert Row After","rowInsertBefore":"Insert Row Before","add":"Add","ariaUpdateNoToolbar":"No toolbars are available","ariaUpdateOneToolbar":"{toolbars} toolbar is available. Press ALT+F10 to focus.","ariaUpdateManyToolbars":"{toolbars} toolbars are available. Press ALT+F10 to focus.","camera":"Insert Image from Camera","cite":"Cite","code":"Code","clearInput":"Clear Input Field","confirm":"Confirm","editLink":"Type or paste link here","image":"Insert Image","link":"Link","removeLink":"Remove link","table":"Insert Table","twitter":"Twitter","headers":"Headers","headersBoth":"Both","headersColumn":"First column","headersNone":"None","headersRow":"First Row","linkTargetBlank":"_blank (new tab)","linkTargetDefault":"default","linkTargetParent":"_parent","linkTargetSelf":"_self (same tab)","linkTargetTop":"_top","cameraDisabled":"The browser does not support this action, or it is available on https only (Chrome).","indent":"Increase Indent","outdent":"Decrease Indent","deleteEmbed":"Delete embed","columns":"Cols","rows":"Rows"};
  5. AlloyEditor._langResourceRequested = true; // We include en.js
  6. // Inline code button
  7. React = AlloyEditor.React;
  8. var ButtonInlineCode = React.createClass({
  9. displayName: 'ButtonInlineCode',
  10. mixins: [AlloyEditor.ButtonStyle, AlloyEditor.ButtonStateClasses, AlloyEditor.ButtonActionStyle],
  11. propTypes: {
  12. editor: React.PropTypes.object.isRequired,
  13. label: React.PropTypes.string,
  14. tabIndex: React.PropTypes.number
  15. },
  16. statics: {
  17. key: 'inlinecode'
  18. },
  19. getDefaultProps: function getDefaultProps() {
  20. return {
  21. style: {
  22. element: 'code'
  23. }
  24. };
  25. },
  26. render: function render() {
  27. var cssClass = 'ae-button ' + this.getStateClasses();
  28. return React.createElement(
  29. 'button',
  30. { 'aria-label': AlloyEditor.Strings.code, 'aria-pressed': cssClass.indexOf('pressed') !== -1, className: cssClass, 'data-type': 'button-code', onClick: this.applyStyle, tabIndex: this.props.tabIndex, title: AlloyEditor.Strings.code },
  31. React.createElement('span', { className: 'ae-icon-code' })
  32. );
  33. }
  34. });
  35. AlloyEditor.Buttons[ButtonInlineCode.key] = AlloyEditor.ButtonInlineCode = ButtonInlineCode;
  36. var ButtonH3 = React.createClass({
  37. displayName: 'ButtonH3',
  38. mixins: [AlloyEditor.ButtonStyle, AlloyEditor.ButtonStateClasses, AlloyEditor.ButtonActionStyle],
  39. propTypes: {
  40. editor: React.PropTypes.object.isRequired,
  41. label: React.PropTypes.string,
  42. tabIndex: React.PropTypes.number
  43. },
  44. statics: {
  45. key: 'h3'
  46. },
  47. getDefaultProps: function getDefaultProps() {
  48. return {
  49. style: {
  50. element: 'h3'
  51. }
  52. };
  53. },
  54. render: function render() {
  55. var cssClass = 'ae-button ' + this.getStateClasses();
  56. return React.createElement(
  57. 'button',
  58. { 'aria-label': AlloyEditor.Strings.h3, 'aria-pressed': cssClass.indexOf('pressed') !== -1, className: cssClass, 'data-type': 'button-h3', onClick: this.applyStyle, tabIndex: this.props.tabIndex, title: "Heading 3" },
  59. React.createElement('span', { className: 'ae-icon-h3' })
  60. );
  61. }
  62. });
  63. AlloyEditor.Buttons[ButtonH3.key] = AlloyEditor.ButtonH3 = ButtonH3;
  64. selections = AlloyEditor.Selections
  65. selections.unshift({
  66. name: 'text',
  67. buttons: ['bold', 'italic', 'strike', 'inlinecode', 'link'],
  68. test: AlloyEditor.SelectionTest.text
  69. })
  70. // Remove Image toolbar
  71. AlloyEditor.Core.ATTRS.toolbars.value.styles.selections.forEach(
  72. function(selection, i, selections) {
  73. if (selection.name == "image") selections.splice(i, 1)
  74. }
  75. )
  76. // Other settings
  77. CKEDITOR.config.language = "en"
  78. CKEDITOR.config.title = ""
  79. CKEDITOR.config.fullPage = true
  80. CKEDITOR.config.pasteFromWordRemoveFontStyles = true
  81. CKEDITOR.config.removePlugins = "dragdrop"
  82. AlloyEditor.Core.ATTRS.removePlugins.value += ',ae_embed,ae_imagealignment,ae_dragresize'
  83. AlloyEditor.Buttons.linkEdit.defaultProps.appendProtocol = false
  84. CKEDITOR.config.buttonCfg = {
  85. buttonLinkEdit: {
  86. appendProtocol: false
  87. }
  88. }
  89. AlloyEditor.Core.ATTRS.toolbars.value = {
  90. add: {
  91. buttons: ['h2', 'h3', 'quote', 'code', 'hline', 'table', 'image'],
  92. tabIndex: 2
  93. },
  94. styles: {
  95. selections: selections,
  96. tabIndex: 1
  97. }
  98. }
  99. CKEDITOR.config.customConfig = "";
  100. // Helpers
  101. function createSelectionFromPoint(startX, startY, endX, endY) { // Select text based on x y coordinates
  102. var doc = document;
  103. var start, end, range = null;
  104. if (typeof doc.caretPositionFromPoint != "undefined") {
  105. start = doc.caretPositionFromPoint(startX, startY);
  106. end = doc.caretPositionFromPoint(endX, endY);
  107. range = doc.createRange();
  108. range.setStart(start.offsetNode, start.offset);
  109. range.setEnd(end.offsetNode, end.offset);
  110. } else if (typeof doc.caretRangeFromPoint != "undefined") {
  111. start = doc.caretRangeFromPoint(startX, startY);
  112. end = doc.caretRangeFromPoint(endX, endY);
  113. range = doc.createRange();
  114. range.setStart(start.startContainer, start.startOffset);
  115. range.setEnd(end.startContainer, end.startOffset);
  116. }
  117. if (range !== null && typeof window.getSelection != "undefined") {
  118. var sel = window.getSelection();
  119. sel.removeAllRanges();
  120. sel.addRange(range);
  121. } else if (typeof doc.body.createTextRange != "undefined") {
  122. range = doc.body.createTextRange();
  123. range.moveToPoint(startX, startY);
  124. var endRange = range.duplicate();
  125. endRange.moveToPoint(endX, endY);
  126. range.setEndPoint("EndToEnd", endRange);
  127. range.select();
  128. }
  129. }
  130. function selectElement(editor, elem) { // Select CKEditor element
  131. var range = new CKEDITOR.dom.range(editor.document);
  132. range.moveToElementEditablePosition(elem, true);
  133. range.setStart(elem, 0)
  134. range.setEnd(elem, elem.getChildCount())
  135. editor.getSelection().selectRanges([range]);
  136. }