@diplodoc/folding-headings-extension 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # Diplodoc folding headings
2
-
3
1
  [![NPM version](https://img.shields.io/npm/v/@diplodoc/folding-headings-extension.svg?style=flat)](https://www.npmjs.org/package/@diplodoc/folding-headings-extension)
2
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=diplodoc-platform_folding-headings-extension&metric=alert_status)](https://sonarcloud.io/summary/overall?id=diplodoc-platform_folding-headings-extension)
3
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=diplodoc-platform_folding-headings-extension&metric=coverage)](https://sonarcloud.io/summary/overall?id=diplodoc-platform_folding-headings-extension)
4
+ [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=diplodoc-platform_folding-headings-extension&metric=sqale_rating)](https://sonarcloud.io/summary/overall?id=diplodoc-platform_folding-headings-extension)
5
+ [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=diplodoc-platform_folding-headings-extension&metric=reliability_rating)](https://sonarcloud.io/summary/overall?id=diplodoc-platform_folding-headings-extension)
6
+ [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=diplodoc-platform_folding-headings-extension&metric=security_rating)](https://sonarcloud.io/summary/overall?id=diplodoc-platform_folding-headings-extension)
7
+
8
+ # Diplodoc folding headings
4
9
 
5
10
  This is an extension of the Diplodoc platform, which allows adding folding headings in the documentation.
6
11
 
@@ -18,12 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/plugin/index.ts
21
- var plugin_exports = {};
22
- __export(plugin_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  TokenType: () => TokenType,
24
24
  transform: () => transform
25
25
  });
26
- module.exports = __toCommonJS(plugin_exports);
26
+ module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/common/const.ts
29
29
  var DATA_KEY = "heading-section";
@@ -210,7 +210,9 @@ var sectionsCoreRule = (state) => {
210
210
  return t;
211
211
  }
212
212
  function closeSections(section) {
213
- while (last(sections) && section.header <= last(sections).header && section.nesting <= last(sections).nesting) {
213
+ while (last(sections) && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
214
+ section.header <= last(sections).header && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
215
+ section.nesting <= last(sections).nesting) {
214
216
  sections.pop();
215
217
  tokens.push(closeContent());
216
218
  tokens.push(closeSection());
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/plugin/index.ts", "../../src/common/const.ts", "../../src/plugin/const.ts", "../../src/plugin/headingBlockRule.ts", "../../src/plugin/utils.ts", "../../src/plugin/sectionsCoreRule.ts", "../../src/plugin/plugin.ts", "../../src/plugin/transform.ts"],
4
- "sourcesContent": ["export type {TransformOptions} from './transform';\nexport {transform} from './transform';\nexport {TokenType} from './const';\n", "export const DATA_KEY = 'heading-section';\n\nexport const SectionAttr = {\n DataId: 'data-diplodoc-id',\n DataKey: 'data-diplodoc-key',\n} as const;\n\nexport const SectionCN = {\n Section: 'heading-section',\n Content: 'heading-section-content',\n};\n", "export {SectionCN, DATA_KEY, SectionAttr} from '../common/const';\n\nexport const ENV_FLAG_NAME = 'has-folding-headings';\n\nexport const TokenType = {\n Heading: 'heading',\n HeadingOpen: 'heading_open',\n HeadingClose: 'heading_close',\n Section: 'heading_section',\n SectionOpen: 'heading_section_open',\n SectionClose: 'heading_section_close',\n Content: 'heading_section_content',\n ContentOpen: 'heading_section_content_open',\n ContentClose: 'heading_section_content_close',\n} as const;\n", "import type ParserBlock from 'markdown-it/lib/parser_block';\n\nimport {TokenType} from './const';\n\n// copied from https://github.com/markdown-it/markdown-it/blob/14.1.0/lib/rules_block/heading.mjs\n// modified: support syntax ###+ for folding headings\nexport const headingBlockRule: ParserBlock.RuleBlock = (state, startLine, _endLine, silent) => {\n const {isSpace} = state.md.utils;\n\n let pos = state.bMarks[startLine] + state.tShift[startLine];\n let max = state.eMarks[startLine];\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) {\n return false;\n }\n\n let ch = state.src.charCodeAt(pos);\n\n if (ch !== 0x23 /* # */ || pos >= max) {\n return false;\n }\n\n // count heading level\n let level = 1;\n ch = state.src.charCodeAt(++pos);\n while (ch === 0x23 /* # */ && pos < max && level <= 6) {\n level++;\n ch = state.src.charCodeAt(++pos);\n }\n\n let folding = false;\n if (ch === 0x2b /* + */) {\n folding = true;\n ch = state.src.charCodeAt(++pos);\n }\n\n if (level > 6 || (pos < max && !isSpace(ch))) {\n return false;\n }\n\n if (silent) {\n return true;\n }\n\n // Let's cut tails like ' ### ' from the end of string\n\n max = state.skipSpacesBack(max, pos);\n const tmp = state.skipCharsBack(max, 0x23, pos); // #\n if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {\n max = tmp;\n }\n\n state.line = startLine + 1;\n\n let token = state.push(TokenType.HeadingOpen, 'h' + String(level), 1);\n token.markup = '########'.slice(0, level) + (folding ? '+' : '');\n token.map = [startLine, state.line];\n if (folding) {\n token.meta ||= {};\n token.meta.folding = true;\n }\n\n token = state.push('inline', '', 0);\n token.content = state.src.slice(pos, max).trim();\n token.map = [startLine, state.line];\n token.children = [];\n\n token = state.push(TokenType.HeadingClose, 'h' + String(level), -1);\n token.markup = '########'.slice(0, level) + (folding ? '+' : '');\n if (folding) {\n token.meta ||= {};\n token.meta.folding = true;\n }\n\n return true;\n};\n", "import {DATA_KEY} from './const';\n\nexport function generateID() {\n return DATA_KEY + '-' + Math.random().toString(36).substr(2, 8);\n}\n\nexport function headingLevel(header: string) {\n return parseInt(header.charAt(1), 10);\n}\n\nexport function last<T>(arr: T[]): T | undefined {\n return arr[arr.length - 1];\n}\n\nexport function hidden<B extends Record<string | symbol, unknown>, F extends string | symbol, V>(\n box: B,\n field: F,\n value: V,\n) {\n if (!(field in box)) {\n Object.defineProperty(box, field, {\n enumerable: false,\n value: value,\n });\n }\n\n return box as B & {[P in F]: V};\n}\n\nexport type Runtime = {\n script: string;\n style: string;\n};\n\ndeclare const __dirname: string;\nexport function copyRuntime(\n {runtime, output}: {runtime: Runtime; output: string},\n cache: Set<string>,\n) {\n const PATH_TO_RUNTIME = '../runtime';\n const {join, resolve} = dynrequire('node:path');\n const runtimeFiles = {\n 'index.js': runtime.script,\n 'index.css': runtime.style,\n };\n for (const [originFile, outputFile] of Object.entries(runtimeFiles)) {\n const file = join(PATH_TO_RUNTIME, originFile);\n if (!cache.has(file)) {\n cache.add(file);\n copy(resolve(__dirname, file), join(output, outputFile));\n }\n }\n}\n\nexport function copy(from: string, to: string) {\n const {mkdirSync, copyFileSync} = dynrequire('node:fs');\n const {dirname} = dynrequire('node:path');\n\n mkdirSync(dirname(to), {recursive: true});\n copyFileSync(from, to);\n}\n\n/*\n * Runtime require hidden for builders.\n * Used for nodejs api\n */\nexport function dynrequire(module: string) {\n return eval(`require('${module}')`);\n}\n", "import type Core from 'markdown-it/lib/parser_core';\n\nimport {DATA_KEY, ENV_FLAG_NAME, SectionAttr, SectionCN, TokenType} from './const';\nimport {generateID, headingLevel, last} from './utils';\n\ntype Section = {header: number; nesting: number};\n\nexport const sectionsCoreRule: Core.RuleCore = (state) => {\n const Token = state.Token;\n const tokens: typeof state.tokens = []; // output\n const sections: Section[] = [];\n let nestedLevel = 0;\n\n for (const token of state.tokens) {\n // record level of nesting\n if (token.type.search(TokenType.Heading) !== 0) {\n nestedLevel += token.nesting;\n }\n if (last(sections) && nestedLevel < last(sections)!.nesting) {\n closeSectionsToCurrentNesting(nestedLevel);\n }\n\n const hasFolding = token.markup.endsWith('#+');\n\n // add sections before headers\n if (token.type === TokenType.HeadingOpen) {\n const section: Section = {\n header: headingLevel(token.tag),\n nesting: nestedLevel,\n };\n closeSections(section);\n if (hasFolding) {\n tokens.push(openSection());\n sections.push(section);\n }\n }\n\n tokens.push(token);\n\n if (token.type === TokenType.HeadingClose && hasFolding) {\n tokens.push(openContent());\n }\n }\n\n // end for every token\n closeAllSections();\n\n if (state.tokens.length !== tokens.length) {\n state.env ??= {};\n state.env[ENV_FLAG_NAME] = true;\n }\n\n state.tokens = tokens;\n\n function openSection() {\n const t = new Token(TokenType.SectionOpen, 'section', 1);\n t.attrPush(['class', SectionCN.Section]);\n t.attrPush([SectionAttr.DataKey, DATA_KEY]);\n t.attrPush([SectionAttr.DataId, generateID()]);\n t.block = true;\n return t;\n }\n\n function closeSection() {\n const t = new Token(TokenType.SectionClose, 'section', -1);\n t.block = true;\n return t;\n }\n\n function openContent() {\n const t = new Token(TokenType.ContentOpen, 'div', 1);\n t.attrPush(['class', SectionCN.Content]);\n t.block = true;\n return t;\n }\n\n function closeContent() {\n const t = new Token(TokenType.ContentClose, 'div', -1);\n t.block = true;\n return t;\n }\n\n function closeSections(section: Section) {\n while (\n last(sections) &&\n section.header <= last(sections)!.header &&\n section.nesting <= last(sections)!.nesting\n ) {\n sections.pop();\n tokens.push(closeContent());\n tokens.push(closeSection());\n }\n }\n\n function closeSectionsToCurrentNesting(nesting: number) {\n while (last(sections) && nesting < last(sections)!.nesting) {\n sections.pop();\n tokens.push(closeContent());\n tokens.push(closeSection());\n }\n }\n\n function closeAllSections() {\n while (sections.pop()) {\n tokens.push(closeContent());\n tokens.push(closeSection());\n }\n }\n};\n", "import type {PluginSimple} from 'markdown-it';\n\nimport {headingBlockRule} from './headingBlockRule';\nimport {sectionsCoreRule} from './sectionsCoreRule';\n\nexport const foldingHeadingPlugin: PluginSimple = (md) => {\n md.block.ruler.at('heading', headingBlockRule, {alt: ['paragraph', 'reference', 'blockquote']});\n md.core.ruler.push('heading_sections', sectionsCoreRule);\n};\n", "import type MarkdownIt from 'markdown-it';\nimport {PluginWithOptions} from 'markdown-it';\n\nimport {ENV_FLAG_NAME} from './const';\nimport {foldingHeadingPlugin} from './plugin';\nimport {type Runtime, copyRuntime, dynrequire, hidden} from './utils';\n\nconst registerTransform = (\n md: MarkdownIt,\n {\n runtime,\n bundle,\n output,\n }: Pick<NormalizedPluginOptions, 'bundle' | 'runtime'> & {\n output: string;\n },\n) => {\n md.use(foldingHeadingPlugin);\n md.core.ruler.push('heading_sections_after', ({env}) => {\n hidden(env, 'bundled', new Set<string>());\n\n if (env?.[ENV_FLAG_NAME]) {\n env.meta = env.meta || {};\n env.meta.script = env.meta.script || [];\n env.meta.script.push(runtime.script);\n env.meta.style = env.meta.style || [];\n env.meta.style.push(runtime.style);\n\n if (bundle) {\n copyRuntime({runtime, output}, env.bundled);\n }\n }\n });\n};\n\ntype NormalizedPluginOptions = Omit<TransformOptions, 'runtime'> & {\n runtime: Runtime;\n};\n\nexport type TransformOptions = {\n runtime?:\n | string\n | {\n script: string;\n style: string;\n };\n bundle?: boolean;\n};\n\ntype InputOptions = {\n destRoot: string;\n};\n\nexport function transform(options: Partial<TransformOptions> = {}) {\n const {bundle = true} = options;\n\n if (bundle && typeof options.runtime === 'string') {\n throw new TypeError('Option `runtime` should be record when `bundle` is enabled.');\n }\n\n const runtime: Runtime =\n typeof options.runtime === 'string'\n ? {script: options.runtime, style: options.runtime}\n : options.runtime || {\n script: '_assets/folding-headings-extension.js',\n style: '_assets/folding-headings-extension.css',\n };\n\n const plugin: PluginWithOptions<{output?: string}> = function (\n md: MarkdownIt,\n {output = '.'} = {},\n ) {\n registerTransform(md, {\n runtime,\n bundle,\n output,\n });\n };\n\n Object.assign(plugin, {\n collect(input: string, {destRoot = '.'}: InputOptions) {\n const MdIt = dynrequire('markdown-it');\n const md = new MdIt().use((md: MarkdownIt) => {\n registerTransform(md, {\n runtime,\n bundle,\n output: destRoot,\n });\n });\n\n md.parse(input, {});\n },\n });\n\n return plugin;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAA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AAEA,QAAM,UACF,OAAO,QAAQ,YAAY,WACrB,EAAC,QAAQ,QAAQ,SAAS,OAAO,QAAQ,QAAO,IAChD,QAAQ,WAAW;AAAA,IACf,QAAQ;AAAA,IACR,OAAO;AAAA,EACX;AAEV,QAAM,SAA+C,SACjD,IACA,EAAC,SAAS,IAAG,IAAI,CAAC,GACpB;AACE,sBAAkB,IAAI;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,SAAO,OAAO,QAAQ;AAAA,IAClB,QAAQ,OAAe,EAAC,WAAW,IAAG,GAAiB;AACnD,YAAM,OAAO,WAAW,aAAa;AACrC,YAAM,KAAK,IAAI,KAAK,EAAE,IAAI,CAACA,QAAmB;AAC1C,0BAAkBA,KAAI;AAAA,UAClB;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,QACZ,CAAC;AAAA,MACL,CAAC;AAED,SAAG,MAAM,OAAO,CAAC,CAAC;AAAA,IACtB;AAAA,EACJ,CAAC;AAED,SAAO;AACX;",
4
+ "sourcesContent": ["export type {TransformOptions} from './transform';\nexport {transform} from './transform';\nexport {TokenType} from './const';\n", "export const DATA_KEY = 'heading-section';\n\nexport const SectionAttr = {\n DataId: 'data-diplodoc-id',\n DataKey: 'data-diplodoc-key',\n} as const;\n\nexport const SectionCN = {\n Section: 'heading-section',\n Content: 'heading-section-content',\n};\n", "export {SectionCN, DATA_KEY, SectionAttr} from '../common/const';\n\nexport const ENV_FLAG_NAME = 'has-folding-headings';\n\nexport const TokenType = {\n Heading: 'heading',\n HeadingOpen: 'heading_open',\n HeadingClose: 'heading_close',\n Section: 'heading_section',\n SectionOpen: 'heading_section_open',\n SectionClose: 'heading_section_close',\n Content: 'heading_section_content',\n ContentOpen: 'heading_section_content_open',\n ContentClose: 'heading_section_content_close',\n} as const;\n", "import type ParserBlock from 'markdown-it/lib/parser_block';\n\nimport {TokenType} from './const';\n\n// copied from https://github.com/markdown-it/markdown-it/blob/14.1.0/lib/rules_block/heading.mjs\n// modified: support syntax ###+ for folding headings\nexport const headingBlockRule: ParserBlock.RuleBlock = (state, startLine, _endLine, silent) => {\n const {isSpace} = state.md.utils;\n\n let pos = state.bMarks[startLine] + state.tShift[startLine];\n let max = state.eMarks[startLine];\n\n // if it's indented more than 3 spaces, it should be a code block\n if (state.sCount[startLine] - state.blkIndent >= 4) {\n return false;\n }\n\n let ch = state.src.charCodeAt(pos);\n\n if (ch !== 0x23 /* # */ || pos >= max) {\n return false;\n }\n\n // count heading level\n let level = 1;\n ch = state.src.charCodeAt(++pos);\n while (ch === 0x23 /* # */ && pos < max && level <= 6) {\n level++;\n ch = state.src.charCodeAt(++pos);\n }\n\n let folding = false;\n if (ch === 0x2b /* + */) {\n folding = true;\n ch = state.src.charCodeAt(++pos);\n }\n\n if (level > 6 || (pos < max && !isSpace(ch))) {\n return false;\n }\n\n if (silent) {\n return true;\n }\n\n // Let's cut tails like ' ### ' from the end of string\n\n max = state.skipSpacesBack(max, pos);\n const tmp = state.skipCharsBack(max, 0x23, pos); // #\n if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {\n max = tmp;\n }\n\n state.line = startLine + 1;\n\n let token = state.push(TokenType.HeadingOpen, 'h' + String(level), 1);\n token.markup = '########'.slice(0, level) + (folding ? '+' : '');\n token.map = [startLine, state.line];\n if (folding) {\n token.meta ||= {};\n token.meta.folding = true;\n }\n\n token = state.push('inline', '', 0);\n token.content = state.src.slice(pos, max).trim();\n token.map = [startLine, state.line];\n token.children = [];\n\n token = state.push(TokenType.HeadingClose, 'h' + String(level), -1);\n token.markup = '########'.slice(0, level) + (folding ? '+' : '');\n if (folding) {\n token.meta ||= {};\n token.meta.folding = true;\n }\n\n return true;\n};\n", "import {DATA_KEY} from './const';\n\nexport function generateID() {\n return DATA_KEY + '-' + Math.random().toString(36).substr(2, 8);\n}\n\nexport function headingLevel(header: string) {\n return parseInt(header.charAt(1), 10);\n}\n\nexport function last<T>(arr: T[]): T | undefined {\n return arr[arr.length - 1];\n}\n\nexport function hidden<B extends Record<string | symbol, unknown>, F extends string | symbol, V>(\n box: B,\n field: F,\n value: V,\n) {\n if (!(field in box)) {\n Object.defineProperty(box, field, {\n enumerable: false,\n value: value,\n });\n }\n\n return box as B & Record<F, V>;\n}\n\nexport type Runtime = {\n script: string;\n style: string;\n};\n\ndeclare const __dirname: string;\nexport function copyRuntime(\n {runtime, output}: {runtime: Runtime; output: string},\n cache: Set<string>,\n) {\n const PATH_TO_RUNTIME = '../runtime';\n const {join, resolve} = dynrequire('node:path');\n const runtimeFiles = {\n 'index.js': runtime.script,\n 'index.css': runtime.style,\n };\n for (const [originFile, outputFile] of Object.entries(runtimeFiles)) {\n const file = join(PATH_TO_RUNTIME, originFile);\n if (!cache.has(file)) {\n cache.add(file);\n copy(resolve(__dirname, file), join(output, outputFile));\n }\n }\n}\n\nexport function copy(from: string, to: string) {\n const {mkdirSync, copyFileSync} = dynrequire('node:fs');\n const {dirname} = dynrequire('node:path');\n\n mkdirSync(dirname(to), {recursive: true});\n copyFileSync(from, to);\n}\n\n/*\n * Runtime require hidden for builders.\n * Used for nodejs api\n */\nexport function dynrequire(module: string) {\n // eslint-disable-next-line no-eval\n return eval(`require('${module}')`);\n}\n", "import type Core from 'markdown-it/lib/parser_core';\n\nimport {DATA_KEY, ENV_FLAG_NAME, SectionAttr, SectionCN, TokenType} from './const';\nimport {generateID, headingLevel, last} from './utils';\n\ntype Section = {header: number; nesting: number};\n\nexport const sectionsCoreRule: Core.RuleCore = (state) => {\n const Token = state.Token;\n const tokens: typeof state.tokens = []; // output\n const sections: Section[] = [];\n let nestedLevel = 0;\n\n for (const token of state.tokens) {\n // record level of nesting\n if (token.type.search(TokenType.Heading) !== 0) {\n nestedLevel += token.nesting;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (last(sections) && nestedLevel < last(sections)!.nesting) {\n closeSectionsToCurrentNesting(nestedLevel);\n }\n\n const hasFolding = token.markup.endsWith('#+');\n\n // add sections before headers\n if (token.type === TokenType.HeadingOpen) {\n const section: Section = {\n header: headingLevel(token.tag),\n nesting: nestedLevel,\n };\n closeSections(section);\n if (hasFolding) {\n tokens.push(openSection());\n sections.push(section);\n }\n }\n\n tokens.push(token);\n\n if (token.type === TokenType.HeadingClose && hasFolding) {\n tokens.push(openContent());\n }\n }\n\n // end for every token\n closeAllSections();\n\n if (state.tokens.length !== tokens.length) {\n state.env ??= {};\n state.env[ENV_FLAG_NAME] = true;\n }\n\n state.tokens = tokens;\n\n function openSection() {\n const t = new Token(TokenType.SectionOpen, 'section', 1);\n t.attrPush(['class', SectionCN.Section]);\n t.attrPush([SectionAttr.DataKey, DATA_KEY]);\n t.attrPush([SectionAttr.DataId, generateID()]);\n t.block = true;\n return t;\n }\n\n function closeSection() {\n const t = new Token(TokenType.SectionClose, 'section', -1);\n t.block = true;\n return t;\n }\n\n function openContent() {\n const t = new Token(TokenType.ContentOpen, 'div', 1);\n t.attrPush(['class', SectionCN.Content]);\n t.block = true;\n return t;\n }\n\n function closeContent() {\n const t = new Token(TokenType.ContentClose, 'div', -1);\n t.block = true;\n return t;\n }\n\n function closeSections(section: Section) {\n while (\n last(sections) &&\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n section.header <= last(sections)!.header &&\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n section.nesting <= last(sections)!.nesting\n ) {\n sections.pop();\n tokens.push(closeContent());\n tokens.push(closeSection());\n }\n }\n\n function closeSectionsToCurrentNesting(nesting: number) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n while (last(sections) && nesting < last(sections)!.nesting) {\n sections.pop();\n tokens.push(closeContent());\n tokens.push(closeSection());\n }\n }\n\n function closeAllSections() {\n while (sections.pop()) {\n tokens.push(closeContent());\n tokens.push(closeSection());\n }\n }\n};\n", "import type {PluginSimple} from 'markdown-it';\n\nimport {headingBlockRule} from './headingBlockRule';\nimport {sectionsCoreRule} from './sectionsCoreRule';\n\nexport const foldingHeadingPlugin: PluginSimple = (md) => {\n md.block.ruler.at('heading', headingBlockRule, {alt: ['paragraph', 'reference', 'blockquote']});\n md.core.ruler.push('heading_sections', sectionsCoreRule);\n};\n", "import type MarkdownIt from 'markdown-it';\nimport type {PluginWithOptions} from 'markdown-it';\n\nimport {ENV_FLAG_NAME} from './const';\nimport {foldingHeadingPlugin} from './plugin';\nimport {type Runtime, copyRuntime, dynrequire, hidden} from './utils';\n\nconst registerTransform = (\n md: MarkdownIt,\n {\n runtime,\n bundle,\n output,\n }: Pick<NormalizedPluginOptions, 'bundle' | 'runtime'> & {\n output: string;\n },\n) => {\n md.use(foldingHeadingPlugin);\n md.core.ruler.push('heading_sections_after', ({env}) => {\n hidden(env, 'bundled', new Set<string>());\n\n if (env?.[ENV_FLAG_NAME]) {\n env.meta = env.meta || {};\n env.meta.script = env.meta.script || [];\n env.meta.script.push(runtime.script);\n env.meta.style = env.meta.style || [];\n env.meta.style.push(runtime.style);\n\n if (bundle) {\n copyRuntime({runtime, output}, env.bundled);\n }\n }\n });\n};\n\ntype NormalizedPluginOptions = Omit<TransformOptions, 'runtime'> & {\n runtime: Runtime;\n};\n\nexport type TransformOptions = {\n runtime?:\n | string\n | {\n script: string;\n style: string;\n };\n bundle?: boolean;\n};\n\ntype InputOptions = {\n destRoot: string;\n};\n\nexport function transform(options: Partial<TransformOptions> = {}) {\n const {bundle = true} = options;\n\n if (bundle && typeof options.runtime === 'string') {\n throw new TypeError('Option `runtime` should be record when `bundle` is enabled.');\n }\n\n const runtime: Runtime =\n typeof options.runtime === 'string'\n ? {script: options.runtime, style: options.runtime}\n : options.runtime || {\n script: '_assets/folding-headings-extension.js',\n style: '_assets/folding-headings-extension.css',\n };\n\n const plugin: PluginWithOptions<{output?: string}> = function (\n md: MarkdownIt,\n {output = '.'} = {},\n ) {\n registerTransform(md, {\n runtime,\n bundle,\n output,\n });\n };\n\n Object.assign(plugin, {\n collect(input: string, {destRoot = '.'}: InputOptions) {\n const MdIt = dynrequire('markdown-it');\n const md = new MdIt().use((md: MarkdownIt) => {\n registerTransform(md, {\n runtime,\n bundle,\n output: destRoot,\n });\n });\n\n md.parse(input, {});\n },\n });\n\n return plugin;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAW;AAEjB,IAAM,cAAc;AAAA,EACvB,QAAQ;AAAA,EACR,SAAS;AACb;AAEO,IAAM,YAAY;AAAA,EACrB,SAAS;AAAA,EACT,SAAS;AACb;;;ACRO,IAAM,gBAAgB;AAEtB,IAAM,YAAY;AAAA,EACrB,SAAS;AAAA,EACT,aAAa;AAAA,EACb,cAAc;AAAA,EACd,SAAS;AAAA,EACT,aAAa;AAAA,EACb,cAAc;AAAA,EACd,SAAS;AAAA,EACT,aAAa;AAAA,EACb,cAAc;AAClB;;;ACRO,IAAM,mBAA0C,CAAC,OAAO,WAAW,UAAU,WAAW;AAC3F,QAAM,EAAC,QAAO,IAAI,MAAM,GAAG;AAE3B,MAAI,MAAM,MAAM,OAAO,SAAS,IAAI,MAAM,OAAO,SAAS;AAC1D,MAAI,MAAM,MAAM,OAAO,SAAS;AAGhC,MAAI,MAAM,OAAO,SAAS,IAAI,MAAM,aAAa,GAAG;AAChD,WAAO;AAAA,EACX;AAEA,MAAI,KAAK,MAAM,IAAI,WAAW,GAAG;AAEjC,MAAI,OAAO,MAAgB,OAAO,KAAK;AACnC,WAAO;AAAA,EACX;AAGA,MAAI,QAAQ;AACZ,OAAK,MAAM,IAAI,WAAW,EAAE,GAAG;AAC/B,SAAO,OAAO,MAAgB,MAAM,OAAO,SAAS,GAAG;AACnD;AACA,SAAK,MAAM,IAAI,WAAW,EAAE,GAAG;AAAA,EACnC;AAEA,MAAI,UAAU;AACd,MAAI,OAAO,IAAc;AACrB,cAAU;AACV,SAAK,MAAM,IAAI,WAAW,EAAE,GAAG;AAAA,EACnC;AAEA,MAAI,QAAQ,KAAM,MAAM,OAAO,CAAC,QAAQ,E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AI,OAAO;AAAA,MAC9C;AAAA,IACJ;AAAA,EACJ,CAAC;AACL;AAoBO,SAAS,UAAU,UAAqC,CAAC,GAAG;AAC/D,QAAM,EAAC,SAAS,KAAI,IAAI;AAExB,MAAI,UAAU,OAAO,QAAQ,YAAY,UAAU;AAC/C,UAAM,IAAI,UAAU,6DAA6D;AAAA,EACrF;AAEA,QAAM,UACF,OAAO,QAAQ,YAAY,WACrB,EAAC,QAAQ,QAAQ,SAAS,OAAO,QAAQ,QAAO,IAChD,QAAQ,WAAW;AAAA,IACf,QAAQ;AAAA,IACR,OAAO;AAAA,EACX;AAEV,QAAM,SAA+C,SACjD,IACA,EAAC,SAAS,IAAG,IAAI,CAAC,GACpB;AACE,sBAAkB,IAAI;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,SAAO,OAAO,QAAQ;AAAA,IAClB,QAAQ,OAAe,EAAC,WAAW,IAAG,GAAiB;AACnD,YAAM,OAAO,WAAW,aAAa;AACrC,YAAM,KAAK,IAAI,KAAK,EAAE,IAAI,CAACA,QAAmB;AAC1C,0BAAkBA,KAAI;AAAA,UAClB;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,QACZ,CAAC;AAAA,MACL,CAAC;AAED,SAAG,MAAM,OAAO,CAAC,CAAC;AAAA,IACtB;AAAA,EACJ,CAAC;AAED,SAAO;AACX;",
6
6
  "names": ["md"]
7
7
  }
@@ -1,2 +1,2 @@
1
- .yfm h1[data-folded],.yfm h2[data-folded],.yfm h3[data-folded],.yfm h4[data-folded],.yfm h5[data-folded],.yfm h6[data-folded]{position:relative;padding-left:28px}.yfm h1[data-folded]:before,.yfm h2[data-folded]:before,.yfm h3[data-folded]:before,.yfm h4[data-folded]:before,.yfm h5[data-folded]:before,.yfm h6[data-folded]:before{position:absolute;z-index:1;top:50%;left:0;content:"";cursor:pointer;background-color:currentColor;mask-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06" clip-rule="evenodd"/></svg>');mask-repeat:no-repeat;mask-position:center;transition:transform .3s ease;transform:translateY(-50%) rotate(-90deg)}.yfm h1[data-folded]:before{width:28px;height:28px;mask-size:20px}.yfm h2[data-folded]:before,.yfm h3[data-folded]:before{left:2px;width:24px;height:24px;mask-size:20px}.yfm h4[data-folded]:before{left:6px;width:20px;height:20px;mask-size:16px}.yfm h5[data-folded]:before{left:8px;width:20px;height:20px;mask-size:14px}.yfm h6[data-folded]:before{left:8px;width:20px;height:20px;mask-size:12px}.yfm h1[data-folded=false]:before,.yfm h2[data-folded=false]:before,.yfm h3[data-folded=false]:before,.yfm h4[data-folded=false]:before,.yfm h5[data-folded=false]:before,.yfm h6[data-folded=false]:before{transform:translateY(-50%)}.heading-section-content{display:none;padding-left:28px;transition:height .3s ease-in-out}.heading-section-content>.heading-section{margin-left:-28px}.heading-section>h1,.heading-section>h2,.heading-section>h3,.heading-section>h4,.heading-section>h5,.heading-section>h6{cursor:pointer;position:relative;padding-left:28px}.heading-section>h1:before,.heading-section>h2:before,.heading-section>h3:before,.heading-section>h4:before,.heading-section>h5:before,.heading-section>h6:before{position:absolute;z-index:1;top:50%;left:0;content:"";cursor:pointer;background-color:currentColor;mask-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06" clip-rule="evenodd"/></svg>');mask-repeat:no-repeat;mask-position:center;transition:transform .3s ease;transform:translateY(-50%) rotate(-90deg)}.heading-section>h1 .yfm-anchor,.heading-section>h2 .yfm-anchor,.heading-section>h3 .yfm-anchor,.heading-section>h4 .yfm-anchor,.heading-section>h5 .yfm-anchor,.heading-section>h6 .yfm-anchor{margin-left:-52px}.heading-section>h1:before{width:28px;height:28px;mask-size:20px}.heading-section>h2:before,.heading-section>h3:before{left:2px;width:24px;height:24px;mask-size:20px}.heading-section>h4:before{left:6px;width:20px;height:20px;mask-size:16px}.heading-section>h5:before{left:8px;width:20px;height:20px;mask-size:14px}.heading-section>h6:before{left:8px;width:20px;height:20px;mask-size:12px}.heading-section.open>.heading-section-content{display:revert}.heading-section.open>h1:before,.heading-section.open>h2:before,.heading-section.open>h3:before,.heading-section.open>h4:before,.heading-section.open>h5:before,.heading-section.open>h6:before{transform:translateY(-50%)}
1
+ .yfm h1[data-folded],.yfm h2[data-folded],.yfm h3[data-folded],.yfm h4[data-folded],.yfm h5[data-folded],.yfm h6[data-folded]{position:relative;padding-left:28px}.yfm h1[data-folded]:before,.yfm h2[data-folded]:before,.yfm h3[data-folded]:before,.yfm h4[data-folded]:before,.yfm h5[data-folded]:before,.yfm h6[data-folded]:before{position:absolute;z-index:1;top:50%;left:0;content:"";cursor:pointer;background-color:currentColor;mask-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06" clip-rule="evenodd"/></svg>');mask-repeat:no-repeat;mask-position:center;transition:transform .3s ease;transform:translateY(-50%) rotate(-90deg)}.yfm h1[data-folded]:before{width:28px;height:28px;mask-size:20px}.yfm h2[data-folded]:before,.yfm h3[data-folded]:before{left:2px;width:24px;height:24px;mask-size:20px}.yfm h4[data-folded]:before{left:6px;width:20px;height:20px;mask-size:16px}.yfm h5[data-folded]:before{left:8px;width:20px;height:20px;mask-size:14px}.yfm h6[data-folded]:before{left:8px;width:20px;height:20px;mask-size:12px}.yfm h1[data-folded=false]:before,.yfm h2[data-folded=false]:before,.yfm h3[data-folded=false]:before,.yfm h4[data-folded=false]:before,.yfm h5[data-folded=false]:before,.yfm h6[data-folded=false]:before{transform:translateY(-50%)}.heading-section-content{display:none;padding-left:28px;transition:height .3s ease-in-out}.heading-section-content>.heading-section{margin-left:-28px}.heading-section>h1,.heading-section>h2,.heading-section>h3,.heading-section>h4,.heading-section>h5,.heading-section>h6{cursor:pointer;position:relative;padding-left:28px}.heading-section>h1:before,.heading-section>h2:before,.heading-section>h3:before,.heading-section>h4:before,.heading-section>h5:before,.heading-section>h6:before{position:absolute;z-index:1;top:50%;left:0;content:"";cursor:pointer;background-color:currentColor;mask-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06" clip-rule="evenodd"/></svg>');mask-repeat:no-repeat;mask-position:center;transition:transform .3s ease;transform:translateY(-50%) rotate(-90deg)}.heading-section>h1 .yfm-anchor,.heading-section>h1 .yfm-clipboard-anchor,.heading-section>h2 .yfm-anchor,.heading-section>h2 .yfm-clipboard-anchor,.heading-section>h3 .yfm-anchor,.heading-section>h3 .yfm-clipboard-anchor,.heading-section>h4 .yfm-anchor,.heading-section>h4 .yfm-clipboard-anchor,.heading-section>h5 .yfm-anchor,.heading-section>h5 .yfm-clipboard-anchor,.heading-section>h6 .yfm-anchor,.heading-section>h6 .yfm-clipboard-anchor{margin-left:-52px}.yfm table .heading-section>h1 .yfm-anchor,.yfm table .heading-section>h1 .yfm-clipboard-anchor,.yfm table .heading-section>h2 .yfm-anchor,.yfm table .heading-section>h2 .yfm-clipboard-anchor,.yfm table .heading-section>h3 .yfm-anchor,.yfm table .heading-section>h3 .yfm-clipboard-anchor,.yfm table .heading-section>h4 .yfm-anchor,.yfm table .heading-section>h4 .yfm-clipboard-anchor,.yfm table .heading-section>h5 .yfm-anchor,.yfm table .heading-section>h5 .yfm-clipboard-anchor,.yfm table .heading-section>h6 .yfm-anchor,.yfm table .heading-section>h6 .yfm-clipboard-anchor{margin-left:-2.5em}.heading-section>h1:before{width:28px;height:28px;mask-size:20px}.heading-section>h2:before,.heading-section>h3:before{left:2px;width:24px;height:24px;mask-size:20px}.heading-section>h4:before{left:6px;width:20px;height:20px;mask-size:16px}.heading-section>h5:before{left:8px;width:20px;height:20px;mask-size:14px}.heading-section>h6:before{left:8px;width:20px;height:20px;mask-size:12px}.heading-section.open>.heading-section-content{display:revert}.heading-section.open>h1:before,.heading-section.open>h2:before,.heading-section.open>h3:before,.heading-section.open>h4:before,.heading-section.open>h5:before,.heading-section.open>h6:before{transform:translateY(-50%)}
2
2
  /*# sourceMappingURL=index.css.map */
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/runtime/styles/_editor.scss", "../../src/runtime/styles/_mixins.scss", "../../src/runtime/styles/index.scss"],
4
- "sourcesContent": ["// this styles for folding headings in markdown editor\n\n@use './mixins' as m;\n\n.yfm {\n h1[data-folded],\n h2[data-folded],\n h3[data-folded],\n h4[data-folded],\n h5[data-folded],\n h6[data-folded] {\n @include m.chevron();\n }\n\n h1[data-folded] {\n @include m.chevron_size_xl();\n }\n\n h2[data-folded],\n h3[data-folded] {\n @include m.chevron_size_l();\n }\n\n h4[data-folded] {\n @include m.chevron_size_m();\n }\n\n h5[data-folded] {\n @include m.chevron_size_s();\n }\n\n h6[data-folded] {\n @include m.chevron_size_xs();\n }\n\n h1[data-folded=false],\n h2[data-folded=false],\n h3[data-folded=false],\n h4[data-folded=false],\n h5[data-folded=false],\n h6[data-folded=false] {\n @include m.chevron_open();\n }\n}\n", "$chevronIcon: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\" viewBox=\"0 0 16 16\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06\" clip-rule=\"evenodd\"/></svg>');\n\n@mixin chevron() {\n position: relative;\n\n padding-left: 28px;\n\n &::before {\n position: absolute;\n z-index: 1;\n top: 50%;\n left: 0;\n\n content: '';\n cursor: pointer;\n\n background-color: currentColor;\n mask-image: $chevronIcon;\n mask-repeat: no-repeat;\n mask-position: center;\n\n transition: transform 0.3s ease;\n transform: translateY(-50%) rotate(-90deg);\n }\n}\n\n@mixin chevron_size_xs() {\n &::before {\n left: 8px;\n\n width: 20px;\n height: 20px;\n\n mask-size: 12px;\n }\n}\n\n@mixin chevron_size_s() {\n &::before {\n left: 8px;\n\n width: 20px;\n height: 20px;\n\n mask-size: 14px;\n }\n}\n\n@mixin chevron_size_m() {\n &::before {\n left: 6px;\n\n width: 20px;\n height: 20px;\n\n mask-size: 16px;\n }\n}\n\n@mixin chevron_size_l() {\n &::before {\n left: 2px;\n\n width: 24px;\n height: 24px;\n\n mask-size: 20px;\n }\n}\n\n@mixin chevron_size_xl() {\n &::before {\n width: 28px;\n height: 28px;\n\n mask-size: 20px;\n }\n}\n\n@mixin chevron_open() {\n &::before {\n transform: translateY(-50%);\n }\n}\n", "@use './mixins' as m;\n@use './editor';\n\n$paddingLeft: 28px;\n$yfmAnchorWidth: 24px;\n\n.heading-section {\n $class: &;\n\n &-content {\n display: none;\n padding-left: $paddingLeft;\n transition: height 0.3s ease-in-out;\n\n & > #{$class} {\n margin-left: -#{$paddingLeft};\n }\n }\n\n > h1,\n > h2,\n > h3,\n > h4,\n > h5,\n > h6 {\n cursor: pointer;\n\n @include m.chevron();\n\n .yfm-anchor {\n margin-left: -#{$yfmAnchorWidth + $paddingLeft}; // width of yfm-anchor (24px) + padding of heading (28px)\n }\n }\n\n > h1 {\n @include m.chevron_size_xl();\n }\n\n > h2,\n > h3 {\n @include m.chevron_size_l();\n }\n\n > h4 {\n @include m.chevron_size_m();\n }\n\n > h5 {\n @include m.chevron_size_s();\n }\n\n > h6 {\n @include m.chevron_size_xs();\n }\n\n &.open {\n > #{$class}-content {\n display: revert;\n }\n\n > h1,\n > h2,\n > h3,\n > h4,\n > h5,\n > h6 {\n @include m.chevron_open();\n }\n }\n}\n"],
5
- "mappings": "AAKI,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aCFA,SAAA,SAEA,aAAA,KAEA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QACI,SAAA,SACA,QAAA,EACA,IAAA,IACA,KAAA,EAEA,QAAA,GACA,OAAA,QAEA,iBAAA,aACA,WAjBM,6UAkBN,YAAA,UACA,cAAA,OAEA,WAAA,UAAA,IAAA,KACA,UAAA,WAAA,MAAA,OAAA,QAiDJ,CDlEA,ICkEA,EAAA,CAAA,YAAA,QACI,MAAA,KACA,OAAA,KAEA,UAAA,KAfJ,CDvDA,ICuDA,EAAA,CAAA,YAAA,QAAA,CDvDA,ICuDA,EAAA,CAAA,YAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,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CAAA,WAAA,CAfA,eAeA,CAAA,GAAA,CAAA,WAAA,CAfA,eAeA,CAAA,GAAA,CAAA,WAAA,CAfA,eAeA,CAAA,GAAA,CAAA,WAAA,CAfA,eAeA,CAAA,GAAA,CAAA,WACI,YAAA,MDyCR,CCzDI,eDyDJ,CAAA,EAAA,QACI,MAAA,KACA,OAAA,KAEA,UAAA,KAfJ,CC9CI,eD8CJ,CAAA,EAAA,QAAA,CC9CI,eD8CJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KAjBJ,CCnCI,eDmCJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KAjBJ,CCxBI,eDwBJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KAjBJ,CCbI,eDaJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KCuBA,CA1CA,eA0CA,CAAA,IAAA,CAAA,CA/CJ,wBAgDQ,QAAA,ODuBR,CClEI,eDkEJ,CCxBI,IDwBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCxBI,IDwBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCxBI,IDwBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCxBI,IDwBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCxBI,IDwBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCxBI,IDwBJ,CAAA,EAAA,QACI,UAAA,WAAA",
3
+ "sources": ["../../src/runtime/_editor.scss", "../../src/runtime/_mixins.scss", "../../src/runtime/index.scss"],
4
+ "sourcesContent": ["// this styles for folding headings in markdown editor\n\n@use './mixins' as m;\n\n.yfm {\n h1[data-folded],\n h2[data-folded],\n h3[data-folded],\n h4[data-folded],\n h5[data-folded],\n h6[data-folded] {\n @include m.chevron();\n }\n\n h1[data-folded] {\n @include m.chevron_size_xl();\n }\n\n h2[data-folded],\n h3[data-folded] {\n @include m.chevron_size_l();\n }\n\n h4[data-folded] {\n @include m.chevron_size_m();\n }\n\n h5[data-folded] {\n @include m.chevron_size_s();\n }\n\n h6[data-folded] {\n @include m.chevron_size_xs();\n }\n\n h1[data-folded='false'],\n h2[data-folded='false'],\n h3[data-folded='false'],\n h4[data-folded='false'],\n h5[data-folded='false'],\n h6[data-folded='false'] {\n @include m.chevron_open();\n }\n}\n", "$chevronIcon: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\" viewBox=\"0 0 16 16\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06\" clip-rule=\"evenodd\"/></svg>');\n\n@mixin chevron() {\n position: relative;\n\n padding-left: 28px;\n\n &::before {\n position: absolute;\n z-index: 1;\n top: 50%;\n left: 0;\n\n content: '';\n cursor: pointer;\n\n background-color: currentColor;\n mask-image: $chevronIcon;\n mask-repeat: no-repeat;\n mask-position: center;\n\n transition: transform 0.3s ease;\n transform: translateY(-50%) rotate(-90deg);\n }\n}\n\n@mixin chevron_size_xs() {\n &::before {\n left: 8px;\n\n width: 20px;\n height: 20px;\n\n mask-size: 12px;\n }\n}\n\n@mixin chevron_size_s() {\n &::before {\n left: 8px;\n\n width: 20px;\n height: 20px;\n\n mask-size: 14px;\n }\n}\n\n@mixin chevron_size_m() {\n &::before {\n left: 6px;\n\n width: 20px;\n height: 20px;\n\n mask-size: 16px;\n }\n}\n\n@mixin chevron_size_l() {\n &::before {\n left: 2px;\n\n width: 24px;\n height: 24px;\n\n mask-size: 20px;\n }\n}\n\n@mixin chevron_size_xl() {\n &::before {\n width: 28px;\n height: 28px;\n\n mask-size: 20px;\n }\n}\n\n@mixin chevron_open() {\n &::before {\n transform: translateY(-50%);\n }\n}\n", "@use './mixins' as m;\n@use './editor';\n\n$paddingLeft: 28px;\n$yfmAnchorWidth: 24px;\n\n.heading-section {\n $class: &;\n\n &-content {\n display: none;\n padding-left: $paddingLeft;\n transition: height 0.3s ease-in-out;\n\n & > #{$class} {\n margin-left: -#{$paddingLeft};\n }\n }\n\n > h1,\n > h2,\n > h3,\n > h4,\n > h5,\n > h6 {\n cursor: pointer;\n\n @include m.chevron();\n\n .yfm-anchor,\n .yfm-clipboard-anchor {\n margin-left: -#{$yfmAnchorWidth + $paddingLeft}; // width of yfm-anchor (24px) + padding of heading (28px)\n\n // overrides styles from transformer\n // https://github.com/diplodoc-platform/transform/blob/f2626e8658c06100dfb081e64ba1dbb06510c8dd/src/scss/_anchor.scss#L63\n .yfm table & {\n margin-left: -2.5em;\n }\n }\n }\n\n > h1 {\n @include m.chevron_size_xl();\n }\n\n > h2,\n > h3 {\n @include m.chevron_size_l();\n }\n\n > h4 {\n @include m.chevron_size_m();\n }\n\n > h5 {\n @include m.chevron_size_s();\n }\n\n > h6 {\n @include m.chevron_size_xs();\n }\n\n &.open {\n > #{$class}-content {\n display: revert;\n }\n\n > h1,\n > h2,\n > h3,\n > h4,\n > h5,\n > h6 {\n @include m.chevron_open();\n }\n }\n}\n"],
5
+ "mappings": "AAKI,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,aCFA,SAAA,SAEA,aAAA,KAEA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QAAA,CDFA,ICEA,EAAA,CAAA,YAAA,QACI,SAAA,S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BR,IE8BQ,MAAA,CArBJ,eAqBI,CAAA,GAAA,CANJ,WAMI,CF9BR,IE8BQ,MAAA,CArBJ,eAqBI,CAAA,GAAA,CANJ,qBAMI,CF9BR,IE8BQ,MAAA,CArBJ,eAqBI,CAAA,GAAA,CANJ,WAMI,CF9BR,IE8BQ,MAAA,CArBJ,eAqBI,CAAA,GAAA,CANJ,qBAOQ,YAAA,ODmCZ,CCzDI,eDyDJ,CAAA,EAAA,QACI,MAAA,KACA,OAAA,KAEA,UAAA,KAfJ,CC9CI,eD8CJ,CAAA,EAAA,QAAA,CC9CI,eD8CJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KAjBJ,CCnCI,eDmCJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KAjBJ,CCxBI,eDwBJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KAjBJ,CCbI,eDaJ,CAAA,EAAA,QACI,KAAA,IAEA,MAAA,KACA,OAAA,KAEA,UAAA,KC8BA,CAjDA,eAiDA,CAAA,IAAA,CAAA,CAtDJ,wBAuDQ,QAAA,ODgBR,CClEI,eDkEJ,CCjBI,IDiBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCjBI,IDiBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCjBI,IDiBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCjBI,IDiBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCjBI,IDiBJ,CAAA,EAAA,QAAA,CClEI,eDkEJ,CCjBI,IDiBJ,CAAA,EAAA,QACI,UAAA,WAAA",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";(()=>{var n="heading-section",i={DataId:"data-diplodoc-id",DataKey:"data-diplodoc-key"};var c="heading_sections",a={Heading:".yfm .heading-section > h1,h2,h3,h4,h5,h6",Section:".yfm .heading-section",Content:".yfm .heading-section-content"},o={Open:"open"};var A=t=>{let e=t.composedPath();return Array.isArray(e)&&e.length>0?e[0]:t.target},C=t=>{let e=A(t);return!e||!e.matches};var I=class{__doc;constructor(e){this.__doc=e,this.__doc.addEventListener("click",this._onDocClick)}open(e){for(let g of this._findSections(e))g.classList.add(o.Open)}toggle(e){for(let g of this._findSections(e))g.classList.toggle(o.Open)}close(e){for(let g of this._findSections(e))g.classList.remove(o.Open)}destroy(){this.__doc.removeEventListener("click",this._onDocClick)}_findSections(e){return Array.from(this.__doc.querySelectorAll(`section[${i.DataKey}=${n}][${i.DataId}=${e}]`))}_onDocClick=e=>{if(C(e))return;let g=this._findHeading(e);g&&this._toogleSection(g)};_findHeading(e){let g=A(e);return this._matchHeading(g)?g:e.composedPath?.()?.find(this._matchHeading)}_matchHeading=e=>e instanceof HTMLElement?e?.matches?.(a.Heading)&&e.parentElement?.matches(a.Section):!1;_toogleSection(e){let g=e.parentElement;g instanceof HTMLElement&&g.classList.toggle(o.Open)}};typeof window<"u"&&typeof document<"u"&&!window[c]&&(window[c]=new I(document));})();
1
+ "use strict";(()=>{var c="heading-section",o={DataId:"data-diplodoc-id",DataKey:"data-diplodoc-key"};var a="heading_sections",I={Heading:".yfm .heading-section > h1,h2,h3,h4,h5,h6",Section:".yfm .heading-section",Content:".yfm .heading-section-content"},i={Open:"open"};var A=g=>{let e=g.composedPath();return Array.isArray(e)&&e.length>0?e[0]:g.target},C=g=>{let e=A(g);return!e||!e.matches};var n=class{__doc;constructor(e){this.__doc=e,this.__doc.addEventListener("click",this._onDocClick)}open(e){for(let t of this._findSections(e))t.classList.add(i.Open)}toggle(e){for(let t of this._findSections(e))t.classList.toggle(i.Open)}close(e){for(let t of this._findSections(e))t.classList.remove(i.Open)}destroy(){this.__doc.removeEventListener("click",this._onDocClick)}_findSections(e){return Array.from(this.__doc.querySelectorAll(`section[${o.DataKey}=${c}][${o.DataId}=${e}]`))}_onDocClick=e=>{if(C(e))return;let t=this._findHeading(e);t&&this._toogleSection(t)};_findHeading(e){let t=A(e);return this._matchHeading(t)?t:e.composedPath?.()?.find(this._matchHeading)}_matchHeading=e=>e instanceof HTMLElement?e?.matches?.(I.Heading)&&e.parentElement?.matches(I.Section):!1;_toogleSection(e){let t=e.parentElement;t instanceof HTMLElement&&t.classList.toggle(i.Open)}};typeof window<"u"&&typeof document<"u"&&!window[a]&&(window[a]=new n(document));})();
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/common/const.ts", "../../src/runtime/const.ts", "../../src/runtime/utils.ts", "../../src/runtime/controller.ts", "../../src/runtime/index.ts"],
4
- "sourcesContent": ["export const DATA_KEY = 'heading-section';\n\nexport const SectionAttr = {\n DataId: 'data-diplodoc-id',\n DataKey: 'data-diplodoc-key',\n} as const;\n\nexport const SectionCN = {\n Section: 'heading-section',\n Content: 'heading-section-content',\n};\n", "export {SectionAttr, DATA_KEY} from '../common/const';\n\nexport const GLOBAL_KEY = 'heading_sections';\n\nexport const Selector = {\n Heading: '.yfm .heading-section > h1,h2,h3,h4,h5,h6',\n Section: '.yfm .heading-section',\n Content: '.yfm .heading-section-content',\n} as const;\n\nexport const ClassName = {\n Open: 'open',\n} as const;\n", "export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n", "import {ClassName, DATA_KEY, SectionAttr, Selector} from './const';\nimport {getEventTarget, isCustom} from './utils';\n\nexport class HeadingSectionContoller {\n private __doc: Document;\n\n constructor(doc: Document) {\n this.__doc = doc;\n this.__doc.addEventListener('click', this._onDocClick);\n }\n\n open(id: string) {\n for (const elem of this._findSections(id)) {\n elem.classList.add(ClassName.Open);\n }\n }\n\n toggle(id: string) {\n for (const elem of this._findSections(id)) {\n elem.classList.toggle(ClassName.Open);\n }\n }\n\n close(id: string) {\n for (const elem of this._findSections(id)) {\n elem.classList.remove(ClassName.Open);\n }\n }\n\n destroy() {\n this.__doc.removeEventListener('click', this._onDocClick);\n }\n\n private _findSections(id: string) {\n return Array.from(\n this.__doc.querySelectorAll(\n `section[${SectionAttr.DataKey}=${DATA_KEY}][${SectionAttr.DataId}=${id}]`,\n ),\n );\n }\n\n private _onDocClick = (event: MouseEvent) => {\n if (isCustom(event)) return;\n\n const heading = this._findHeading(event);\n if (heading) this._toogleSection(heading);\n };\n\n private _findHeading(event: MouseEvent): HTMLElement | undefined {\n const target = getEventTarget(event);\n\n if (this._matchHeading(target)) return target as HTMLElement;\n\n const path = event.composedPath?.();\n return path?.find(this._matchHeading) as HTMLElement | undefined;\n }\n\n private _matchHeading = (target: EventTarget | null) => {\n if (!(target instanceof HTMLElement)) return false;\n\n return (\n target?.matches?.(Selector.Heading) && target.parentElement?.matches(Selector.Section)\n );\n };\n\n private _toogleSection(heading: HTMLElement) {\n const section = heading.parentElement;\n if (section instanceof HTMLElement) {\n section.classList.toggle(ClassName.Open);\n }\n }\n}\n", "import {GLOBAL_KEY} from './const';\nimport {HeadingSectionContoller} from './controller';\n\nimport './styles/index.scss';\n\nif (typeof window !== 'undefined' && typeof document !== 'undefined' && !window[GLOBAL_KEY]) {\n window[GLOBAL_KEY] = new HeadingSectionContoller(document);\n}\n\ndeclare global {\n interface Window {\n [GLOBAL_KEY]: HeadingSectionContoller;\n }\n}\n"],
5
- "mappings": "mBAAO,IAAMA,EAAW,kBAEXC,EAAc,CACvB,OAAQ,mBACR,QAAS,mBACb,ECHO,IAAMC,EAAa,mBAEbC,EAAW,CACpB,QAAS,4CACT,QAAS,wBACT,QAAS,+BACb,EAEaC,EAAY,CACrB,KAAM,MACV,ECZO,IAAMC,EAAkBC,GAAiB,CAC5C,IAAMC,EAAOD,EAAM,aAAa,EAChC,OAAO,MAAM,QAAQC,CAAI,GAAKA,EAAK,OAAS,EAAIA,EAAK,CAAC,EAAID,EAAM,MACpE,EAEaE,EA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J,EClEI,OAAO,OAAW,KAAe,OAAO,SAAa,KAAe,CAAC,OAAOU,CAAU,IACtF,OAAOA,CAAU,EAAI,IAAIC,EAAwB,QAAQ",
4
+ "sourcesContent": ["export const DATA_KEY = 'heading-section';\n\nexport const SectionAttr = {\n DataId: 'data-diplodoc-id',\n DataKey: 'data-diplodoc-key',\n} as const;\n\nexport const SectionCN = {\n Section: 'heading-section',\n Content: 'heading-section-content',\n};\n", "export {SectionAttr, DATA_KEY} from '../common/const';\n\nexport const GLOBAL_KEY = 'heading_sections';\n\nexport const Selector = {\n Heading: '.yfm .heading-section > h1,h2,h3,h4,h5,h6',\n Section: '.yfm .heading-section',\n Content: '.yfm .heading-section-content',\n} as const;\n\nexport const ClassName = {\n Open: 'open',\n} as const;\n", "export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n", "import {ClassName, DATA_KEY, SectionAttr, Selector} from './const';\nimport {getEventTarget, isCustom} from './utils';\n\nexport class HeadingSectionContoller {\n private __doc: Document;\n\n constructor(doc: Document) {\n this.__doc = doc;\n this.__doc.addEventListener('click', this._onDocClick);\n }\n\n open(id: string) {\n for (const elem of this._findSections(id)) {\n elem.classList.add(ClassName.Open);\n }\n }\n\n toggle(id: string) {\n for (const elem of this._findSections(id)) {\n elem.classList.toggle(ClassName.Open);\n }\n }\n\n close(id: string) {\n for (const elem of this._findSections(id)) {\n elem.classList.remove(ClassName.Open);\n }\n }\n\n destroy() {\n this.__doc.removeEventListener('click', this._onDocClick);\n }\n\n private _findSections(id: string) {\n return Array.from(\n this.__doc.querySelectorAll(\n `section[${SectionAttr.DataKey}=${DATA_KEY}][${SectionAttr.DataId}=${id}]`,\n ),\n );\n }\n\n private _onDocClick = (event: MouseEvent) => {\n if (isCustom(event)) return;\n\n const heading = this._findHeading(event);\n if (heading) this._toogleSection(heading);\n };\n\n private _findHeading(event: MouseEvent): HTMLElement | undefined {\n const target = getEventTarget(event);\n\n if (this._matchHeading(target)) return target as HTMLElement;\n\n const path = event.composedPath?.();\n return path?.find(this._matchHeading) as HTMLElement | undefined;\n }\n\n private _matchHeading = (target: EventTarget | null) => {\n if (!(target instanceof HTMLElement)) return false;\n\n return (\n target?.matches?.(Selector.Heading) && target.parentElement?.matches(Selector.Section)\n );\n };\n\n private _toogleSection(heading: HTMLElement) {\n const section = heading.parentElement;\n if (section instanceof HTMLElement) {\n section.classList.toggle(ClassName.Open);\n }\n }\n}\n", "import {GLOBAL_KEY} from './const';\nimport {HeadingSectionContoller} from './controller';\nimport './styles/index.scss';\n\nif (typeof window !== 'undefined' && typeof document !== 'undefined' && !window[GLOBAL_KEY]) {\n window[GLOBAL_KEY] = new HeadingSectionContoller(document);\n}\n\ndeclare global {\n interface Window {\n [GLOBAL_KEY]: HeadingSectionContoller;\n }\n}\n"],
5
+ "mappings": "mBAAO,IAAMA,EAAW,kBAEXC,EAAc,CACvB,OAAQ,mBACR,QAAS,mBACb,ECHO,IAAMC,EAAa,mBAEbC,EAAW,CACpB,QAAS,4CACT,QAAS,wBACT,QAAS,+BACb,EAEaC,EAAY,CACrB,KAAM,MACV,ECZO,IAAMC,EAAkBC,GAAiB,CAC5C,IAAMC,EAAOD,EAAM,aAAa,EAChC,OAAO,MAAM,QAAQC,CAAI,GAAKA,EAAK,OAAS,EAAIA,EAAK,CAAC,EAAID,EAAM,MACpE,EAEaE,EAAYF,GAAiB,CACtC,IAAMG,EAASJ,EAAeC,CAAK,EACnC,MAAO,CAACG,GAAU,CAAEA,EAAuB,OAC/C,ECLO,IAAMC,EAAN,KAA8B,CACzB,MAER,YAAYC,EAAe,CACvB,KAAK,MAAQA,EACb,KAAK,MAAM,iBAAiB,QAAS,KAAK,WAAW,CACzD,CAEA,KAAKC,EAAY,CACb,QAAWC,KAAQ,KAAK,cAAcD,CAAE,EACpCC,EAAK,UAAU,IAAIC,EAAU,IAAI,CAEzC,CAEA,OAAOF,EAAY,CACf,QAAWC,KAAQ,KAAK,cAAcD,CAAE,EACpCC,EAAK,UAAU,OAAOC,EAAU,IAAI,CAE5C,CAEA,MAAMF,EAAY,CACd,QAAWC,KAAQ,KAAK,cAAcD,CAAE,EACpCC,EAAK,UAAU,OAAOC,EAAU,IAAI,CAE5C,CAEA,SAAU,CACN,KAAK,MAAM,oBAAoB,QAAS,KAAK,WAAW,CAC5D,CAEQ,cAAcF,EAAY,CAC9B,OAAO,MAAM,KACT,KAAK,MAAM,iBACP,WAAWG,EAAY,OAAO,IAAIC,CAAQ,KAAKD,EAAY,MAAM,IAAIH,CAAE,GAC3E,CACJ,CACJ,CAEQ,YAAeK,GAAsB,CACzC,GAAIC,EAASD,CAAK,EAAG,OAErB,IAAME,EAAU,KAAK,aAAaF,CAAK,EACnCE,GAAS,KAAK,eAAeA,CAAO,CAC5C,EAEQ,aAAaF,EAA4C,CAC7D,IAAMG,EAASC,EAAeJ,CAAK,EAEnC,OAAI,KAAK,cAAcG,CAAM,EAAUA,EAE1BH,EAAM,eAAe,GACrB,KAAK,KAAK,aAAa,CACxC,CAEQ,cAAiBG,GACfA,aAAkB,YAGpBA,GAAQ,UAAUE,EAAS,OAAO,GAAKF,EAAO,eAAe,QAAQE,EAAS,OAAO,EAH5C,GAOzC,eAAeH,EAAsB,CACzC,IAAMI,EAAUJ,EAAQ,cACpBI,aAAmB,aACnBA,EAAQ,UAAU,OAAOT,EAAU,IAAI,CAE/C,CACJ,ECnEI,OAAO,OAAW,KAAe,OAAO,SAAa,KAAe,CAAC,OAAOU,CAAU,IACtF,OAAOA,CAAU,EAAI,IAAIC,EAAwB,QAAQ",
6
6
  "names": ["DATA_KEY", "SectionAttr", "GLOBAL_KEY", "Selector", "ClassName", "getEventTarget", "event", "path", "isCustom", "target", "HeadingSectionContoller", "doc", "id", "elem", "ClassName", "SectionAttr", "DATA_KEY", "event", "isCustom", "heading", "target", "getEventTarget", "Selector", "section", "GLOBAL_KEY", "HeadingSectionContoller"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  export declare function generateID(): string;
2
2
  export declare function headingLevel(header: string): number;
3
3
  export declare function last<T>(arr: T[]): T | undefined;
4
- export declare function hidden<B extends Record<string | symbol, unknown>, F extends string | symbol, V>(box: B, field: F, value: V): B & { [P in F]: V; };
4
+ export declare function hidden<B extends Record<string | symbol, unknown>, F extends string | symbol, V>(box: B, field: F, value: V): B & Record<F, V>;
5
5
  export type Runtime = {
6
6
  script: string;
7
7
  style: string;
@@ -0,0 +1,147 @@
1
+ export declare const sectionsHtmlResult: string;
2
+ export declare const commonHeadingTokens: ({
3
+ type: string;
4
+ tag: string;
5
+ attrs: null;
6
+ map: number[];
7
+ nesting: number;
8
+ level: number;
9
+ children: null;
10
+ content: string;
11
+ markup: string;
12
+ info: string;
13
+ meta: null;
14
+ block: boolean;
15
+ hidden: boolean;
16
+ } | {
17
+ type: string;
18
+ tag: string;
19
+ attrs: null;
20
+ map: number[];
21
+ nesting: number;
22
+ level: number;
23
+ children: {
24
+ type: string;
25
+ tag: string;
26
+ attrs: null;
27
+ map: null;
28
+ nesting: number;
29
+ level: number;
30
+ children: null;
31
+ content: string;
32
+ markup: string;
33
+ info: string;
34
+ meta: null;
35
+ block: boolean;
36
+ hidden: boolean;
37
+ }[];
38
+ content: string;
39
+ markup: string;
40
+ info: string;
41
+ meta: null;
42
+ block: boolean;
43
+ hidden: boolean;
44
+ } | {
45
+ type: string;
46
+ tag: string;
47
+ attrs: null;
48
+ map: null;
49
+ nesting: number;
50
+ level: number;
51
+ children: null;
52
+ content: string;
53
+ markup: string;
54
+ info: string;
55
+ meta: null;
56
+ block: boolean;
57
+ hidden: boolean;
58
+ })[];
59
+ export declare const foldingHeadingTokens: ({
60
+ type: string;
61
+ tag: string;
62
+ attrs: string[][];
63
+ map: null;
64
+ nesting: number;
65
+ level: number;
66
+ children: null;
67
+ content: string;
68
+ markup: string;
69
+ info: string;
70
+ meta: null;
71
+ block: boolean;
72
+ hidden: boolean;
73
+ } | {
74
+ type: string;
75
+ tag: string;
76
+ attrs: null;
77
+ map: number[];
78
+ nesting: number;
79
+ level: number;
80
+ children: null;
81
+ content: string;
82
+ markup: string;
83
+ info: string;
84
+ meta: {
85
+ folding: boolean;
86
+ };
87
+ block: boolean;
88
+ hidden: boolean;
89
+ } | {
90
+ type: string;
91
+ tag: string;
92
+ attrs: null;
93
+ map: number[];
94
+ nesting: number;
95
+ level: number;
96
+ children: {
97
+ type: string;
98
+ tag: string;
99
+ attrs: null;
100
+ map: null;
101
+ nesting: number;
102
+ level: number;
103
+ children: null;
104
+ content: string;
105
+ markup: string;
106
+ info: string;
107
+ meta: null;
108
+ block: boolean;
109
+ hidden: boolean;
110
+ }[];
111
+ content: string;
112
+ markup: string;
113
+ info: string;
114
+ meta: null;
115
+ block: boolean;
116
+ hidden: boolean;
117
+ } | {
118
+ type: string;
119
+ tag: string;
120
+ attrs: null;
121
+ map: null;
122
+ nesting: number;
123
+ level: number;
124
+ children: null;
125
+ content: string;
126
+ markup: string;
127
+ info: string;
128
+ meta: {
129
+ folding: boolean;
130
+ };
131
+ block: boolean;
132
+ hidden: boolean;
133
+ } | {
134
+ type: string;
135
+ tag: string;
136
+ attrs: null;
137
+ map: null;
138
+ nesting: number;
139
+ level: number;
140
+ children: null;
141
+ content: string;
142
+ markup: string;
143
+ info: string;
144
+ meta: null;
145
+ block: boolean;
146
+ hidden: boolean;
147
+ })[];
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@diplodoc/folding-headings-extension",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Folding headings extension for Diplodoc platform ",
5
5
  "main": "build/plugin/index.js",
6
6
  "types": "build/plugin/index.d.ts",
7
+ "engines": {
8
+ "npm": ">=11.5.1"
9
+ },
7
10
  "exports": {
8
11
  ".": {
9
12
  "types": "./build/plugin/index.d.ts",
@@ -32,25 +35,25 @@
32
35
  "scripts": {
33
36
  "build": "run-p build:*",
34
37
  "build:declarations": "tsc --emitDeclarationOnly --outDir ./build",
35
- "build:js": "./esbuild/build.mjs",
36
- "lint": "eslint .",
37
- "lint:fix": "eslint --fix .",
38
- "prepublishOnly": "npm run build",
39
- "test": "jest"
38
+ "build:js": "node ./esbuild/build.mjs",
39
+ "prepublishOnly": "npm run typecheck && npm run lint && npm test && npm run build",
40
+ "test": "vitest run --config vitest.config.mjs",
41
+ "test:watch": "vitest --config vitest.config.mjs",
42
+ "test:coverage": "vitest run --coverage",
43
+ "typecheck": "tsc --noEmit",
44
+ "lint": "lint update && lint",
45
+ "lint:fix": "lint update && lint fix",
46
+ "pre-commit": "lint update && lint-staged",
47
+ "prepare": "husky"
40
48
  },
41
49
  "devDependencies": {
42
- "@diplodoc/eslint-config": "^2.0.0",
43
- "@diplodoc/prettier-config": "^2.0.0",
44
- "@diplodoc/transform": "^4.20.0",
50
+ "@diplodoc/lint": "^1.14.1",
45
51
  "@diplodoc/tsconfig": "^1.0.2",
46
- "@types/jest": "^29.5.12",
47
- "@types/markdown-it": "^13.0.8",
48
- "esbuild": "^0.20.2",
49
- "esbuild-sass-plugin": "^3.3.1",
50
- "jest": "^29.7.0",
51
- "jest-environment-jsdom": "^29.7.0",
52
+ "@types/markdown-it": "^13.0.9",
53
+ "@vitest/coverage-v8": "^3.2.4",
54
+ "markdown-it": "^13.0.0",
52
55
  "npm-run-all": "^4.1.5",
53
- "ts-jest": "^29.2.2",
54
- "typescript": "^5.3.3"
56
+ "typescript": "^5.3.3",
57
+ "vitest": "^3.2.4"
55
58
  }
56
59
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes