cosey 0.10.0 → 0.10.1

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
@@ -76,4 +76,4 @@ Cosey 基于 element-plus 并补充了众多组件,意在使开发者更加专
76
76
  - 打标签 `npm run tag`
77
77
  - 生成更新日志 `npm run changelog`
78
78
  - 暂存、提交 changelog `git commit -a -m 'chore: changelog'`
79
- - 推送
79
+ - 推送 `npm run push`
@@ -1,18 +1,18 @@
1
1
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
- value: {
2
+ language: {
3
3
  type: StringConstructor;
4
4
  default: string;
5
5
  };
6
6
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
7
  'update:value': (value: string) => boolean;
8
8
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
9
- value: {
9
+ language: {
10
10
  type: StringConstructor;
11
11
  default: string;
12
12
  };
13
13
  }>> & Readonly<{
14
14
  "onUpdate:value"?: ((value: string) => any) | undefined;
15
15
  }>, {
16
- value: string;
16
+ language: string;
17
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
18
18
  export default _default;
@@ -2,12 +2,13 @@ import { defineComponent, useModel, createVNode } from 'vue';
2
2
  import { useEditor, useElement } from 'slate-vue3';
3
3
  import { DOMEditor } from 'slate-vue3/dom';
4
4
  import { languageOptions } from '../plugins/code-block.js';
5
+ import { useGlobalHighlightStyle } from '../../highlight/highlight.style.js';
5
6
  import { isString } from '../../../utils/is.js';
6
7
 
7
8
  var stdin_default = defineComponent({
8
9
  name: "CoEditorContentCodeBlock",
9
10
  props: {
10
- value: {
11
+ language: {
11
12
  type: String,
12
13
  default: "text"
13
14
  }
@@ -18,28 +19,31 @@ var stdin_default = defineComponent({
18
19
  setup(props, {
19
20
  slots
20
21
  }) {
21
- const innerValue = useModel(props, "value");
22
+ useGlobalHighlightStyle();
23
+ const language = useModel(props, "language");
22
24
  const editor = useEditor();
23
25
  const element = useElement();
24
26
  const onChange = e => {
25
- innerValue.value = e.target.value;
27
+ language.value = e.target.value;
26
28
  const path = DOMEditor.findPath(editor, element.value);
27
29
  editor.setNodes({
28
- language: innerValue.value
30
+ language: language.value
29
31
  }, {
30
32
  at: path
31
33
  });
32
34
  };
33
35
  return () => {
34
36
  return createVNode("pre", {
35
- "class": `language-${innerValue.value}`
37
+ "class": `language-${language.value}`
38
+ }, [createVNode("code", {
39
+ "class": `language-${language.value}`
36
40
  }, [createVNode("select", {
37
- "value": innerValue.value,
41
+ "value": language.value,
38
42
  "contenteditable": false,
39
43
  "onChange": onChange
40
44
  }, [languageOptions.map(option => createVNode("option", {
41
45
  "value": option.value
42
- }, [option.label]))]), createVNode("div", null, [slots.default?.()])]);
46
+ }, [option.label]))]), createVNode("div", null, [slots.default?.()])])]);
43
47
  };
44
48
  }
45
49
  });
@@ -194,6 +194,7 @@ const getEditorStyle = (token) => {
194
194
  "&.is-focus::before": {
195
195
  content: '""',
196
196
  position: "absolute",
197
+ zIndex: 10,
197
198
  inset: 0,
198
199
  border: `2px solid ${token.colorPrimaryHover}`,
199
200
  borderRadius: token.borderRadius,
@@ -19,6 +19,7 @@ const languageOptions = [
19
19
  { value: "json", label: "JSON" },
20
20
  { value: "markdown", label: "Markdown" },
21
21
  { value: "php", label: "PHP" },
22
+ { value: "bash", label: "Bash" },
22
23
  { value: "java", label: "Java" },
23
24
  { value: "python", label: "Python" },
24
25
  { value: "sql", label: "SQL" }
@@ -318,7 +319,14 @@ function withCodeBlock(editor) {
318
319
  editor.renderElement = (props) => {
319
320
  const { attributes, children, element } = props;
320
321
  if (element.type === "code-block") {
321
- return h(stdin_default, useInheritRef(attributes), () => children);
322
+ return h(
323
+ stdin_default,
324
+ {
325
+ ...useInheritRef(attributes),
326
+ language: element.language
327
+ },
328
+ () => children
329
+ );
322
330
  }
323
331
  if (element.type === "code-line") {
324
332
  return h("div", { ...attributes, style: { position: "relative" } }, children);
@@ -6,7 +6,7 @@ const highlightProps = {
6
6
  },
7
7
  lang: {
8
8
  type: String,
9
- default: "txt"
9
+ default: "text"
10
10
  },
11
11
  maxHeight: {
12
12
  type: String
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, computed, createVNode } from 'vue';
2
2
  import { ElScrollbar } from 'element-plus';
3
3
  import { highlightSlots, highlightProps } from './highlight.api.js';
4
- import stdin_default$1 from './highlight.style.js';
4
+ import stdin_default$1, { useGlobalHighlightStyle } from './highlight.style.js';
5
5
  import stdin_default$2 from '../copy/copy.js';
6
6
  import { useComponentConfig } from '../config-provider/config-provider.api.js';
7
7
  import Prism from 'prismjs';
@@ -17,7 +17,8 @@ var stdin_default = defineComponent({
17
17
  const {
18
18
  hashId
19
19
  } = stdin_default$1(prefixCls);
20
- const highlightedCode = computed(() => Prism.highlight(props.code || "", Prism.languages[props.lang] || Prism.languages["txt"], props.lang));
20
+ useGlobalHighlightStyle();
21
+ const highlightedCode = computed(() => Prism.highlight(props.code || "", Prism.languages[props.lang] || Prism.languages["text"], props.lang));
21
22
  return () => {
22
23
  return createVNode("div", {
23
24
  "class": [hashId.value, prefixCls.value]
@@ -5,3 +5,4 @@ declare const _default: (_prefixCls?: import("vue").ComputedRef<string> | string
5
5
  hashId: import("vue").Ref<string, string>;
6
6
  };
7
7
  export default _default;
8
+ export declare const useGlobalHighlightStyle: (themeManager?: import("../theme/theme-context").ThemeManager) => void;
@@ -1,8 +1,10 @@
1
+ import { getGlobalStyleHook } from '../theme/getGlobalStyleHook.js';
1
2
  import { getSimpleStyleHook } from '../theme/getSimpleStyleHook.js';
2
3
 
3
4
  function getHljsDark() {
4
5
  return {
5
6
  'pre[class*="language-"], code[class*="language-"]': {
7
+ display: "block",
6
8
  color: "#d4d4d4",
7
9
  fontSize: "13px",
8
10
  textShadow: "none",
@@ -32,12 +34,10 @@ function getHljsDark() {
32
34
  },
33
35
  'pre[class*="language-"]': {
34
36
  padding: "1em",
35
- margin: ".5em 0",
36
37
  overflow: "auto",
37
38
  background: "#1e1e1e"
38
39
  },
39
40
  ':not(pre) > code[class*="language-"]': {
40
- padding: ".1em .3em",
41
41
  borderRadius: ".3em",
42
42
  color: "#db4c69",
43
43
  background: "#1e1e1e"
@@ -188,6 +188,7 @@ function getHljsDark() {
188
188
  function getHljsLight() {
189
189
  return {
190
190
  'code[class*="language-"], pre[class*="language-"]': {
191
+ display: "block",
191
192
  background: "hsl(230, 1%, 98%)",
192
193
  color: "hsl(230, 8%, 24%)",
193
194
  fontFamily: '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
@@ -215,12 +216,10 @@ function getHljsLight() {
215
216
  },
216
217
  'pre[class*="language-"]': {
217
218
  padding: "1em",
218
- margin: "0.5em 0",
219
219
  overflow: "auto",
220
220
  borderRadius: "0.3em"
221
221
  },
222
222
  ':not(pre) > code[class*="language-"]': {
223
- padding: "0.2em 0.3em",
224
223
  borderRadius: "0.3em",
225
224
  whiteSpace: "normal"
226
225
  },
@@ -335,15 +334,15 @@ var stdin_default = getSimpleStyleHook("CoHighlight", (token) => {
335
334
  insetBlockStart: token.sizeXXS,
336
335
  insetInlineEnd: token.sizeXXS,
337
336
  zIndex: 10
338
- },
339
- ":root.dark &": {
340
- ...getHljsDark()
341
- },
342
- ":root:not(.dark) &": {
343
- ...getHljsLight()
344
337
  }
345
338
  }
346
339
  };
347
340
  });
341
+ const useGlobalHighlightStyle = getGlobalStyleHook("CoGlobalHighlight", () => {
342
+ return {
343
+ ":root.dark": getHljsDark(),
344
+ ":root:not(.dark)": getHljsLight()
345
+ };
346
+ });
348
347
 
349
- export { stdin_default as default, getHljsDark, getHljsLight };
348
+ export { stdin_default as default, getHljsDark, getHljsLight, useGlobalHighlightStyle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -38,7 +38,7 @@
38
38
  "nprogress": "^0.2.0",
39
39
  "pinia": "^3.0.2",
40
40
  "prismjs": "^1.30.0",
41
- "slate-vue3": "^0.8.0",
41
+ "slate-vue3": "^0.10.0",
42
42
  "stylis": "^4.3.6",
43
43
  "svga": "^2.1.1",
44
44
  "vue": "^3.5.21",
@@ -72,7 +72,7 @@
72
72
  "nprogress": "^0.2.0",
73
73
  "pinia": "^3.0.2",
74
74
  "prismjs": "^1.30.0",
75
- "slate-vue3": "^0.8.0",
75
+ "slate-vue3": "^0.10.0",
76
76
  "stylis": "^4.3.6",
77
77
  "svga": "^2.1.1",
78
78
  "vue": "^3.5.21",