@bagelink/vue 1.2.13 → 1.2.15
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/form/FieldArray.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/components/gridBox.vue.d.ts +6 -3
- package/dist/components/form/inputs/RichText/components/gridBox.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/composables/useCommands.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/config.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/formatting.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/table.d.ts.map +1 -1
- package/dist/index.cjs +355 -56
- package/dist/index.mjs +355 -56
- package/dist/style.css +3 -3
- package/package.json +1 -1
- package/src/components/form/FieldArray.vue +1 -1
- package/src/components/form/inputs/RichText/components/EditorToolbar.vue +3 -4
- package/src/components/form/inputs/RichText/components/gridBox.vue +4 -1
- package/src/components/form/inputs/RichText/composables/useCommands.ts +22 -3
- package/src/components/form/inputs/RichText/config.ts +9 -7
- package/src/components/form/inputs/RichText/utils/commands.ts +307 -23
- package/src/components/form/inputs/RichText/utils/formatting.ts +117 -17
- package/src/components/form/inputs/RichText/utils/table.ts +36 -1
|
@@ -5,17 +5,52 @@ export function insertTable(rows: number, cols: number, state: EditorState) {
|
|
|
5
5
|
const table = state.doc.createElement('table')
|
|
6
6
|
table.style.width = '100%'
|
|
7
7
|
table.style.borderCollapse = 'collapse'
|
|
8
|
+
table.style.marginBottom = '1rem'
|
|
9
|
+
|
|
10
|
+
// Add a header row
|
|
11
|
+
const thead = state.doc.createElement('thead')
|
|
12
|
+
const headerRow = thead.insertRow()
|
|
13
|
+
for (let j = 0; j < cols; j++) {
|
|
14
|
+
const th = state.doc.createElement('th')
|
|
15
|
+
th.innerHTML = `Header ${j + 1}`
|
|
16
|
+
th.style.padding = '8px'
|
|
17
|
+
th.style.border = '1px solid var(--border-color, #ddd)'
|
|
18
|
+
th.style.backgroundColor = 'var(--bgl-gray-light, #f4f4f4)'
|
|
19
|
+
headerRow.appendChild(th)
|
|
20
|
+
}
|
|
21
|
+
table.appendChild(thead)
|
|
8
22
|
|
|
23
|
+
// Add body rows
|
|
24
|
+
const tbody = state.doc.createElement('tbody')
|
|
9
25
|
for (let i = 0; i < rows; i++) {
|
|
10
|
-
const row =
|
|
26
|
+
const row = tbody.insertRow()
|
|
11
27
|
for (let j = 0; j < cols; j++) {
|
|
12
28
|
const cell = row.insertCell()
|
|
13
29
|
cell.innerHTML = ' '
|
|
30
|
+
cell.style.padding = '8px'
|
|
31
|
+
cell.style.border = '1px solid var(--border-color, #ddd)'
|
|
14
32
|
}
|
|
15
33
|
}
|
|
34
|
+
table.appendChild(tbody)
|
|
35
|
+
|
|
36
|
+
// Insert the table at the current selection
|
|
16
37
|
const { range } = state
|
|
17
38
|
if (range) {
|
|
18
39
|
range.insertNode(table)
|
|
40
|
+
|
|
41
|
+
// Move cursor inside first cell for convenience
|
|
42
|
+
if (state.doc.getSelection()) {
|
|
43
|
+
const firstCell = table.querySelector('td')
|
|
44
|
+
if (firstCell) {
|
|
45
|
+
range.selectNodeContents(firstCell)
|
|
46
|
+
range.collapse(true)
|
|
47
|
+
const selection = state.doc.getSelection()
|
|
48
|
+
if (selection) {
|
|
49
|
+
selection.removeAllRanges()
|
|
50
|
+
selection.addRange(range)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
19
54
|
} else {
|
|
20
55
|
state.doc.body.appendChild(table)
|
|
21
56
|
}
|