@globalbrain/sefirot 4.26.0 → 4.28.0

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.
@@ -7,7 +7,7 @@ import SDropdown from './SDropdown.vue'
7
7
 
8
8
  export type { Mode, Size, Tooltip, Type }
9
9
 
10
- const props = defineProps<{
10
+ const props = withDefaults(defineProps<{
11
11
  tag?: Component | string
12
12
  size?: Size
13
13
  type?: Type
@@ -23,8 +23,11 @@ const props = defineProps<{
23
23
  loading?: boolean
24
24
  disabled?: boolean
25
25
  tooltip?: string | Tooltip
26
+ dropdownAlign?: 'left' | 'right'
26
27
  options: DropdownSection[]
27
- }>()
28
+ }>(), {
29
+ dropdownAlign: 'left'
30
+ })
28
31
 
29
32
  const container = ref<any>(null)
30
33
 
@@ -40,7 +43,7 @@ async function onOpen() {
40
43
  </script>
41
44
 
42
45
  <template>
43
- <div class="SActionMenu" :class="[block]" ref="container">
46
+ <div class="SActionMenu" :class="[{ block }, dropdownAlign]" ref="container">
44
47
  <div class="button">
45
48
  <SButton
46
49
  :tag
@@ -75,7 +78,6 @@ async function onOpen() {
75
78
 
76
79
  .dropdown {
77
80
  position: absolute;
78
- left: 0;
79
81
  z-index: var(--z-index-dropdown);
80
82
 
81
83
  &.top { bottom: calc(100% + 8px); }
@@ -85,4 +87,7 @@ async function onOpen() {
85
87
  .SActionMenu.block {
86
88
  display: block;
87
89
  }
90
+
91
+ .SActionMenu.left .dropdown { left: 0; }
92
+ .SActionMenu.right .dropdown { right: 0; }
88
93
  </style>
@@ -104,6 +104,7 @@
104
104
  }
105
105
 
106
106
  .SContent :deep(ol > li::before) {
107
+ position: absolute;
107
108
  margin-right: 3px;
108
109
  margin-left: -20px;
109
110
  color: var(--c-text-1);
@@ -1,18 +1,18 @@
1
1
  <script setup lang="ts">
2
2
  import { type Component, computed } from 'vue'
3
- import { useMarkdown } from '../composables/Markdown'
3
+ import { type UseMarkdownOptions, useMarkdown } from '../composables/Markdown'
4
4
 
5
- const props = withDefaults(defineProps<{
5
+ export interface SMarkdownProps extends UseMarkdownOptions {
6
6
  tag?: Component | string
7
7
  content: string
8
- html?: boolean
9
- inline?: boolean
10
- }>(), {
8
+ }
9
+
10
+ const props = withDefaults(defineProps<SMarkdownProps>(), {
11
11
  tag: 'div',
12
12
  html: true
13
13
  })
14
14
 
15
- const markdown = useMarkdown({ html: props.html, inline: props.inline })
15
+ const markdown = useMarkdown(props)
16
16
  const rendered = computed(() => markdown(props.content))
17
17
  </script>
18
18
 
@@ -1,8 +1,71 @@
1
1
  import DOMPurify, { type Config } from 'dompurify'
2
- import MarkdownIt, { type Options as MarkdownItOptions } from 'markdown-it'
2
+ import MarkdownIt from 'markdown-it'
3
3
 
4
4
  export type UseMarkdown = (source: string, inline?: boolean) => string
5
5
 
6
+ // vendored for vue compatibility
7
+ export interface MarkdownItOptions {
8
+ /**
9
+ * Set `true` to enable HTML tags in source. Be careful!
10
+ * That's not safe! You may need external sanitizer to protect output from XSS.
11
+ * It's better to extend features via plugins, instead of enabling HTML.
12
+ * @default false
13
+ */
14
+ html?: boolean | undefined
15
+
16
+ /**
17
+ * Set `true` to add '/' when closing single tags
18
+ * (`<br />`). This is needed only for full CommonMark compatibility. In real
19
+ * world you will need HTML output.
20
+ * @default false
21
+ */
22
+ xhtmlOut?: boolean | undefined
23
+
24
+ /**
25
+ * Set `true` to convert `\n` in paragraphs into `<br>`.
26
+ * @default false
27
+ */
28
+ breaks?: boolean | undefined
29
+
30
+ /**
31
+ * CSS language class prefix for fenced blocks.
32
+ * Can be useful for external highlighters.
33
+ * @default 'language-'
34
+ */
35
+ langPrefix?: string | undefined
36
+
37
+ /**
38
+ * Set `true` to autoconvert URL-like text to links.
39
+ * @default false
40
+ */
41
+ linkify?: boolean | undefined
42
+
43
+ /**
44
+ * Set `true` to enable [some language-neutral replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
45
+ * quotes beautification (smartquotes).
46
+ * @default false
47
+ */
48
+ typographer?: boolean | undefined
49
+
50
+ /**
51
+ * Double + single quotes replacement
52
+ * pairs, when typographer enabled and smartquotes on. For example, you can
53
+ * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
54
+ * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
55
+ * @default '“”‘’'
56
+ */
57
+ quotes?: string | string[]
58
+
59
+ /**
60
+ * Highlighter function for fenced code blocks.
61
+ * Highlighter `function (str, lang, attrs)` should return escaped HTML. It can
62
+ * also return empty string if the source was not changed and should be escaped
63
+ * externally. If result starts with <pre... internal wrapper is skipped.
64
+ * @default null
65
+ */
66
+ highlight?: ((str: string, lang: string, attrs: string) => string) | null | undefined
67
+ }
68
+
6
69
  export interface UseMarkdownOptions extends MarkdownItOptions {
7
70
  config?: (md: MarkdownIt) => void
8
71
  /** @default false */
@@ -40,6 +103,16 @@ export function useMarkdown({
40
103
  //
41
104
 
42
105
  const md = new MarkdownIt({ html: true, linkify: true, ...options })
106
+
107
+ md.renderer.rules.ordered_list_open = (tokens, idx, options, env, self) => {
108
+ const token = tokens[idx]
109
+ const start = Number(token.attrGet('start')) - 1
110
+ if (start >= 0) {
111
+ token.attrSet('style', `counter-reset: s-medium-counter ${start}`)
112
+ }
113
+ return self.renderToken(tokens, idx, options)
114
+ }
115
+
43
116
  config?.(md)
44
117
 
45
118
  return (source, inline = _inline) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
3
  "type": "module",
4
- "version": "4.26.0",
4
+ "version": "4.28.0",
5
5
  "packageManager": "pnpm@9.15.4",
6
6
  "description": "Vue Components for Global Brain Design System.",
7
7
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",