@bigbinary/neeto-editor 1.43.28 → 1.43.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/headerLinks.js
CHANGED
|
@@ -38,8 +38,16 @@ var buildHeaderLinks = function buildHeaderLinks(editorContentNode) {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
// eslint-disable-next-line @bigbinary/neeto/file-name-and-export-name-standards
|
|
42
|
+
var applyDecorations = function applyDecorations() {
|
|
42
43
|
var editorContent = document.querySelector(".neeto-editor-content");
|
|
43
44
|
if (editorContent) buildHeaderLinks(editorContent);
|
|
44
|
-
}
|
|
45
|
+
};
|
|
46
|
+
(function (_window$neetoEditor) {
|
|
47
|
+
if (document.readyState === "loading") {
|
|
48
|
+
document.addEventListener("DOMContentLoaded", applyDecorations);
|
|
49
|
+
} else applyDecorations();
|
|
50
|
+
window.neetoEditor = (_window$neetoEditor = window.neetoEditor) !== null && _window$neetoEditor !== void 0 ? _window$neetoEditor : {};
|
|
51
|
+
window.neetoEditor.applyHeaderDecorations = applyDecorations;
|
|
52
|
+
})();
|
|
45
53
|
//# sourceMappingURL=headerLinks.js.map
|
package/dist/headerLinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headerLinks.js","sources":["../src/components/EditorContent/utils/headers.js","../src/components/EditorContent/headerLinks.js"],"sourcesContent":["const buildLinkSVG = () => {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const svgWrapper = document.createElement(\"span\");\n svgWrapper.classList.add(\"header-link-icon-wrapper\");\n const svg = document.createElementNS(svgNS, \"svg\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.setAttribute(\"height\", \"20\");\n svg.setAttribute(\"viewBox\", \"0 0 16 16\");\n svg.setAttribute(\"width\", \"20\");\n\n const path = document.createElementNS(svgNS, \"path\");\n path.setAttribute(\n \"d\",\n \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n );\n\n svg.appendChild(path);\n svgWrapper.appendChild(svg);\n\n return svgWrapper;\n};\n\nconst convertTextToId = text =>\n text\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9\\s]/g, \"\")\n .replace(/\\s+/g, \"-\");\n\nexport const buildHeaderLinks = editorContentNode => {\n const headerTags = editorContentNode.querySelectorAll(\n \"h1, h2, h3, h4, h5, h6\"\n );\n const usedIds = new Map();\n\n headerTags.forEach(heading => {\n let headingId = convertTextToId(heading.textContent);\n if (usedIds.has(headingId)) {\n const count = usedIds.get(headingId);\n usedIds.set(headingId, count + 1);\n headingId = `${headingId}-${count}`;\n } else usedIds.set(headingId, 1);\n\n heading.setAttribute(\"id\", headingId);\n\n const anchor = document.createElement(\"a\");\n anchor.setAttribute(\"href\", `#${headingId}`);\n anchor.classList.add(\"header-wrapper-link\");\n anchor.appendChild(buildLinkSVG());\n anchor.appendChild(heading.cloneNode(true));\n\n heading.replaceWith(anchor);\n });\n};\n","
|
|
1
|
+
{"version":3,"file":"headerLinks.js","sources":["../src/components/EditorContent/utils/headers.js","../src/components/EditorContent/headerLinks.js"],"sourcesContent":["const buildLinkSVG = () => {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const svgWrapper = document.createElement(\"span\");\n svgWrapper.classList.add(\"header-link-icon-wrapper\");\n const svg = document.createElementNS(svgNS, \"svg\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.setAttribute(\"height\", \"20\");\n svg.setAttribute(\"viewBox\", \"0 0 16 16\");\n svg.setAttribute(\"width\", \"20\");\n\n const path = document.createElementNS(svgNS, \"path\");\n path.setAttribute(\n \"d\",\n \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n );\n\n svg.appendChild(path);\n svgWrapper.appendChild(svg);\n\n return svgWrapper;\n};\n\nconst convertTextToId = text =>\n text\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9\\s]/g, \"\")\n .replace(/\\s+/g, \"-\");\n\nexport const buildHeaderLinks = editorContentNode => {\n const headerTags = editorContentNode.querySelectorAll(\n \"h1, h2, h3, h4, h5, h6\"\n );\n const usedIds = new Map();\n\n headerTags.forEach(heading => {\n let headingId = convertTextToId(heading.textContent);\n if (usedIds.has(headingId)) {\n const count = usedIds.get(headingId);\n usedIds.set(headingId, count + 1);\n headingId = `${headingId}-${count}`;\n } else usedIds.set(headingId, 1);\n\n heading.setAttribute(\"id\", headingId);\n\n const anchor = document.createElement(\"a\");\n anchor.setAttribute(\"href\", `#${headingId}`);\n anchor.classList.add(\"header-wrapper-link\");\n anchor.appendChild(buildLinkSVG());\n anchor.appendChild(heading.cloneNode(true));\n\n heading.replaceWith(anchor);\n });\n};\n","// eslint-disable-next-line @bigbinary/neeto/file-name-and-export-name-standards\nimport { buildHeaderLinks } from \"./utils/headers\";\n\nconst applyDecorations = () => {\n const editorContent = document.querySelector(\".neeto-editor-content\");\n\n if (editorContent) buildHeaderLinks(editorContent);\n};\n\n(() => {\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", applyDecorations);\n } else applyDecorations();\n\n window.neetoEditor = window.neetoEditor ?? {};\n window.neetoEditor.applyHeaderDecorations = applyDecorations;\n})();\n"],"names":["buildLinkSVG","svgNS","svgWrapper","document","createElement","classList","add","svg","createElementNS","setAttribute","path","appendChild","convertTextToId","text","trim","toLowerCase","replace","buildHeaderLinks","editorContentNode","headerTags","querySelectorAll","usedIds","Map","forEach","heading","headingId","textContent","has","count","get","set","concat","anchor","cloneNode","replaceWith","applyDecorations","editorContent","querySelector","_window$neetoEditor","readyState","addEventListener","window","neetoEditor","applyHeaderDecorations"],"mappings":";;AAAA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,GAAS;EACzB,IAAMC,KAAK,GAAG,4BAA4B,CAAA;AAE1C,EAAA,IAAMC,UAAU,GAAGC,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC,CAAA;AACjDF,EAAAA,UAAU,CAACG,SAAS,CAACC,GAAG,CAAC,0BAA0B,CAAC,CAAA;EACpD,IAAMC,GAAG,GAAGJ,QAAQ,CAACK,eAAe,CAACP,KAAK,EAAE,KAAK,CAAC,CAAA;AAClDM,EAAAA,GAAG,CAACE,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;AACvCF,EAAAA,GAAG,CAACE,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AAChCF,EAAAA,GAAG,CAACE,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AACxCF,EAAAA,GAAG,CAACE,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;EAE/B,IAAMC,IAAI,GAAGP,QAAQ,CAACK,eAAe,CAACP,KAAK,EAAE,MAAM,CAAC,CAAA;AACpDS,EAAAA,IAAI,CAACD,YAAY,CACf,GAAG,EACH,+UACF,CAAC,CAAA;AAEDF,EAAAA,GAAG,CAACI,WAAW,CAACD,IAAI,CAAC,CAAA;AACrBR,EAAAA,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