@bagelink/vue 1.6.43 → 1.6.49
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/bin/experimentalGenTypedRoutes.ts +18 -19
- package/bin/utils.ts +4 -4
- package/dist/components/AddressSearch.vue.d.ts.map +1 -1
- package/dist/components/Alert.vue.d.ts.map +1 -1
- package/dist/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/Card.vue.d.ts.map +1 -1
- package/dist/components/Carousel.vue.d.ts +2 -2
- package/dist/components/Carousel.vue.d.ts.map +1 -1
- package/dist/components/Dropdown.vue.d.ts.map +1 -1
- package/dist/components/Flag.vue.d.ts.map +1 -1
- package/dist/components/IframeVue.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/Loading.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/NavBar.vue.d.ts +1 -1
- package/dist/components/Pill.vue.d.ts.map +1 -1
- package/dist/components/Swiper.vue.d.ts +12 -4
- package/dist/components/Swiper.vue.d.ts.map +1 -1
- package/dist/components/Zoomer.vue.d.ts.map +1 -1
- package/dist/components/analytics/LineChart.vue.d.ts.map +1 -1
- package/dist/components/analytics/PieChart.vue.d.ts +2 -1
- package/dist/components/analytics/PieChart.vue.d.ts.map +1 -1
- package/dist/components/analytics/index.d.ts +1 -1
- package/dist/components/analytics/index.d.ts.map +1 -1
- package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
- package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ColorInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/PasswordInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioGroup.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RangeInput.vue.d.ts +11 -11
- package/dist/components/form/inputs/RichText/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/components/TableGridSelector.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/commands.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TelInput.vue.d.ts.map +1 -1
- package/dist/components/layout/AppContent.vue.d.ts.map +1 -1
- package/dist/components/layout/AppSidebar.vue.d.ts +1 -0
- package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -1
- package/dist/components/layout/Layout.vue.d.ts.map +1 -1
- package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
- package/dist/components/layout/index.d.ts +3 -3
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/lightbox/Lightbox.vue.d.ts.map +1 -1
- package/dist/index.cjs +24 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1530 -1404
- package/dist/plugins/modalTypes.d.ts +1 -8
- package/dist/plugins/modalTypes.d.ts.map +1 -1
- package/dist/plugins/useModal.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -2
- package/src/components/AccordionItem.vue +13 -13
- package/src/components/AddToCalendar.vue +1 -1
- package/src/components/AddressSearch.vue +9 -8
- package/src/components/Alert.vue +2 -1
- package/src/components/Badge.vue +5 -5
- package/src/components/BglVideo.vue +44 -45
- package/src/components/Btn.vue +15 -15
- package/src/components/Card.vue +10 -8
- package/src/components/Carousel.vue +159 -162
- package/src/components/DataPreview.vue +1 -1
- package/src/components/DragOver.vue +6 -6
- package/src/components/Dropdown.vue +39 -38
- package/src/components/Flag.vue +7 -6
- package/src/components/Icon/Icon.vue +22 -22
- package/src/components/IframeVue.vue +5 -5
- package/src/components/Image.vue +17 -17
- package/src/components/ImportData.vue +79 -79
- package/src/components/ListItem.vue +12 -11
- package/src/components/Loading.vue +10 -9
- package/src/components/MapEmbed/Index.vue +24 -24
- package/src/components/Modal.vue +11 -9
- package/src/components/ModalForm.vue +15 -11
- package/src/components/NavBar.vue +6 -6
- package/src/components/Pagination.vue +27 -27
- package/src/components/Pill.vue +11 -12
- package/src/components/Rating.vue +2 -2
- package/src/components/Slider.vue +75 -75
- package/src/components/Spreadsheet/Index.vue +34 -34
- package/src/components/Spreadsheet/SpreadsheetTable.vue +3 -3
- package/src/components/Swiper.vue +4 -4
- package/src/components/Zoomer.vue +282 -182
- package/src/components/analytics/BarChart.vue +6 -6
- package/src/components/analytics/KpiCard.vue +2 -2
- package/src/components/analytics/LineChart.vue +63 -61
- package/src/components/analytics/PieChart.vue +104 -90
- package/src/components/analytics/index.ts +2 -2
- package/src/components/calendar/CalendarPopover.vue +1 -1
- package/src/components/calendar/Index.vue +1 -1
- package/src/components/calendar/views/AgendaView.vue +3 -3
- package/src/components/calendar/views/DayView.vue +6 -6
- package/src/components/calendar/views/MonthView.vue +2 -2
- package/src/components/calendar/views/WeekView.vue +18 -18
- package/src/components/dataTable/DataTable.vue +4 -4
- package/src/components/dataTable/useSorting.ts +1 -1
- package/src/components/dataTable/useTableData.ts +15 -15
- package/src/components/dataTable/useTableSelection.ts +15 -15
- package/src/components/dataTable/useTableVirtualization.ts +1 -1
- package/src/components/draggable/useDraggable.ts +42 -42
- package/src/components/form/BagelForm.vue +15 -15
- package/src/components/form/BglFieldSet.vue +5 -3
- package/src/components/form/BglMultiStepForm.vue +20 -21
- package/src/components/form/inputs/CheckInput.vue +2 -2
- package/src/components/form/inputs/CodeEditor/format.ts +7 -7
- package/src/components/form/inputs/CodeEditor/useHighlight.ts +6 -6
- package/src/components/form/inputs/ColorInput.vue +5 -4
- package/src/components/form/inputs/DateInput.vue +8 -9
- package/src/components/form/inputs/DatePicker.vue +24 -24
- package/src/components/form/inputs/EmailInput.vue +24 -24
- package/src/components/form/inputs/NumberInput.vue +26 -26
- package/src/components/form/inputs/OTP.vue +7 -7
- package/src/components/form/inputs/PasswordInput.vue +3 -2
- package/src/components/form/inputs/RadioGroup.vue +28 -25
- package/src/components/form/inputs/RadioPillsInput.vue +12 -12
- package/src/components/form/inputs/RangeInput.vue +21 -21
- package/src/components/form/inputs/RichText/components/EditorToolbar.vue +107 -92
- package/src/components/form/inputs/RichText/components/TableGridSelector.vue +64 -64
- package/src/components/form/inputs/RichText/components/gridBox.vue +10 -8
- package/src/components/form/inputs/RichText/composables/useCommands.ts +1 -1
- package/src/components/form/inputs/RichText/composables/useEditor.ts +12 -12
- package/src/components/form/inputs/RichText/composables/useEditorKeyboard.ts +1 -1
- package/src/components/form/inputs/RichText/index.vue +138 -138
- package/src/components/form/inputs/RichText/utils/commands.ts +84 -85
- package/src/components/form/inputs/RichText/utils/debug.ts +1 -1
- package/src/components/form/inputs/RichText/utils/formatting.ts +39 -39
- package/src/components/form/inputs/RichText/utils/media.ts +7 -7
- package/src/components/form/inputs/RichText/utils/selection.ts +28 -28
- package/src/components/form/inputs/RichText/utils/table.ts +19 -19
- package/src/components/form/inputs/SelectBtn.vue +1 -1
- package/src/components/form/inputs/SelectInput.vue +54 -54
- package/src/components/form/inputs/SignaturePad.vue +40 -40
- package/src/components/form/inputs/TableField.vue +1 -1
- package/src/components/form/inputs/TelInput.vue +54 -53
- package/src/components/form/inputs/TextInput.vue +19 -19
- package/src/components/form/inputs/ToggleInput.vue +2 -2
- package/src/components/form/inputs/Upload/useFileUpload.ts +6 -6
- package/src/components/form/useBagelFormState.ts +5 -5
- package/src/components/layout/AppContent.vue +6 -3
- package/src/components/layout/AppLayout.vue +2 -2
- package/src/components/layout/AppSidebar.vue +83 -16
- package/src/components/layout/Layout.vue +12 -10
- package/src/components/layout/SidebarMenu.vue +4 -4
- package/src/components/layout/TabbedLayout.vue +17 -17
- package/src/components/layout/Tabs.vue +4 -5
- package/src/components/layout/TabsNav.vue +14 -14
- package/src/components/layout/index.ts +3 -5
- package/src/components/lightbox/Lightbox.vue +276 -126
- package/src/components/lightbox/index.ts +8 -8
- package/src/composables/index.ts +8 -8
- package/src/composables/useAddToCalendar.ts +13 -13
- package/src/composables/useDevice.ts +2 -2
- package/src/composables/useFormField.ts +4 -4
- package/src/composables/usePolling.ts +8 -8
- package/src/composables/useSchemaField.ts +38 -38
- package/src/composables/useTheme.ts +9 -9
- package/src/composables/useValidateFieldValue.ts +2 -2
- package/src/directives/pattern.ts +25 -25
- package/src/directives/ripple.ts +4 -4
- package/src/directives/vResize.ts +6 -6
- package/src/index.ts +1 -0
- package/src/plugins/bagel.ts +4 -4
- package/src/plugins/modalTypes.ts +1 -8
- package/src/plugins/useModal.ts +43 -18
- package/src/styles/layout.css +1 -1
- package/src/types/index.ts +1 -1
- package/src/utils/BagelFormUtils.ts +7 -7
- package/src/utils/calendar/Helpers.ts +8 -8
- package/src/utils/calendar/dateUtils.ts +22 -22
- package/src/utils/calendar/time.ts +25 -25
- package/src/utils/calendar/week.ts +25 -25
- package/src/utils/elementUtils.ts +27 -27
- package/src/utils/sizeParsing.ts +2 -2
- package/src/utils/strings.ts +5 -5
- package/src/utils/tapDetector.ts +11 -11
- package/src/utils/useSearch.ts +29 -29
- package/vite.config.ts +0 -2
|
@@ -21,10 +21,10 @@ export interface CommandExecutor {
|
|
|
21
21
|
|
|
22
22
|
// Helper functions
|
|
23
23
|
function getCurrentSelection(state: EditorState): { selection: Selection, range: Range } | null {
|
|
24
|
-
if (!state.doc) {return null}
|
|
24
|
+
if (!state.doc) { return null }
|
|
25
25
|
|
|
26
26
|
const selection = state.doc.getSelection()
|
|
27
|
-
if (!selection || !selection.rangeCount) {return null}
|
|
27
|
+
if (!selection || !selection.rangeCount) { return null }
|
|
28
28
|
|
|
29
29
|
const range = selection.getRangeAt(0)
|
|
30
30
|
return { selection, range }
|
|
@@ -32,7 +32,7 @@ function getCurrentSelection(state: EditorState): { selection: Selection, range:
|
|
|
32
32
|
|
|
33
33
|
// Alternative helper function to apply formatting to word at cursor
|
|
34
34
|
function applyFormattingToWordAtCursor(doc: Document, range: Range, tagName: string): boolean {
|
|
35
|
-
if (!range.collapsed) {return false}
|
|
35
|
+
if (!range.collapsed) { return false }
|
|
36
36
|
|
|
37
37
|
let textNode = range.startContainer
|
|
38
38
|
let offset = range.startOffset
|
|
@@ -40,7 +40,7 @@ function applyFormattingToWordAtCursor(doc: Document, range: Range, tagName: str
|
|
|
40
40
|
// If we're in an element node, try to find a text node
|
|
41
41
|
if (textNode.nodeType !== Node.TEXT_NODE) {
|
|
42
42
|
const element = textNode as Element
|
|
43
|
-
if (
|
|
43
|
+
if (element.childNodes.length > 0 && offset < element.childNodes.length) {
|
|
44
44
|
const childNode = element.childNodes[offset]
|
|
45
45
|
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
46
46
|
textNode = childNode
|
|
@@ -54,7 +54,7 @@ function applyFormattingToWordAtCursor(doc: Document, range: Range, tagName: str
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Check if we're already inside a formatting element
|
|
57
|
-
const parentElement = textNode
|
|
57
|
+
const { parentElement } = textNode
|
|
58
58
|
const existingFormatElement = parentElement?.closest(tagName.toLowerCase())
|
|
59
59
|
|
|
60
60
|
if (existingFormatElement) {
|
|
@@ -88,7 +88,7 @@ function applyFormattingToWordAtCursor(doc: Document, range: Range, tagName: str
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const text = textNode.textContent || ''
|
|
91
|
-
if (!text) {return false}
|
|
91
|
+
if (!text) { return false }
|
|
92
92
|
|
|
93
93
|
// Find word boundaries - support Hebrew, English, and numbers
|
|
94
94
|
let start = offset
|
|
@@ -99,14 +99,14 @@ function applyFormattingToWordAtCursor(doc: Document, range: Range, tagName: str
|
|
|
99
99
|
|
|
100
100
|
// If we're at the end of a word (cursor right after the last character)
|
|
101
101
|
// move back one position to include that word
|
|
102
|
-
if (
|
|
103
|
-
(offset >= text.length || !wordChar.test(text[offset]))) {
|
|
102
|
+
if (offset > 0 && wordChar.test(text[offset - 1])
|
|
103
|
+
&& (offset >= text.length || !wordChar.test(text[offset]))) {
|
|
104
104
|
start = offset - 1
|
|
105
105
|
end = offset - 1
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// Move start backwards to find word beginning
|
|
109
|
-
while (
|
|
109
|
+
while (start > 0 && wordChar.test(text[start - 1])) {
|
|
110
110
|
start--
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -167,14 +167,14 @@ function applyFormattingToWordAtCursor(doc: Document, range: Range, tagName: str
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function updateStateAfterCommand(state: EditorState) {
|
|
170
|
-
if (!state.doc) {return}
|
|
170
|
+
if (!state.doc) { return }
|
|
171
171
|
|
|
172
172
|
// Update content
|
|
173
173
|
state.content = state.doc.body.innerHTML
|
|
174
174
|
|
|
175
175
|
// Update selection state
|
|
176
176
|
const selection = state.doc.getSelection()
|
|
177
|
-
if (selection &&
|
|
177
|
+
if (selection && selection.rangeCount > 0) {
|
|
178
178
|
state.selection = selection
|
|
179
179
|
state.range = selection.getRangeAt(0).cloneRange()
|
|
180
180
|
state.rangeCount = selection.rangeCount
|
|
@@ -197,7 +197,7 @@ function createCommand(name: string, execute: Command['execute'], isActive?: Com
|
|
|
197
197
|
return {
|
|
198
198
|
name,
|
|
199
199
|
execute: (state: EditorState, value?: string) => {
|
|
200
|
-
if (!state.doc) {return}
|
|
200
|
+
if (!state.doc) { return }
|
|
201
201
|
execute(state, value)
|
|
202
202
|
updateStateAfterCommand(state)
|
|
203
203
|
},
|
|
@@ -209,7 +209,7 @@ export function createCommandRegistry(state: EditorState): CommandRegistry {
|
|
|
209
209
|
// History commands
|
|
210
210
|
const historyCommands = {
|
|
211
211
|
undo: createCommand('Undo', () => {
|
|
212
|
-
if (
|
|
212
|
+
if (state.undoStack.length > 0 && state.doc) {
|
|
213
213
|
const lastContent = state.undoStack.pop()
|
|
214
214
|
if (lastContent !== undefined) {
|
|
215
215
|
state.redoStack.push(state.content)
|
|
@@ -219,7 +219,7 @@ export function createCommandRegistry(state: EditorState): CommandRegistry {
|
|
|
219
219
|
}
|
|
220
220
|
}),
|
|
221
221
|
redo: createCommand('Redo', () => {
|
|
222
|
-
if (
|
|
222
|
+
if (state.redoStack.length > 0 && state.doc) {
|
|
223
223
|
const nextContent = state.redoStack.pop()
|
|
224
224
|
if (nextContent !== undefined) {
|
|
225
225
|
state.undoStack.push(state.content)
|
|
@@ -234,15 +234,15 @@ export function createCommandRegistry(state: EditorState): CommandRegistry {
|
|
|
234
234
|
const textCommands = {
|
|
235
235
|
bold: createCommand('Bold', (state) => {
|
|
236
236
|
const selectionInfo = getCurrentSelection(state)
|
|
237
|
-
if (!selectionInfo) {return}
|
|
237
|
+
if (!selectionInfo) { return }
|
|
238
238
|
|
|
239
239
|
let { range, selection } = selectionInfo
|
|
240
240
|
|
|
241
241
|
// If no text is selected, try to apply formatting to word at cursor
|
|
242
242
|
if (range.collapsed) {
|
|
243
243
|
const success = applyFormattingToWordAtCursor(state.doc!, range, 'b')
|
|
244
|
-
if (success) {return}
|
|
245
|
-
return
|
|
244
|
+
if (success) { return }
|
|
245
|
+
return
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
// Check if the selection is already bold
|
|
@@ -291,7 +291,7 @@ return
|
|
|
291
291
|
}, (state) => {
|
|
292
292
|
// isActive function for bold
|
|
293
293
|
const selectionInfo = getCurrentSelection(state)
|
|
294
|
-
if (!selectionInfo) {return false}
|
|
294
|
+
if (!selectionInfo) { return false }
|
|
295
295
|
|
|
296
296
|
const commonAncestor = selectionInfo.range.commonAncestorContainer
|
|
297
297
|
const parentElement = commonAncestor.nodeType === Node.TEXT_NODE
|
|
@@ -303,15 +303,15 @@ return
|
|
|
303
303
|
|
|
304
304
|
italic: createCommand('Italic', (state) => {
|
|
305
305
|
const selectionInfo = getCurrentSelection(state)
|
|
306
|
-
if (!selectionInfo) {return}
|
|
306
|
+
if (!selectionInfo) { return }
|
|
307
307
|
|
|
308
308
|
let { range, selection } = selectionInfo
|
|
309
309
|
|
|
310
310
|
// If no text is selected, try to apply formatting to word at cursor
|
|
311
311
|
if (range.collapsed) {
|
|
312
312
|
const success = applyFormattingToWordAtCursor(state.doc!, range, 'i')
|
|
313
|
-
if (success) {return}
|
|
314
|
-
return
|
|
313
|
+
if (success) { return }
|
|
314
|
+
return
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
// Check if the selection is already italic
|
|
@@ -360,7 +360,7 @@ return
|
|
|
360
360
|
}, (state) => {
|
|
361
361
|
// isActive function for italic
|
|
362
362
|
const selectionInfo = getCurrentSelection(state)
|
|
363
|
-
if (!selectionInfo) {return false}
|
|
363
|
+
if (!selectionInfo) { return false }
|
|
364
364
|
|
|
365
365
|
const commonAncestor = selectionInfo.range.commonAncestorContainer
|
|
366
366
|
const parentElement = commonAncestor.nodeType === Node.TEXT_NODE
|
|
@@ -372,15 +372,15 @@ return
|
|
|
372
372
|
|
|
373
373
|
underline: createCommand('Underline', (state) => {
|
|
374
374
|
const selectionInfo = getCurrentSelection(state)
|
|
375
|
-
if (!selectionInfo) {return}
|
|
375
|
+
if (!selectionInfo) { return }
|
|
376
376
|
|
|
377
377
|
let { range, selection } = selectionInfo
|
|
378
378
|
|
|
379
379
|
// If no text is selected, try to apply formatting to word at cursor
|
|
380
380
|
if (range.collapsed) {
|
|
381
381
|
const success = applyFormattingToWordAtCursor(state.doc!, range, 'u')
|
|
382
|
-
if (success) {return}
|
|
383
|
-
return
|
|
382
|
+
if (success) { return }
|
|
383
|
+
return
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
// Check if the selection is already underlined
|
|
@@ -429,7 +429,7 @@ return
|
|
|
429
429
|
}, (state) => {
|
|
430
430
|
// isActive function for underline
|
|
431
431
|
const selectionInfo = getCurrentSelection(state)
|
|
432
|
-
if (!selectionInfo) {return false}
|
|
432
|
+
if (!selectionInfo) { return false }
|
|
433
433
|
|
|
434
434
|
const commonAncestor = selectionInfo.range.commonAncestorContainer
|
|
435
435
|
const parentElement = commonAncestor.nodeType === Node.TEXT_NODE
|
|
@@ -440,14 +440,14 @@ return
|
|
|
440
440
|
}),
|
|
441
441
|
|
|
442
442
|
link: createCommand('Link', (state) => {
|
|
443
|
-
const openLinkModal =
|
|
443
|
+
const { openLinkModal } = state as any
|
|
444
444
|
if (openLinkModal) {
|
|
445
445
|
insertLink(openLinkModal, state)
|
|
446
446
|
}
|
|
447
447
|
}, (state) => {
|
|
448
448
|
// isActive function for link
|
|
449
449
|
const selectionInfo = getCurrentSelection(state)
|
|
450
|
-
if (!selectionInfo) {return false}
|
|
450
|
+
if (!selectionInfo) { return false }
|
|
451
451
|
|
|
452
452
|
const commonAncestor = selectionInfo.range.commonAncestorContainer
|
|
453
453
|
const parentElement = commonAncestor.nodeType === Node.TEXT_NODE
|
|
@@ -463,17 +463,17 @@ return
|
|
|
463
463
|
...acc,
|
|
464
464
|
[cmd]: createCommand(`Heading ${cmd}`, (state) => {
|
|
465
465
|
const selectionInfo = getCurrentSelection(state)
|
|
466
|
-
if (!selectionInfo) {return}
|
|
466
|
+
if (!selectionInfo) { return }
|
|
467
467
|
|
|
468
468
|
const { range, selection } = selectionInfo
|
|
469
469
|
const currentBlock = findBlockElement(range.commonAncestorContainer)
|
|
470
|
-
if (!currentBlock) {return}
|
|
470
|
+
if (!currentBlock) { return }
|
|
471
471
|
|
|
472
472
|
// Store the original selection information before modification
|
|
473
|
-
const startContainer = range
|
|
474
|
-
const endContainer = range
|
|
475
|
-
const startOffset = range
|
|
476
|
-
const endOffset = range
|
|
473
|
+
const { startContainer } = range
|
|
474
|
+
const { endContainer } = range
|
|
475
|
+
const { startOffset } = range
|
|
476
|
+
const { endOffset } = range
|
|
477
477
|
const isCollapsed = range.collapsed
|
|
478
478
|
|
|
479
479
|
// Check if we need to toggle off (already in the same heading)
|
|
@@ -497,7 +497,7 @@ return
|
|
|
497
497
|
|
|
498
498
|
// Find corresponding nodes in the new block
|
|
499
499
|
const findCorrespondingNode = (originalNode: Node, originalBlock: Element, newBlock: Element): Node | null => {
|
|
500
|
-
if (originalNode === originalBlock) {return newBlock}
|
|
500
|
+
if (originalNode === originalBlock) { return newBlock }
|
|
501
501
|
|
|
502
502
|
// If it's a text node, find it by traversing the tree
|
|
503
503
|
if (originalNode.nodeType === Node.TEXT_NODE) {
|
|
@@ -589,7 +589,6 @@ return
|
|
|
589
589
|
newBlock.parentNode?.insertBefore(p, newBlock.nextSibling)
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
-
|
|
593
592
|
} catch (error) {
|
|
594
593
|
console.error(`Error applying ${cmd} heading:`, error)
|
|
595
594
|
}
|
|
@@ -600,14 +599,14 @@ return
|
|
|
600
599
|
const blockCommands = {
|
|
601
600
|
p: createCommand('Paragraph', (state) => {
|
|
602
601
|
const selectionInfo = getCurrentSelection(state)
|
|
603
|
-
if (!selectionInfo) {return}
|
|
602
|
+
if (!selectionInfo) { return }
|
|
604
603
|
|
|
605
604
|
const { range } = selectionInfo
|
|
606
605
|
const currentBlock = findBlockElement(range.commonAncestorContainer)
|
|
607
|
-
if (!currentBlock) {return}
|
|
606
|
+
if (!currentBlock) { return }
|
|
608
607
|
|
|
609
608
|
// Check if already a paragraph - if so, nothing to do
|
|
610
|
-
if (
|
|
609
|
+
if (currentBlock.tagName.toLowerCase() === 'p') {
|
|
611
610
|
return
|
|
612
611
|
}
|
|
613
612
|
|
|
@@ -634,14 +633,14 @@ return
|
|
|
634
633
|
|
|
635
634
|
blockquote: createCommand('Blockquote', (state) => {
|
|
636
635
|
const selectionInfo = getCurrentSelection(state)
|
|
637
|
-
if (!selectionInfo) {return}
|
|
636
|
+
if (!selectionInfo) { return }
|
|
638
637
|
|
|
639
638
|
const { range } = selectionInfo
|
|
640
639
|
const currentBlock = findBlockElement(range.commonAncestorContainer)
|
|
641
|
-
if (!currentBlock) {return}
|
|
640
|
+
if (!currentBlock) { return }
|
|
642
641
|
|
|
643
642
|
// Check if already a blockquote - if so, toggle to paragraph
|
|
644
|
-
const isToggleOff =
|
|
643
|
+
const isToggleOff = currentBlock.tagName.toLowerCase() === 'blockquote'
|
|
645
644
|
const newTag = isToggleOff ? 'p' : 'blockquote'
|
|
646
645
|
|
|
647
646
|
try {
|
|
@@ -670,20 +669,20 @@ return
|
|
|
670
669
|
const listCommands = {
|
|
671
670
|
orderedList: createCommand('Ordered List', (state) => {
|
|
672
671
|
const selectionInfo = getCurrentSelection(state)
|
|
673
|
-
if (!selectionInfo) {return}
|
|
672
|
+
if (!selectionInfo) { return }
|
|
674
673
|
|
|
675
674
|
const { range } = selectionInfo
|
|
676
675
|
const currentBlock = findBlockElement(range.commonAncestorContainer)
|
|
677
|
-
if (!currentBlock) {return}
|
|
676
|
+
if (!currentBlock) { return }
|
|
678
677
|
|
|
679
678
|
// Check if we're inside a list item
|
|
680
679
|
const listItem = currentBlock.closest('li')
|
|
681
680
|
if (listItem) {
|
|
682
681
|
const listParent = listItem.parentElement as HTMLElement
|
|
683
|
-
if (!listParent) {return}
|
|
682
|
+
if (!listParent) { return }
|
|
684
683
|
|
|
685
684
|
// If it's already an ordered list, toggle off to paragraph
|
|
686
|
-
if (
|
|
685
|
+
if (listParent.tagName.toLowerCase() === 'ol') {
|
|
687
686
|
const p = state.doc!.createElement('p')
|
|
688
687
|
while (listItem.firstChild) {
|
|
689
688
|
p.appendChild(listItem.firstChild)
|
|
@@ -703,7 +702,7 @@ return
|
|
|
703
702
|
}
|
|
704
703
|
|
|
705
704
|
// Convert unordered list to ordered list
|
|
706
|
-
if (
|
|
705
|
+
if (listParent.tagName.toLowerCase() === 'ul') {
|
|
707
706
|
const ol = state.doc!.createElement('ol')
|
|
708
707
|
|
|
709
708
|
// Store current cursor position before conversion
|
|
@@ -762,20 +761,20 @@ return
|
|
|
762
761
|
|
|
763
762
|
unorderedList: createCommand('Unordered List', (state) => {
|
|
764
763
|
const selectionInfo = getCurrentSelection(state)
|
|
765
|
-
if (!selectionInfo) {return}
|
|
764
|
+
if (!selectionInfo) { return }
|
|
766
765
|
|
|
767
766
|
const { range } = selectionInfo
|
|
768
767
|
const currentBlock = findBlockElement(range.commonAncestorContainer)
|
|
769
|
-
if (!currentBlock) {return}
|
|
768
|
+
if (!currentBlock) { return }
|
|
770
769
|
|
|
771
770
|
// Check if we're inside a list item
|
|
772
771
|
const listItem = currentBlock.closest('li')
|
|
773
772
|
if (listItem) {
|
|
774
773
|
const listParent = listItem.parentElement as HTMLElement
|
|
775
|
-
if (!listParent) {return}
|
|
774
|
+
if (!listParent) { return }
|
|
776
775
|
|
|
777
776
|
// If it's already an unordered list, toggle off to paragraph
|
|
778
|
-
if (
|
|
777
|
+
if (listParent.tagName.toLowerCase() === 'ul') {
|
|
779
778
|
const p = state.doc!.createElement('p')
|
|
780
779
|
while (listItem.firstChild) {
|
|
781
780
|
p.appendChild(listItem.firstChild)
|
|
@@ -795,7 +794,7 @@ return
|
|
|
795
794
|
}
|
|
796
795
|
|
|
797
796
|
// Convert ordered list to unordered list
|
|
798
|
-
if (
|
|
797
|
+
if (listParent.tagName.toLowerCase() === 'ol') {
|
|
799
798
|
const ul = state.doc!.createElement('ul')
|
|
800
799
|
|
|
801
800
|
// Store current cursor position before conversion
|
|
@@ -858,7 +857,7 @@ return
|
|
|
858
857
|
const formatCommands = {
|
|
859
858
|
clear: createCommand('Clear Formatting', (state) => {
|
|
860
859
|
const selectionInfo = getCurrentSelection(state)
|
|
861
|
-
if (!selectionInfo) {return}
|
|
860
|
+
if (!selectionInfo) { return }
|
|
862
861
|
|
|
863
862
|
const { range, selection } = selectionInfo
|
|
864
863
|
|
|
@@ -871,7 +870,7 @@ return
|
|
|
871
870
|
// Remove extra whitespace
|
|
872
871
|
.replace(/\s+/g, ' ')
|
|
873
872
|
// Remove invisible characters
|
|
874
|
-
.replace(
|
|
873
|
+
.replace(/\u00A0/g, ' ') // non-breaking space to regular space
|
|
875
874
|
.trim()
|
|
876
875
|
}
|
|
877
876
|
|
|
@@ -895,7 +894,7 @@ return
|
|
|
895
894
|
// For formatting elements, just return the cleaned text content
|
|
896
895
|
const cleanedText = cleanText(element.textContent || '')
|
|
897
896
|
return state.doc!.createTextNode(cleanedText)
|
|
898
|
-
}if (structuralTags.includes(tagName)) {
|
|
897
|
+
} if (structuralTags.includes(tagName)) {
|
|
899
898
|
// For structural elements, keep the element but remove all styling attributes
|
|
900
899
|
const cleanElement = state.doc!.createElement(tagName)
|
|
901
900
|
|
|
@@ -943,7 +942,7 @@ return
|
|
|
943
942
|
|
|
944
943
|
if (range.collapsed) {
|
|
945
944
|
// If no selection, clean the entire document
|
|
946
|
-
const body = state.doc
|
|
945
|
+
const { body } = (state.doc!)
|
|
947
946
|
const cleanedFragment = state.doc!.createDocumentFragment()
|
|
948
947
|
|
|
949
948
|
Array.from(body.childNodes).forEach((node) => {
|
|
@@ -1007,7 +1006,7 @@ return
|
|
|
1007
1006
|
// If we have an openTableEditor function in state, use it for new tables
|
|
1008
1007
|
if ((state as any).openTableEditor && !value) {
|
|
1009
1008
|
console.log('Opening table editor modal for new table')
|
|
1010
|
-
|
|
1009
|
+
; (state as any).openTableEditor(null)
|
|
1011
1010
|
return
|
|
1012
1011
|
}
|
|
1013
1012
|
|
|
@@ -1078,10 +1077,10 @@ return
|
|
|
1078
1077
|
// Table alignment commands
|
|
1079
1078
|
const alignmentCommands = ['Left', 'Center', 'Right', 'Justify'].reduce((acc, align) => ({
|
|
1080
1079
|
...acc,
|
|
1081
|
-
[`tableAlign${align}`]: createCommand(`Table Align ${align}`, state => {
|
|
1080
|
+
[`tableAlign${align}`]: createCommand(`Table Align ${align}`, (state) => {
|
|
1082
1081
|
if (state.range) {
|
|
1083
|
-
const alignment = 'Left'
|
|
1084
|
-
|
|
1082
|
+
const alignment = align === 'Left' ? 'start' : align === 'Right' ? 'end' : align.toLowerCase() as 'center' | 'justify'
|
|
1083
|
+
alignColumn(state.range, alignment)
|
|
1085
1084
|
}
|
|
1086
1085
|
})
|
|
1087
1086
|
}), {})
|
|
@@ -1090,7 +1089,7 @@ return
|
|
|
1090
1089
|
const textAlignmentCommands = {
|
|
1091
1090
|
alignLeft: createCommand('Align Left', (state) => {
|
|
1092
1091
|
const selectionInfo = getCurrentSelection(state)
|
|
1093
|
-
if (!selectionInfo) {return}
|
|
1092
|
+
if (!selectionInfo) { return }
|
|
1094
1093
|
|
|
1095
1094
|
const { range } = selectionInfo
|
|
1096
1095
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
@@ -1102,19 +1101,19 @@ return
|
|
|
1102
1101
|
}
|
|
1103
1102
|
}, (state) => {
|
|
1104
1103
|
const selectionInfo = getCurrentSelection(state)
|
|
1105
|
-
if (!selectionInfo) {return false}
|
|
1104
|
+
if (!selectionInfo) { return false }
|
|
1106
1105
|
|
|
1107
1106
|
const { range } = selectionInfo
|
|
1108
1107
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
1109
1108
|
? range.startContainer.parentElement?.closest('p, h1, h2, h3, h4, h5, h6')
|
|
1110
1109
|
: (range.startContainer as Element).closest('p, h1, h2, h3, h4, h5, h6')
|
|
1111
1110
|
|
|
1112
|
-
return
|
|
1111
|
+
return (paragraph as HTMLElement)?.style.textAlign === 'left'
|
|
1113
1112
|
}),
|
|
1114
1113
|
|
|
1115
1114
|
alignCenter: createCommand('Align Center', (state) => {
|
|
1116
1115
|
const selectionInfo = getCurrentSelection(state)
|
|
1117
|
-
if (!selectionInfo) {return}
|
|
1116
|
+
if (!selectionInfo) { return }
|
|
1118
1117
|
|
|
1119
1118
|
const { range } = selectionInfo
|
|
1120
1119
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
@@ -1126,19 +1125,19 @@ return
|
|
|
1126
1125
|
}
|
|
1127
1126
|
}, (state) => {
|
|
1128
1127
|
const selectionInfo = getCurrentSelection(state)
|
|
1129
|
-
if (!selectionInfo) {return false}
|
|
1128
|
+
if (!selectionInfo) { return false }
|
|
1130
1129
|
|
|
1131
1130
|
const { range } = selectionInfo
|
|
1132
1131
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
1133
1132
|
? range.startContainer.parentElement?.closest('p, h1, h2, h3, h4, h5, h6')
|
|
1134
1133
|
: (range.startContainer as Element).closest('p, h1, h2, h3, h4, h5, h6')
|
|
1135
1134
|
|
|
1136
|
-
return
|
|
1135
|
+
return (paragraph as HTMLElement)?.style.textAlign === 'center'
|
|
1137
1136
|
}),
|
|
1138
1137
|
|
|
1139
1138
|
alignRight: createCommand('Align Right', (state) => {
|
|
1140
1139
|
const selectionInfo = getCurrentSelection(state)
|
|
1141
|
-
if (!selectionInfo) {return}
|
|
1140
|
+
if (!selectionInfo) { return }
|
|
1142
1141
|
|
|
1143
1142
|
const { range } = selectionInfo
|
|
1144
1143
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
@@ -1150,19 +1149,19 @@ return
|
|
|
1150
1149
|
}
|
|
1151
1150
|
}, (state) => {
|
|
1152
1151
|
const selectionInfo = getCurrentSelection(state)
|
|
1153
|
-
if (!selectionInfo) {return false}
|
|
1152
|
+
if (!selectionInfo) { return false }
|
|
1154
1153
|
|
|
1155
1154
|
const { range } = selectionInfo
|
|
1156
1155
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
1157
1156
|
? range.startContainer.parentElement?.closest('p, h1, h2, h3, h4, h5, h6')
|
|
1158
1157
|
: (range.startContainer as Element).closest('p, h1, h2, h3, h4, h5, h6')
|
|
1159
1158
|
|
|
1160
|
-
return
|
|
1159
|
+
return (paragraph as HTMLElement)?.style.textAlign === 'right'
|
|
1161
1160
|
}),
|
|
1162
1161
|
|
|
1163
1162
|
alignJustify: createCommand('Align Justify', (state) => {
|
|
1164
1163
|
const selectionInfo = getCurrentSelection(state)
|
|
1165
|
-
if (!selectionInfo) {return}
|
|
1164
|
+
if (!selectionInfo) { return }
|
|
1166
1165
|
|
|
1167
1166
|
const { range } = selectionInfo
|
|
1168
1167
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
@@ -1174,19 +1173,19 @@ return
|
|
|
1174
1173
|
}
|
|
1175
1174
|
}, (state) => {
|
|
1176
1175
|
const selectionInfo = getCurrentSelection(state)
|
|
1177
|
-
if (!selectionInfo) {return false}
|
|
1176
|
+
if (!selectionInfo) { return false }
|
|
1178
1177
|
|
|
1179
1178
|
const { range } = selectionInfo
|
|
1180
1179
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
1181
1180
|
? range.startContainer.parentElement?.closest('p, h1, h2, h3, h4, h5, h6')
|
|
1182
1181
|
: (range.startContainer as Element).closest('p, h1, h2, h3, h4, h5, h6')
|
|
1183
1182
|
|
|
1184
|
-
return
|
|
1183
|
+
return (paragraph as HTMLElement)?.style.textAlign === 'justify'
|
|
1185
1184
|
}),
|
|
1186
1185
|
|
|
1187
1186
|
textDirection: createCommand('Toggle Text Direction', (state) => {
|
|
1188
1187
|
const selectionInfo = getCurrentSelection(state)
|
|
1189
|
-
if (!selectionInfo) {return}
|
|
1188
|
+
if (!selectionInfo) { return }
|
|
1190
1189
|
|
|
1191
1190
|
const { range } = selectionInfo
|
|
1192
1191
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
@@ -1195,23 +1194,23 @@ return
|
|
|
1195
1194
|
|
|
1196
1195
|
if (paragraph) {
|
|
1197
1196
|
const currentDir = (paragraph as HTMLElement).dir || 'ltr'
|
|
1198
|
-
; (paragraph as HTMLElement).dir = 'ltr'
|
|
1197
|
+
; (paragraph as HTMLElement).dir = currentDir === 'ltr' ? 'rtl' : 'ltr'
|
|
1199
1198
|
}
|
|
1200
1199
|
}, (state) => {
|
|
1201
1200
|
const selectionInfo = getCurrentSelection(state)
|
|
1202
|
-
if (!selectionInfo) {return false}
|
|
1201
|
+
if (!selectionInfo) { return false }
|
|
1203
1202
|
|
|
1204
1203
|
const { range } = selectionInfo
|
|
1205
1204
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
1206
1205
|
? range.startContainer.parentElement?.closest('p, h1, h2, h3, h4, h5, h6')
|
|
1207
1206
|
: (range.startContainer as Element).closest('p, h1, h2, h3, h4, h5, h6')
|
|
1208
1207
|
|
|
1209
|
-
return
|
|
1208
|
+
return (paragraph as HTMLElement)?.dir === 'rtl'
|
|
1210
1209
|
}),
|
|
1211
1210
|
|
|
1212
1211
|
ltrDirection: createCommand('Set Left to Right Direction', (state) => {
|
|
1213
1212
|
const selectionInfo = getCurrentSelection(state)
|
|
1214
|
-
if (!selectionInfo) {return}
|
|
1213
|
+
if (!selectionInfo) { return }
|
|
1215
1214
|
|
|
1216
1215
|
const { range } = selectionInfo
|
|
1217
1216
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
@@ -1223,19 +1222,19 @@ return
|
|
|
1223
1222
|
}
|
|
1224
1223
|
}, (state) => {
|
|
1225
1224
|
const selectionInfo = getCurrentSelection(state)
|
|
1226
|
-
if (!selectionInfo) {return false}
|
|
1225
|
+
if (!selectionInfo) { return false }
|
|
1227
1226
|
|
|
1228
1227
|
const { range } = selectionInfo
|
|
1229
1228
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
1230
1229
|
? range.startContainer.parentElement?.closest('p, h1, h2, h3, h4, h5, h6')
|
|
1231
1230
|
: (range.startContainer as Element).closest('p, h1, h2, h3, h4, h5, h6')
|
|
1232
1231
|
|
|
1233
|
-
return
|
|
1232
|
+
return (paragraph as HTMLElement)?.dir === 'ltr'
|
|
1234
1233
|
}),
|
|
1235
1234
|
|
|
1236
1235
|
rtlDirection: createCommand('Set Right to Left Direction', (state) => {
|
|
1237
1236
|
const selectionInfo = getCurrentSelection(state)
|
|
1238
|
-
if (!selectionInfo) {return}
|
|
1237
|
+
if (!selectionInfo) { return }
|
|
1239
1238
|
|
|
1240
1239
|
const { range } = selectionInfo
|
|
1241
1240
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
@@ -1247,14 +1246,14 @@ return
|
|
|
1247
1246
|
}
|
|
1248
1247
|
}, (state) => {
|
|
1249
1248
|
const selectionInfo = getCurrentSelection(state)
|
|
1250
|
-
if (!selectionInfo) {return false}
|
|
1249
|
+
if (!selectionInfo) { return false }
|
|
1251
1250
|
|
|
1252
1251
|
const { range } = selectionInfo
|
|
1253
1252
|
const paragraph = range.startContainer.nodeType === Node.TEXT_NODE
|
|
1254
1253
|
? range.startContainer.parentElement?.closest('p, h1, h2, h3, h4, h5, h6')
|
|
1255
1254
|
: (range.startContainer as Element).closest('p, h1, h2, h3, h4, h5, h6')
|
|
1256
1255
|
|
|
1257
|
-
return
|
|
1256
|
+
return (paragraph as HTMLElement)?.dir === 'rtl'
|
|
1258
1257
|
})
|
|
1259
1258
|
}
|
|
1260
1259
|
|
|
@@ -1268,7 +1267,7 @@ return
|
|
|
1268
1267
|
// Media commands
|
|
1269
1268
|
const mediaCommands = {
|
|
1270
1269
|
image: createCommand('Insert Image', (state) => {
|
|
1271
|
-
const openImageModal =
|
|
1270
|
+
const { openImageModal } = state as any
|
|
1272
1271
|
if (openImageModal) {
|
|
1273
1272
|
openImageModal()
|
|
1274
1273
|
} else {
|
|
@@ -1276,7 +1275,7 @@ return
|
|
|
1276
1275
|
}
|
|
1277
1276
|
}),
|
|
1278
1277
|
video: createCommand('Insert Video', (state) => {
|
|
1279
|
-
const openVideoModal =
|
|
1278
|
+
const { openVideoModal } = state as any
|
|
1280
1279
|
if (openVideoModal) {
|
|
1281
1280
|
openVideoModal()
|
|
1282
1281
|
} else {
|
|
@@ -1284,7 +1283,7 @@ return
|
|
|
1284
1283
|
}
|
|
1285
1284
|
}),
|
|
1286
1285
|
embed: createCommand('Insert Embed', (state) => {
|
|
1287
|
-
const openEmbedModal =
|
|
1286
|
+
const { openEmbedModal } = state as any
|
|
1288
1287
|
if (openEmbedModal) {
|
|
1289
1288
|
openEmbedModal()
|
|
1290
1289
|
} else {
|
|
@@ -50,7 +50,7 @@ export class EditorDebugger {
|
|
|
50
50
|
|
|
51
51
|
private getNodeDescription(node: Node): string {
|
|
52
52
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
53
|
-
return `Text("${node.textContent?.slice(0, 20)}${node.textContent &&
|
|
53
|
+
return `Text("${node.textContent?.slice(0, 20)}${node.textContent && node.textContent.length > 20 ? '...' : ''}")`
|
|
54
54
|
}
|
|
55
55
|
const element = node as Element
|
|
56
56
|
return `${element.tagName.toLowerCase()}${element.id ? `#${element.id}` : ''}`
|