|
1 | 1 | /**
|
2 |
| - * simplemde v1.11.1 |
| 2 | + * simplemde v1.11.2 |
3 | 3 | * Copyright Next Step Webs, Inc.
|
4 | 4 | * @link https://github.com/NextStepWebs/simplemde-markdown-editor
|
5 | 5 | * @license MIT
|
@@ -1833,107 +1833,125 @@ function isnan (val) {
|
1833 | 1833 |
|
1834 | 1834 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
1835 | 1835 | },{"base64-js":1,"ieee754":15,"isarray":16}],4:[function(require,module,exports){
|
1836 |
| -/* globals CodeMirror */ |
1837 |
| -// Use strict mode (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) |
1838 |
| -"use strict"; |
1839 |
| - |
1840 |
| - |
1841 |
| -// Requires |
1842 |
| -var Typo = require("typo-js"); |
1843 |
| - |
1844 |
| - |
1845 |
| -// Initialize data globally to reduce memory consumption |
1846 |
| -var num_loaded = 0; |
1847 |
| -var aff_loading = false; |
1848 |
| -var dic_loading = false; |
1849 |
| -var aff_data = ""; |
1850 |
| -var dic_data = ""; |
1851 |
| -var typo; |
1852 |
| - |
1853 |
| - |
1854 |
| -CodeMirror.defineMode("spell-checker", function(config) { |
1855 |
| - // Load AFF/DIC data |
1856 |
| - if(!aff_loading) { |
1857 |
| - aff_loading = true; |
1858 |
| - var xhr_aff = new XMLHttpRequest(); |
1859 |
| - xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true); |
1860 |
| - xhr_aff.onload = function() { |
1861 |
| - if(xhr_aff.readyState === 4 && xhr_aff.status === 200) { |
1862 |
| - aff_data = xhr_aff.responseText; |
1863 |
| - num_loaded++; |
1864 |
| - |
1865 |
| - if(num_loaded == 2) { |
1866 |
| - typo = new Typo("en_US", aff_data, dic_data, { |
1867 |
| - platform: "any" |
1868 |
| - }); |
1869 |
| - } |
1870 |
| - } |
1871 |
| - }; |
1872 |
| - xhr_aff.send(null); |
1873 |
| - } |
1874 |
| - |
1875 |
| - if(!dic_loading) { |
1876 |
| - dic_loading = true; |
1877 |
| - var xhr_dic = new XMLHttpRequest(); |
1878 |
| - xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true); |
1879 |
| - xhr_dic.onload = function() { |
1880 |
| - if(xhr_dic.readyState === 4 && xhr_dic.status === 200) { |
1881 |
| - dic_data = xhr_dic.responseText; |
1882 |
| - num_loaded++; |
1883 |
| - |
1884 |
| - if(num_loaded == 2) { |
1885 |
| - typo = new Typo("en_US", aff_data, dic_data, { |
1886 |
| - platform: "any" |
1887 |
| - }); |
1888 |
| - } |
1889 |
| - } |
1890 |
| - }; |
1891 |
| - xhr_dic.send(null); |
1892 |
| - } |
1893 |
| - |
1894 |
| - |
1895 |
| - // Define what separates a word |
1896 |
| - var rx_word = "!\"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ "; |
1897 |
| - |
1898 |
| - |
1899 |
| - // Create the overlay and such |
1900 |
| - var overlay = { |
1901 |
| - token: function(stream) { |
1902 |
| - var ch = stream.peek(); |
1903 |
| - var word = ""; |
1904 |
| - |
1905 |
| - if(rx_word.includes(ch)) { |
1906 |
| - stream.next(); |
1907 |
| - return null; |
1908 |
| - } |
1909 |
| - |
1910 |
| - while((ch = stream.peek()) != null && !rx_word.includes(ch)) { |
1911 |
| - word += ch; |
1912 |
| - stream.next(); |
1913 |
| - } |
1914 |
| - |
1915 |
| - if(typo && !typo.check(word)) |
1916 |
| - return "spell-error"; // CSS class: cm-spell-error |
1917 |
| - |
1918 |
| - return null; |
1919 |
| - } |
1920 |
| - }; |
1921 |
| - |
1922 |
| - var mode = CodeMirror.getMode( |
1923 |
| - config, config.backdrop || "text/plain" |
1924 |
| - ); |
1925 |
| - |
1926 |
| - return CodeMirror.overlayMode(mode, overlay, true); |
1927 |
| -}); |
1928 |
| - |
1929 |
| - |
1930 |
| -// Because some browsers don't support this functionality yet |
1931 |
| -if(!String.prototype.includes) { |
1932 |
| - String.prototype.includes = function() { |
1933 |
| - "use strict"; |
1934 |
| - return String.prototype.indexOf.apply(this, arguments) !== -1; |
1935 |
| - }; |
| 1836 | +// Use strict mode (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) |
| 1837 | +"use strict"; |
| 1838 | + |
| 1839 | + |
| 1840 | +// Requires |
| 1841 | +var Typo = require("typo-js"); |
| 1842 | + |
| 1843 | + |
| 1844 | +// Create function |
| 1845 | +function CodeMirrorSpellChecker(options) { |
| 1846 | + // Initialize |
| 1847 | + options = options || {}; |
| 1848 | + |
| 1849 | + |
| 1850 | + // Verify |
| 1851 | + if(typeof options.codeMirrorInstance !== "function" || typeof options.codeMirrorInstance.defineMode !== "function") { |
| 1852 | + console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`"); |
| 1853 | + return; |
| 1854 | + } |
| 1855 | + |
| 1856 | + |
| 1857 | + // Because some browsers don't support this functionality yet |
| 1858 | + if(!String.prototype.includes) { |
| 1859 | + String.prototype.includes = function() { |
| 1860 | + "use strict"; |
| 1861 | + return String.prototype.indexOf.apply(this, arguments) !== -1; |
| 1862 | + }; |
| 1863 | + } |
| 1864 | + |
| 1865 | + |
| 1866 | + // Define the new mode |
| 1867 | + options.codeMirrorInstance.defineMode("spell-checker", function(config) { |
| 1868 | + // Load AFF/DIC data |
| 1869 | + if(!CodeMirrorSpellChecker.aff_loading) { |
| 1870 | + CodeMirrorSpellChecker.aff_loading = true; |
| 1871 | + var xhr_aff = new XMLHttpRequest(); |
| 1872 | + xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true); |
| 1873 | + xhr_aff.onload = function() { |
| 1874 | + if(xhr_aff.readyState === 4 && xhr_aff.status === 200) { |
| 1875 | + CodeMirrorSpellChecker.aff_data = xhr_aff.responseText; |
| 1876 | + CodeMirrorSpellChecker.num_loaded++; |
| 1877 | + |
| 1878 | + if(CodeMirrorSpellChecker.num_loaded == 2) { |
| 1879 | + CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, { |
| 1880 | + platform: "any" |
| 1881 | + }); |
| 1882 | + } |
| 1883 | + } |
| 1884 | + }; |
| 1885 | + xhr_aff.send(null); |
| 1886 | + } |
| 1887 | + |
| 1888 | + if(!CodeMirrorSpellChecker.dic_loading) { |
| 1889 | + CodeMirrorSpellChecker.dic_loading = true; |
| 1890 | + var xhr_dic = new XMLHttpRequest(); |
| 1891 | + xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true); |
| 1892 | + xhr_dic.onload = function() { |
| 1893 | + if(xhr_dic.readyState === 4 && xhr_dic.status === 200) { |
| 1894 | + CodeMirrorSpellChecker.dic_data = xhr_dic.responseText; |
| 1895 | + CodeMirrorSpellChecker.num_loaded++; |
| 1896 | + |
| 1897 | + if(CodeMirrorSpellChecker.num_loaded == 2) { |
| 1898 | + CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, { |
| 1899 | + platform: "any" |
| 1900 | + }); |
| 1901 | + } |
| 1902 | + } |
| 1903 | + }; |
| 1904 | + xhr_dic.send(null); |
| 1905 | + } |
| 1906 | + |
| 1907 | + |
| 1908 | + // Define what separates a word |
| 1909 | + var rx_word = "!\"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ "; |
| 1910 | + |
| 1911 | + |
| 1912 | + // Create the overlay and such |
| 1913 | + var overlay = { |
| 1914 | + token: function(stream) { |
| 1915 | + var ch = stream.peek(); |
| 1916 | + var word = ""; |
| 1917 | + |
| 1918 | + if(rx_word.includes(ch)) { |
| 1919 | + stream.next(); |
| 1920 | + return null; |
| 1921 | + } |
| 1922 | + |
| 1923 | + while((ch = stream.peek()) != null && !rx_word.includes(ch)) { |
| 1924 | + word += ch; |
| 1925 | + stream.next(); |
| 1926 | + } |
| 1927 | + |
| 1928 | + if(CodeMirrorSpellChecker.typo && !CodeMirrorSpellChecker.typo.check(word)) |
| 1929 | + return "spell-error"; // CSS class: cm-spell-error |
| 1930 | + |
| 1931 | + return null; |
| 1932 | + } |
| 1933 | + }; |
| 1934 | + |
| 1935 | + var mode = options.codeMirrorInstance.getMode( |
| 1936 | + config, config.backdrop || "text/plain" |
| 1937 | + ); |
| 1938 | + |
| 1939 | + return options.codeMirrorInstance.overlayMode(mode, overlay, true); |
| 1940 | + }); |
1936 | 1941 | }
|
| 1942 | + |
| 1943 | + |
| 1944 | +// Initialize data globally to reduce memory consumption |
| 1945 | +CodeMirrorSpellChecker.num_loaded = 0; |
| 1946 | +CodeMirrorSpellChecker.aff_loading = false; |
| 1947 | +CodeMirrorSpellChecker.dic_loading = false; |
| 1948 | +CodeMirrorSpellChecker.aff_data = ""; |
| 1949 | +CodeMirrorSpellChecker.dic_data = ""; |
| 1950 | +CodeMirrorSpellChecker.typo; |
| 1951 | + |
| 1952 | + |
| 1953 | +// Export |
| 1954 | +module.exports = CodeMirrorSpellChecker; |
1937 | 1955 | },{"typo-js":18}],5:[function(require,module,exports){
|
1938 | 1956 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
|
1939 | 1957 | // Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
0 commit comments