@bagelink/vue 1.4.64 → 1.4.71
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/components/NavBar.vue.d.ts.map +1 -1
- package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/dataTable/useTableSelection.d.ts +1 -1
- package/dist/components/dataTable/useTableSelection.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/composables/useCommands.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/composables/useEditor.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/composables/useEditorKeyboard.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts +128 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/commands.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/selection.d.ts.map +1 -1
- package/dist/index.cjs +20 -20
- package/dist/index.mjs +20 -20
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/NavBar.vue +17 -5
- package/src/components/dataTable/DataTable.vue +20 -44
- package/src/components/dataTable/useTableSelection.ts +40 -1
- package/src/components/form/inputs/RichText/composables/useCommands.ts +9 -29
- package/src/components/form/inputs/RichText/composables/useEditor.ts +45 -46
- package/src/components/form/inputs/RichText/composables/useEditorKeyboard.ts +52 -3
- package/src/components/form/inputs/RichText/index.vue +148 -43
- package/src/components/form/inputs/RichText/utils/commands.ts +347 -282
- package/src/components/form/inputs/RichText/utils/selection.ts +55 -37
|
@@ -16,33 +16,57 @@ export function isStyleActive(style: string, doc: Document) {
|
|
|
16
16
|
|
|
17
17
|
if (!parent) return false
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
return checkParent(element.parentElement,
|
|
19
|
+
// Check if the current node or any parent has the style
|
|
20
|
+
const checkParent = (element: Element | null, checker: (el: Element) => boolean): boolean => {
|
|
21
|
+
if (!element) return false
|
|
22
|
+
if (checker(element)) return true
|
|
23
|
+
return checkParent(element.parentElement, checker)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// Define style
|
|
27
|
-
const
|
|
28
|
-
//
|
|
29
|
-
bold:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
// Define style checkers for different formatting types
|
|
27
|
+
const styleCheckers: { [key: string]: (el: Element) => boolean } = {
|
|
28
|
+
// Text formatting - check for elements or inline styles
|
|
29
|
+
bold: (el) => {
|
|
30
|
+
const tagName = el.tagName?.toLowerCase()
|
|
31
|
+
if (tagName === 'strong' || tagName === 'b') return true
|
|
32
|
+
const styles = window.getComputedStyle(el)
|
|
33
|
+
return styles.fontWeight === 'bold' || styles.fontWeight === '700'
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
italic: (el) => {
|
|
37
|
+
const tagName = el.tagName?.toLowerCase()
|
|
38
|
+
if (tagName === 'em' || tagName === 'i') return true
|
|
39
|
+
const styles = window.getComputedStyle(el)
|
|
40
|
+
return styles.fontStyle === 'italic'
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
underline: (el) => {
|
|
44
|
+
const tagName = el.tagName?.toLowerCase()
|
|
45
|
+
if (tagName === 'u') return true
|
|
46
|
+
const styles = window.getComputedStyle(el)
|
|
47
|
+
return styles.textDecoration.includes('underline')
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// Block elements
|
|
51
|
+
h1: el => el.tagName?.toLowerCase() === 'h1',
|
|
52
|
+
h2: el => el.tagName?.toLowerCase() === 'h2',
|
|
53
|
+
h3: el => el.tagName?.toLowerCase() === 'h3',
|
|
54
|
+
h4: el => el.tagName?.toLowerCase() === 'h4',
|
|
55
|
+
h5: el => el.tagName?.toLowerCase() === 'h5',
|
|
56
|
+
h6: el => el.tagName?.toLowerCase() === 'h6',
|
|
57
|
+
p: el => el.tagName?.toLowerCase() === 'p',
|
|
58
|
+
blockquote: el => el.tagName?.toLowerCase() === 'blockquote',
|
|
59
|
+
|
|
60
|
+
// List elements - check if we're inside a list
|
|
61
|
+
orderedList: (el) => {
|
|
62
|
+
// Check if we're inside an ordered list
|
|
63
|
+
return !!el.closest('ol')
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
unorderedList: (el) => {
|
|
67
|
+
// Check if we're inside an unordered list
|
|
68
|
+
return !!el.closest('ul')
|
|
69
|
+
}
|
|
46
70
|
}
|
|
47
71
|
|
|
48
72
|
// Special handling for view state commands
|
|
@@ -50,20 +74,14 @@ export function isStyleActive(style: string, doc: Document) {
|
|
|
50
74
|
return false // These are handled by the editor state directly
|
|
51
75
|
}
|
|
52
76
|
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Check for the style in the style mappings
|
|
60
|
-
const tags = styleMappings[style]
|
|
61
|
-
if (tags) {
|
|
62
|
-
return checkParent(parent, tags)
|
|
77
|
+
// Use the appropriate checker
|
|
78
|
+
const checker = styleCheckers[style]
|
|
79
|
+
if (checker) {
|
|
80
|
+
return checkParent(parent, checker)
|
|
63
81
|
}
|
|
64
82
|
|
|
65
|
-
//
|
|
66
|
-
return checkParent(parent,
|
|
83
|
+
// Fallback: check if element matches the style tag name
|
|
84
|
+
return checkParent(parent, el => el.tagName?.toLowerCase() === style.toLowerCase())
|
|
67
85
|
}
|
|
68
86
|
|
|
69
87
|
export interface SelectionInfo {
|