From 2af652712453ed4166a9b31ae3040d8737ae518a Mon Sep 17 00:00:00 2001 From: sharevb Date: Sat, 18 May 2024 15:20:38 +0200 Subject: [PATCH] feat(new tool): Markdown TOC Generator Fix #573 --- components.d.ts | 4 +++ package.json | 1 + pnpm-lock.yaml | 34 +++++++++++++++---- src/tools/index.ts | 2 ++ src/tools/markdown-toc-generator/index.ts | 12 +++++++ .../markdown-contents.d.ts | 6 ++++ .../markdown-toc-generator.vue | 30 ++++++++++++++++ 7 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 src/tools/markdown-toc-generator/index.ts create mode 100644 src/tools/markdown-toc-generator/markdown-contents.d.ts create mode 100644 src/tools/markdown-toc-generator/markdown-toc-generator.vue diff --git a/components.d.ts b/components.d.ts index f2c3146f5..2aa235c06 100644 --- a/components.d.ts +++ b/components.d.ts @@ -119,6 +119,7 @@ declare module '@vue/runtime-core' { LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default'] MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default'] MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default'] + MarkdownTocGenerator: typeof import('./src/tools/markdown-toc-generator/markdown-toc-generator.vue')['default'] MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default'] MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.vue')['default'] MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default'] @@ -129,15 +130,18 @@ declare module '@vue/runtime-core' { NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] NCode: typeof import('naive-ui')['NCode'] NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] + NColorPicker: typeof import('naive-ui')['NColorPicker'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NDivider: typeof import('naive-ui')['NDivider'] NEllipsis: typeof import('naive-ui')['NEllipsis'] + NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] NGi: typeof import('naive-ui')['NGi'] NGrid: typeof import('naive-ui')['NGrid'] NH1: typeof import('naive-ui')['NH1'] NH3: typeof import('naive-ui')['NH3'] NIcon: typeof import('naive-ui')['NIcon'] + NImage: typeof import('naive-ui')['NImage'] NInputNumber: typeof import('naive-ui')['NInputNumber'] NLabel: typeof import('naive-ui')['NLabel'] NLayout: typeof import('naive-ui')['NLayout'] diff --git a/package.json b/package.json index 9f39ff1db..b4493e56f 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "jwt-decode": "^3.1.2", "libphonenumber-js": "^1.10.28", "lodash": "^4.17.21", + "markdown-contents": "^1.0.11", "marked": "^10.0.0", "mathjs": "^11.9.1", "mime-types": "^2.1.35", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bd6c38c91..63b8c2cd8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,6 +104,9 @@ dependencies: lodash: specifier: ^4.17.21 version: 4.17.21 + markdown-contents: + specifier: ^1.0.11 + version: 1.0.11 marked: specifier: ^10.0.0 version: 10.0.0 @@ -3351,7 +3354,7 @@ packages: dependencies: '@unhead/dom': 0.5.1 '@unhead/schema': 0.5.1 - '@vueuse/shared': 10.7.2(vue@3.3.4) + '@vueuse/shared': 10.9.0(vue@3.3.4) unhead: 0.5.1 vue: 3.3.4 transitivePeerDependencies: @@ -3993,10 +3996,10 @@ packages: - vue dev: false - /@vueuse/shared@10.7.2(vue@3.3.4): - resolution: {integrity: sha512-qFbXoxS44pi2FkgFjPvF4h7c9oMDutpyBdcJdMYIMg9XyXli2meFMuaKn+UMgsClo//Th6+beeCgqweT/79BVA==} + /@vueuse/shared@10.9.0(vue@3.3.4): + resolution: {integrity: sha512-Uud2IWncmAfJvRaFYzv5OHDli+FbOzxiVEQdLCKQKLyhz94PIyFC3CHcH7EDMwIn8NPtD06+PNbC/PiO0LGLtw==} dependencies: - vue-demi: 0.14.6(vue@3.3.4) + vue-demi: 0.14.7(vue@3.3.4) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -4594,6 +4597,13 @@ packages: upper-case: 2.0.2 dev: false + /contents@5.0.0: + resolution: {integrity: sha512-wnnGorqo07ZSIzMQmUc4vUv1NEXl7elBtqoz5UcysV+pbSvphZYfI763rXgpFK2H9o5rvjQQ8kZxp7hOOwIe3A==} + dependencies: + lodash: 4.17.21 + sister: 3.0.2 + dev: false + /convert-source-map@1.9.0: resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} dev: true @@ -6796,6 +6806,13 @@ packages: resolution: {integrity: sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==} dev: true + /markdown-contents@1.0.11: + resolution: {integrity: sha512-6o8It0JhmoN398ATp8zOWHAniTB3/tEXUVTCP00gTqwZNc465DIoHTTaspyEkaov93QLhrqirxizJ29E/i8/0Q==} + dependencies: + contents: 5.0.0 + lodash: 4.17.21 + dev: false + /markdown-it@13.0.2: resolution: {integrity: sha512-FtwnEuuK+2yVU7goGn/MJ0WBZMM9ZPgU9spqlFs7/A/pDIUNSOQZhUgOqYCficIuR2QaFnrt8LHqBWsbTAoI5w==} hasBin: true @@ -8098,6 +8115,10 @@ packages: totalist: 3.0.1 dev: true + /sister@3.0.2: + resolution: {integrity: sha512-p19rtTs+NksBRKW9qn0UhZ8/TUI9BPw9lmtHny+Y3TinWlOa9jWh9xB0AtPSdmOy49NJJJSSe0Ey4C7h0TrcYA==} + dev: false + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -9151,8 +9172,8 @@ packages: vue: 3.3.4 dev: false - /vue-demi@0.14.6(vue@3.3.4): - resolution: {integrity: sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==} + /vue-demi@0.14.7(vue@3.3.4): + resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==} engines: {node: '>=12'} hasBin: true requiresBuild: true @@ -9442,6 +9463,7 @@ packages: /workbox-google-analytics@7.0.0: resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==} + deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained dependencies: workbox-background-sync: 7.0.0 workbox-core: 7.0.0 diff --git a/src/tools/index.ts b/src/tools/index.ts index aa861c935..da1fe1454 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,6 +1,7 @@ import { tool as base64FileConverter } from './base64-file-converter'; import { tool as base64StringConverter } from './base64-string-converter'; import { tool as basicAuthGenerator } from './basic-auth-generator'; +import { tool as markdownTocGenerator } from './markdown-toc-generator'; import { tool as asciiTextDrawer } from './ascii-text-drawer'; @@ -107,6 +108,7 @@ export const toolsByCategory: ToolCategory[] = [ listConverter, tomlToJson, tomlToYaml, + markdownTocGenerator, ], }, { diff --git a/src/tools/markdown-toc-generator/index.ts b/src/tools/markdown-toc-generator/index.ts new file mode 100644 index 000000000..37f540d30 --- /dev/null +++ b/src/tools/markdown-toc-generator/index.ts @@ -0,0 +1,12 @@ +import { Table } from '@vicons/tabler'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'Markdown toc generator', + path: '/markdown-toc-generator', + description: 'Generate a TOC from a markdown file/content', + keywords: ['markdown', 'toc', 'generator'], + component: () => import('./markdown-toc-generator.vue'), + icon: Table, + createdAt: new Date('2024-05-11'), +}); diff --git a/src/tools/markdown-toc-generator/markdown-contents.d.ts b/src/tools/markdown-toc-generator/markdown-contents.d.ts new file mode 100644 index 000000000..156e4b7cf --- /dev/null +++ b/src/tools/markdown-toc-generator/markdown-contents.d.ts @@ -0,0 +1,6 @@ +declare module 'markdown-contents'{ + declare class MarkdownContents { + markdown(): string; + } + export default function Create(markdown: string):MarkdownContents; +} \ No newline at end of file diff --git a/src/tools/markdown-toc-generator/markdown-toc-generator.vue b/src/tools/markdown-toc-generator/markdown-toc-generator.vue new file mode 100644 index 000000000..bb597d74f --- /dev/null +++ b/src/tools/markdown-toc-generator/markdown-toc-generator.vue @@ -0,0 +1,30 @@ + + +