@shwfed/nuxt 0.1.11 → 0.1.12

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.1.11",
4
+ "version": "0.1.12",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addImports } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addPlugin, addImportsDir } from '@nuxt/kit';
2
2
 
3
3
  const module$1 = defineNuxtModule({
4
4
  meta: {
@@ -9,12 +9,10 @@ const module$1 = defineNuxtModule({
9
9
  setup(options, nuxt) {
10
10
  const resolver = createResolver(import.meta.url);
11
11
  nuxt.options.runtimeConfig.public.shwfed = options;
12
- addPlugin(resolver.resolve("./runtime/plugins/cel/index"));
13
- addImports({
14
- name: "useCheating",
15
- as: "useCheating",
16
- from: resolver.resolve("runtime/composables/useCheating")
17
- });
12
+ addPlugin(resolver.resolve("runtime/plugins/cel/index"));
13
+ addPlugin(resolver.resolve("runtime/plugins/markdown/index"));
14
+ addImportsDir(resolver.resolve("runtime/composables"));
15
+ nuxt.options.typescript.tsConfig.include?.push(resolver.resolve("runtime/types/directive.d.ts"));
18
16
  }
19
17
  });
20
18
 
@@ -0,0 +1,7 @@
1
+ import { md } from './md.js';
2
+ declare const _default: import("#app").Plugin<{
3
+ md: typeof md;
4
+ }> & import("#app").ObjectPlugin<{
5
+ md: typeof md;
6
+ }>;
7
+ export default _default;
@@ -0,0 +1,25 @@
1
+ import { defineNuxtPlugin } from "#app";
2
+ import MarkdownIt from "markdown-it";
3
+ import { md } from "./md.js";
4
+ export default defineNuxtPlugin((app) => {
5
+ const engine = new MarkdownIt("commonmark", {
6
+ html: true
7
+ });
8
+ app.vueApp.directive("md", {
9
+ beforeMount(el, v) {
10
+ if (["inline", "inline-flex", "inline-block"].includes(getComputedStyle(el).display)) {
11
+ el.innerHTML = engine.renderInline(v.value);
12
+ } else {
13
+ el.innerHTML = engine.render(v.value);
14
+ }
15
+ },
16
+ beforeUpdate(el, v) {
17
+ el.innerHTML = engine.renderInline(v.value);
18
+ }
19
+ });
20
+ return {
21
+ provide: {
22
+ md
23
+ }
24
+ };
25
+ });
@@ -0,0 +1,9 @@
1
+ export type Markdown = string & Record<never, never>;
2
+ /**
3
+ * Create Markdown text (**Not rendering it into HTML**).
4
+ *
5
+ * - Trim the leading and trailing whitespace of the input.
6
+ * - Escape special characters (except backtick as it will break parsing)
7
+ * - Use first line indent as the indent of the rest lines.
8
+ */
9
+ export declare function md(...args: Parameters<typeof String.raw>): Markdown;
@@ -0,0 +1,5 @@
1
+ export function md(...args) {
2
+ const original = String.raw(...args);
3
+ const indent = (original.startsWith("\n") ? original.slice(1) : original).split("\n", 1)[0]?.match(/^(\s*)/)?.[1]?.length ?? 0;
4
+ return original.trim().replaceAll("\\`", "`").split("\n").map((line) => line.replace(new RegExp(`^${String.raw`\s`.repeat(indent)}`), "")).join("\n");
5
+ }
@@ -0,0 +1,9 @@
1
+ import type { Directive } from 'vue'
2
+
3
+ export type MdDirective = Directive<HTMLElement, string>
4
+
5
+ declare module 'vue' {
6
+ export interface ComponentCustomProperties {
7
+ vMd: MdDirective
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -62,6 +62,7 @@
62
62
  "@nuxt/test-utils": "^3.23.0",
63
63
  "@types/markdown-it": "^14.1.2",
64
64
  "@types/node": "latest",
65
+ "@vue/test-utils": "^2.4.6",
65
66
  "changelogen": "^0.6.2",
66
67
  "eslint": "^9.39.2",
67
68
  "husky": "^9.1.7",