123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- import {
- __commonJS
- } from "./chunk-2LSFTFF7.js";
- // node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/wordcount/plugin.js
- var require_plugin = __commonJS({
- "node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/wordcount/plugin.js"() {
- (function() {
- "use strict";
- var global$2 = tinymce.util.Tools.resolve("tinymce.PluginManager");
- var identity = function(x) {
- return x;
- };
- var __assign = function() {
- __assign = Object.assign || function __assign2(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s)
- if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var zeroWidth = "\uFEFF";
- var removeZwsp$1 = function(s) {
- return s.replace(/\uFEFF/g, "");
- };
- var map = function(xs, f) {
- var len = xs.length;
- var r = new Array(len);
- for (var i = 0; i < len; i++) {
- var x = xs[i];
- r[i] = f(x, i);
- }
- return r;
- };
- var punctuationStr = "[!-#%-*,-\\/:;?@\\[-\\]_{}¡«·»¿;·՚-՟։֊־׀׃׆׳״؉؊،؍؛؞؟٪-٭۔܀-܍߷-߹࠰-࠾࡞।॥॰෴๏๚๛༄-༒༺-༽྅࿐-࿔࿙࿚၊-၏჻፡-፨᐀᙭᙮᚛᚜᛫-᛭᜵᜶។-៖៘-៚᠀-᠊᥄᥅᨞᨟᪠-᪦᪨-᪭᭚-᭠᯼-᯿᰻-᰿᱾᱿᳓‐-‧‰-⁃⁅-⁑⁓-⁞⁽⁾₍₎〈〉❨-❵⟅⟆⟦-⟯⦃-⦘⧘-⧛⧼⧽⳹-⳼⳾⳿⵰⸀-⸮⸰⸱、-〃〈-】〔-〟〰〽゠・꓾꓿꘍-꘏꙳꙾꛲-꛷꡴-꡷꣎꣏꣸-꣺꤮꤯꥟꧁-꧍꧞꧟꩜-꩟꫞꫟꯫﴾﴿︐-︙︰-﹒﹔-﹡﹣﹨﹪﹫!-#%-*,-/:;?@[-]_{}⦅-・]";
- var regExps = {
- aletter: "[A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-׳ؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆༀཀ-ཇཉ-ཬྈ-ྌႠ-Ⴥა-ჺჼᄀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᨀ-ᨖᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᯀ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⒶ-ⓩⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⴀ-ⴥⴰ-ⵥⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〻〼ㄅ-ㄭㄱ-ㆎㆠ-ㆺꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐꞑꞠ-ꞩꟺ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zᅠ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]",
- midnumlet: "[-'\\.‘’․﹒'.]",
- midletter: "[:··״‧︓﹕:]",
- midnum: "[±+*/,;;։،؍٬߸⁄︐︔﹐﹔,;]",
- numeric: "[0-9٠-٩٫۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹]",
- cr: "\\r",
- lf: "\\n",
- newline: "[\v\f
\u2028\u2029]",
- extend: "[̀-ͯ҃-҉֑-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ऀ-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣஂா-ூெ-ைொ-்ௗఁ-ఃా-ౄె-ైొ-్ౕౖౢౣಂಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣംഃാ-ൄെ-ൈൊ-്ൗൢൣංඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ູົຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳា-៓៝᠋-᠍ᢩᤠ-ᤫᤰ-᤻ᦰ-ᧀᧈᧉᨗ-ᨛᩕ-ᩞ᩠-᩿᩼ᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-᯦᮪-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭ᳲ᷀-ᷦ᷼-᷿⃐-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯-꙲꙼꙽꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣠-꣱ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꨩ-ꨶꩃꩌꩍꩻꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꯣ-ꯪ꯬꯭ﬞ︀-️︠-゙゚︦]",
- format: "[-឴឵---\uFEFF-]",
- katakana: "[〱-〵゛゜゠-ヺー-ヿㇰ-ㇿ㋐-㋾㌀-㍗ヲ-ン]",
- extendnumlet: "[=_‿⁀⁔︳︴﹍-﹏_∀-⋿<>]",
- punctuation: punctuationStr
- };
- var characterIndices = {
- ALETTER: 0,
- MIDNUMLET: 1,
- MIDLETTER: 2,
- MIDNUM: 3,
- NUMERIC: 4,
- CR: 5,
- LF: 6,
- NEWLINE: 7,
- EXTEND: 8,
- FORMAT: 9,
- KATAKANA: 10,
- EXTENDNUMLET: 11,
- AT: 12,
- OTHER: 13
- };
- var SETS$1 = [
- new RegExp(regExps.aletter),
- new RegExp(regExps.midnumlet),
- new RegExp(regExps.midletter),
- new RegExp(regExps.midnum),
- new RegExp(regExps.numeric),
- new RegExp(regExps.cr),
- new RegExp(regExps.lf),
- new RegExp(regExps.newline),
- new RegExp(regExps.extend),
- new RegExp(regExps.format),
- new RegExp(regExps.katakana),
- new RegExp(regExps.extendnumlet),
- new RegExp("@")
- ];
- var EMPTY_STRING$1 = "";
- var PUNCTUATION$1 = new RegExp("^" + regExps.punctuation + "$");
- var WHITESPACE$1 = /^\s+$/;
- var SETS = SETS$1;
- var OTHER = characterIndices.OTHER;
- var getType = function(char) {
- var type = OTHER;
- var setsLength = SETS.length;
- for (var j = 0; j < setsLength; ++j) {
- var set = SETS[j];
- if (set && set.test(char)) {
- type = j;
- break;
- }
- }
- return type;
- };
- var memoize = function(func) {
- var cache = {};
- return function(char) {
- if (cache[char]) {
- return cache[char];
- } else {
- var result = func(char);
- cache[char] = result;
- return result;
- }
- };
- };
- var classify = function(characters) {
- var memoized = memoize(getType);
- return map(characters, memoized);
- };
- var isWordBoundary = function(map2, index) {
- var type = map2[index];
- var nextType = map2[index + 1];
- if (index < 0 || index > map2.length - 1 && index !== 0) {
- return false;
- }
- if (type === characterIndices.ALETTER && nextType === characterIndices.ALETTER) {
- return false;
- }
- var nextNextType = map2[index + 2];
- if (type === characterIndices.ALETTER && (nextType === characterIndices.MIDLETTER || nextType === characterIndices.MIDNUMLET || nextType === characterIndices.AT) && nextNextType === characterIndices.ALETTER) {
- return false;
- }
- var prevType = map2[index - 1];
- if ((type === characterIndices.MIDLETTER || type === characterIndices.MIDNUMLET || nextType === characterIndices.AT) && nextType === characterIndices.ALETTER && prevType === characterIndices.ALETTER) {
- return false;
- }
- if ((type === characterIndices.NUMERIC || type === characterIndices.ALETTER) && (nextType === characterIndices.NUMERIC || nextType === characterIndices.ALETTER)) {
- return false;
- }
- if ((type === characterIndices.MIDNUM || type === characterIndices.MIDNUMLET) && nextType === characterIndices.NUMERIC && prevType === characterIndices.NUMERIC) {
- return false;
- }
- if (type === characterIndices.NUMERIC && (nextType === characterIndices.MIDNUM || nextType === characterIndices.MIDNUMLET) && nextNextType === characterIndices.NUMERIC) {
- return false;
- }
- if (type === characterIndices.EXTEND || type === characterIndices.FORMAT || prevType === characterIndices.EXTEND || prevType === characterIndices.FORMAT || nextType === characterIndices.EXTEND || nextType === characterIndices.FORMAT) {
- return false;
- }
- if (type === characterIndices.CR && nextType === characterIndices.LF) {
- return false;
- }
- if (type === characterIndices.NEWLINE || type === characterIndices.CR || type === characterIndices.LF) {
- return true;
- }
- if (nextType === characterIndices.NEWLINE || nextType === characterIndices.CR || nextType === characterIndices.LF) {
- return true;
- }
- if (type === characterIndices.KATAKANA && nextType === characterIndices.KATAKANA) {
- return false;
- }
- if (nextType === characterIndices.EXTENDNUMLET && (type === characterIndices.ALETTER || type === characterIndices.NUMERIC || type === characterIndices.KATAKANA || type === characterIndices.EXTENDNUMLET)) {
- return false;
- }
- if (type === characterIndices.EXTENDNUMLET && (nextType === characterIndices.ALETTER || nextType === characterIndices.NUMERIC || nextType === characterIndices.KATAKANA)) {
- return false;
- }
- if (type === characterIndices.AT) {
- return false;
- }
- return true;
- };
- var EMPTY_STRING = EMPTY_STRING$1;
- var WHITESPACE = WHITESPACE$1;
- var PUNCTUATION = PUNCTUATION$1;
- var isProtocol = function(str) {
- return str === "http" || str === "https";
- };
- var findWordEnd = function(characters, startIndex) {
- var i;
- for (i = startIndex; i < characters.length; i++) {
- if (WHITESPACE.test(characters[i])) {
- break;
- }
- }
- return i;
- };
- var findUrlEnd = function(characters, startIndex) {
- var endIndex = findWordEnd(characters, startIndex + 1);
- var peakedWord = characters.slice(startIndex + 1, endIndex).join(EMPTY_STRING);
- return peakedWord.substr(0, 3) === "://" ? endIndex : startIndex;
- };
- var findWords = function(chars, sChars, characterMap, options) {
- var words = [];
- var word = [];
- for (var i = 0; i < characterMap.length; ++i) {
- word.push(chars[i]);
- if (isWordBoundary(characterMap, i)) {
- var ch = sChars[i];
- if ((options.includeWhitespace || !WHITESPACE.test(ch)) && (options.includePunctuation || !PUNCTUATION.test(ch))) {
- var startOfWord = i - word.length + 1;
- var endOfWord = i + 1;
- var str = sChars.slice(startOfWord, endOfWord).join(EMPTY_STRING);
- if (isProtocol(str)) {
- var endOfUrl = findUrlEnd(sChars, i);
- var url = chars.slice(endOfWord, endOfUrl);
- Array.prototype.push.apply(word, url);
- i = endOfUrl;
- }
- words.push(word);
- }
- word = [];
- }
- }
- return words;
- };
- var getDefaultOptions = function() {
- return {
- includeWhitespace: false,
- includePunctuation: false
- };
- };
- var getWords$1 = function(chars, extract, options) {
- options = __assign(__assign({}, getDefaultOptions()), options);
- var filteredChars = [];
- var extractedChars = [];
- for (var i = 0; i < chars.length; i++) {
- var ch = extract(chars[i]);
- if (ch !== zeroWidth) {
- filteredChars.push(chars[i]);
- extractedChars.push(ch);
- }
- }
- var characterMap = classify(extractedChars);
- return findWords(filteredChars, extractedChars, characterMap, options);
- };
- var getWords = getWords$1;
- var global$1 = tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");
- var getText = function(node, schema) {
- var blockElements = schema.getBlockElements();
- var shortEndedElements = schema.getShortEndedElements();
- var isNewline = function(node2) {
- return blockElements[node2.nodeName] || shortEndedElements[node2.nodeName];
- };
- var textBlocks = [];
- var txt = "";
- var treeWalker = new global$1(node, node);
- while (node = treeWalker.next()) {
- if (node.nodeType === 3) {
- txt += removeZwsp$1(node.data);
- } else if (isNewline(node) && txt.length) {
- textBlocks.push(txt);
- txt = "";
- }
- }
- if (txt.length) {
- textBlocks.push(txt);
- }
- return textBlocks;
- };
- var removeZwsp = function(text) {
- return text.replace(/\u200B/g, "");
- };
- var strLen = function(str) {
- return str.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
- };
- var countWords = function(node, schema) {
- var text = removeZwsp(getText(node, schema).join("\n"));
- return getWords(text.split(""), identity).length;
- };
- var countCharacters = function(node, schema) {
- var text = getText(node, schema).join("");
- return strLen(text);
- };
- var countCharactersWithoutSpaces = function(node, schema) {
- var text = getText(node, schema).join("").replace(/\s/g, "");
- return strLen(text);
- };
- var createBodyCounter = function(editor, count) {
- return function() {
- return count(editor.getBody(), editor.schema);
- };
- };
- var createSelectionCounter = function(editor, count) {
- return function() {
- return count(editor.selection.getRng().cloneContents(), editor.schema);
- };
- };
- var createBodyWordCounter = function(editor) {
- return createBodyCounter(editor, countWords);
- };
- var get = function(editor) {
- return {
- body: {
- getWordCount: createBodyWordCounter(editor),
- getCharacterCount: createBodyCounter(editor, countCharacters),
- getCharacterCountWithoutSpaces: createBodyCounter(editor, countCharactersWithoutSpaces)
- },
- selection: {
- getWordCount: createSelectionCounter(editor, countWords),
- getCharacterCount: createSelectionCounter(editor, countCharacters),
- getCharacterCountWithoutSpaces: createSelectionCounter(editor, countCharactersWithoutSpaces)
- },
- getCount: createBodyWordCounter(editor)
- };
- };
- var open = function(editor, api) {
- editor.windowManager.open({
- title: "Word Count",
- body: {
- type: "panel",
- items: [{
- type: "table",
- header: [
- "Count",
- "Document",
- "Selection"
- ],
- cells: [
- [
- "Words",
- String(api.body.getWordCount()),
- String(api.selection.getWordCount())
- ],
- [
- "Characters (no spaces)",
- String(api.body.getCharacterCountWithoutSpaces()),
- String(api.selection.getCharacterCountWithoutSpaces())
- ],
- [
- "Characters",
- String(api.body.getCharacterCount()),
- String(api.selection.getCharacterCount())
- ]
- ]
- }]
- },
- buttons: [{
- type: "cancel",
- name: "close",
- text: "Close",
- primary: true
- }]
- });
- };
- var register$1 = function(editor, api) {
- editor.addCommand("mceWordCount", function() {
- return open(editor, api);
- });
- };
- var global = tinymce.util.Tools.resolve("tinymce.util.Delay");
- var fireWordCountUpdate = function(editor, api) {
- editor.fire("wordCountUpdate", {
- wordCount: {
- words: api.body.getWordCount(),
- characters: api.body.getCharacterCount(),
- charactersWithoutSpaces: api.body.getCharacterCountWithoutSpaces()
- }
- });
- };
- var updateCount = function(editor, api) {
- fireWordCountUpdate(editor, api);
- };
- var setup = function(editor, api, delay) {
- var debouncedUpdate = global.debounce(function() {
- return updateCount(editor, api);
- }, delay);
- editor.on("init", function() {
- updateCount(editor, api);
- global.setEditorTimeout(editor, function() {
- editor.on("SetContent BeforeAddUndo Undo Redo ViewUpdate keyup", debouncedUpdate);
- }, 0);
- });
- };
- var register = function(editor) {
- var onAction = function() {
- return editor.execCommand("mceWordCount");
- };
- editor.ui.registry.addButton("wordcount", {
- tooltip: "Word count",
- icon: "character-count",
- onAction
- });
- editor.ui.registry.addMenuItem("wordcount", {
- text: "Word count",
- icon: "character-count",
- onAction
- });
- };
- function Plugin(delay) {
- if (delay === void 0) {
- delay = 300;
- }
- global$2.add("wordcount", function(editor) {
- var api = get(editor);
- register$1(editor, api);
- register(editor);
- setup(editor, api, delay);
- return api;
- });
- }
- Plugin();
- })();
- }
- });
- // node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/wordcount/index.js
- require_plugin();
- //# sourceMappingURL=tinymce_plugins_wordcount.js.map
|