@haklex/rich-ext-code-snippet 0.0.11 → 0.0.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/index.mjs CHANGED
@@ -15,6 +15,7 @@ import { FileIcon } from "@haklex/rich-renderer-codeblock/icons";
15
15
  import { getHighlighterWithLang, SHIKI_THEMES } from "@haklex/rich-renderer-codeblock/shiki";
16
16
  import { createPortal } from "react-dom";
17
17
  import { DecoratorNode, $getNodeByKey, $insertNodes } from "lexical";
18
+ import { CODE_SNIPPET_BLOCK_TRANSFORMER } from "@haklex/rich-headless/transformers";
18
19
  function toPrimitive(t, r2) {
19
20
  if ("object" != typeof t || !t) return t;
20
21
  var e = t[Symbol.toPrimitive];
@@ -928,41 +929,6 @@ function $isCodeSnippetEditNode(node) {
928
929
  }
929
930
  const codeSnippetNodes = [CodeSnippetNode];
930
931
  const codeSnippetEditNodes = [CodeSnippetEditNode];
931
- const NEVER_MATCH = /a^/;
932
- function quoteAttr(value) {
933
- return value.replaceAll('"', '\\"');
934
- }
935
- function pickFence(content) {
936
- const matches = content.match(/`+/g);
937
- const maxLen = matches?.reduce((max, run) => Math.max(max, run.length), 0) ?? 0;
938
- return "`".repeat(Math.max(3, maxLen + 1));
939
- }
940
- const CODE_SNIPPET_BLOCK_TRANSFORMER = {
941
- dependencies: [CodeSnippetNode],
942
- export: (node) => {
943
- if (!$isCodeSnippetNode(node)) return null;
944
- const snippet = node.exportJSON();
945
- const body = snippet.files.map((file) => {
946
- const fence = pickFence(file.code || "");
947
- const lang = file.language || "";
948
- const filename = quoteAttr(file.filename || "untitled");
949
- return [
950
- `::: file{name="${filename}" lang="${lang}"}`,
951
- `${fence}${lang}`,
952
- file.code || "",
953
- fence,
954
- ":::"
955
- ].join("\n");
956
- }).join("\n");
957
- return `::: code-snippet
958
- ${body}
959
- :::`;
960
- },
961
- regExp: NEVER_MATCH,
962
- replace: () => {
963
- },
964
- type: "element"
965
- };
966
932
  export {
967
933
  $createCodeSnippetEditNode,
968
934
  $createCodeSnippetNode,
@@ -1,10 +1,2 @@
1
- import { LexicalNode } from 'lexical';
2
- import { CodeSnippetNode } from './nodes/CodeSnippetNode';
3
- export declare const CODE_SNIPPET_BLOCK_TRANSFORMER: {
4
- dependencies: (typeof CodeSnippetNode)[];
5
- export: (node: LexicalNode) => string | null;
6
- regExp: RegExp;
7
- replace: () => void;
8
- type: "element";
9
- };
1
+ export { CODE_SNIPPET_BLOCK_TRANSFORMER } from '@haklex/rich-headless/transformers';
10
2
  //# sourceMappingURL=transformer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../src/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,EAEL,eAAe,EAEhB,MAAM,yBAAyB,CAAA;AAehC,eAAO,MAAM,8BAA8B;;mBAE1B,WAAW;;;;CAwB3B,CAAA"}
1
+ {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../src/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-ext-code-snippet",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Multi-file code snippet extension",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,10 +21,11 @@
21
21
  "@dnd-kit/utilities": "^3.2.2",
22
22
  "lucide-react": "^0.574.0",
23
23
  "shikicode": "*",
24
- "@haklex/rich-editor": "0.0.11",
25
- "@haklex/rich-renderer-codeblock": "0.0.11",
26
- "@haklex/rich-style-token": "0.0.11",
27
- "@haklex/rich-editor-ui": "0.0.11"
24
+ "@haklex/rich-editor": "0.0.12",
25
+ "@haklex/rich-headless": "0.0.12",
26
+ "@haklex/rich-editor-ui": "0.0.12",
27
+ "@haklex/rich-style-token": "0.0.12",
28
+ "@haklex/rich-renderer-codeblock": "0.0.12"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@lexical/react": "^0.40.0",