frappe-ui 0.1.270 → 0.1.271

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frappe-ui",
3
- "version": "0.1.270",
3
+ "version": "0.1.271",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -7,7 +7,7 @@
7
7
  </Button>
8
8
  </DropdownMenuTrigger>
9
9
 
10
- <DropdownMenuPortal>
10
+ <DropdownMenuPortal :to="portalTo">
11
11
  <DropdownMenuContent
12
12
  :class="[
13
13
  cssClasses.dropdownContent,
@@ -100,7 +100,7 @@
100
100
  />
101
101
  </button>
102
102
  </DropdownMenuSubTrigger>
103
- <DropdownMenuPortal>
103
+ <DropdownMenuPortal :to="portalTo">
104
104
  <DropdownMenuSubContent
105
105
  :class="cssClasses.dropdownContent"
106
106
  :side-offset="4"
@@ -282,7 +282,6 @@ defineOptions({
282
282
  })
283
283
 
284
284
  const toggleState = ref(false)
285
- const test = ref(true)
286
285
  const router = useRouter()
287
286
  const attrs = useAttrs()
288
287
 
@@ -291,6 +290,7 @@ const props = withDefaults(defineProps<DropdownProps>(), {
291
290
  placement: 'left',
292
291
  side: 'bottom',
293
292
  offset: 4,
293
+ portalTo: 'body',
294
294
  })
295
295
 
296
296
  function close() {
@@ -434,7 +434,11 @@ const align = computed(() => {
434
434
 
435
435
  defineSlots<{
436
436
  /** Default slot for custom trigger content (receives `open`, `close`, and extra attrs) */
437
- default?: (props: { open: boolean; close: () => void; [key: string]: any }) => any
437
+ default?: (props: {
438
+ open: boolean
439
+ close: () => void
440
+ [key: string]: any
441
+ }) => any
438
442
 
439
443
  /** Custom rendering for each dropdown item (receives `item` and `close`) */
440
444
  item?: (props: { item: DropdownOption; close: () => void }) => any
@@ -44,5 +44,8 @@ export interface DropdownProps {
44
44
 
45
45
  /** Offset in pixels between trigger and dropdown */
46
46
  offset?: number
47
+
48
+ /** Teleport target for dropdown portal content */
49
+ portalTo?: string | HTMLElement
47
50
  }
48
51
 
@@ -121,7 +121,9 @@ export default {
121
121
  .catch((error) => {
122
122
  this.uploading = false
123
123
  let errorMessage = 'Error Uploading File'
124
- if (error?._server_messages) {
124
+ if (error?.message) {
125
+ errorMessage = error.message
126
+ } else if (error?._server_messages) {
125
127
  errorMessage = JSON.parse(
126
128
  JSON.parse(error._server_messages)[0],
127
129
  ).message
@@ -174,6 +174,7 @@ onMounted(() => {
174
174
  }),
175
175
  Table.configure({
176
176
  resizable: true,
177
+ renderWrapper: true,
177
178
  }),
178
179
  TableRow,
179
180
  TableHeader,
@@ -112,7 +112,7 @@ export const NamedColorExtension = Extension.create<ColorOptions>({
112
112
  return {
113
113
  setColorByName:
114
114
  (colorName: string) =>
115
- ({ chain, state, editor }) => {
115
+ ({ chain }) => {
116
116
  // Validate that the color name is allowed
117
117
  if (!this.options.colors.includes(colorName)) {
118
118
  console.warn(
@@ -121,19 +121,8 @@ export const NamedColorExtension = Extension.create<ColorOptions>({
121
121
  return false
122
122
  }
123
123
 
124
- const { to, empty } = state.selection
125
-
126
124
  let commandChain = chain().setMark('textStyle', { color: colorName })
127
125
 
128
- if (!empty) {
129
- commandChain = commandChain
130
- .setTextSelection(to)
131
- .command(({ tr }) => {
132
- tr.setStoredMarks([])
133
- return true
134
- })
135
- }
136
-
137
126
  return commandChain.focus().run()
138
127
  },
139
128
  unsetColor:
@@ -126,7 +126,7 @@ const scrollToHeading = (heading: HeadingAnchor) => {
126
126
  view.dispatch(tr)
127
127
  view.focus()
128
128
 
129
- const editorContainer = document.querySelector('#editorScrollContainer')
129
+ const editorContainer = document.querySelector('#editor-scroll-container')
130
130
  if (element && editorContainer) {
131
131
  const elementRect = element.getBoundingClientRect()
132
132
  const containerRect = editorContainer.getBoundingClientRect()
@@ -147,7 +147,7 @@ const scrollToHeading = (heading: HeadingAnchor) => {
147
147
  const domPos = view.domAtPos(pos)
148
148
  if (domPos.node && domPos.node.nodeType === Node.ELEMENT_NODE) {
149
149
  const node = domPos.node as Element
150
- const editorContainer = document.querySelector('#editorScrollContainer')
150
+ const editorContainer = document.querySelector('#editor-scroll-container')
151
151
  if (editorContainer) {
152
152
  const nodeRect = node.getBoundingClientRect()
153
153
  const containerRect = editorContainer.getBoundingClientRect()
@@ -277,7 +277,7 @@ const extractAnchors = (): HeadingAnchor[] => {
277
277
  if (!props.editor?.state?.doc) return []
278
278
 
279
279
  const headings: HeadingAnchor[] = []
280
- const scrollParent = document.querySelector('#editorScrollContainer')
280
+ const scrollParent = document.querySelector('#editor-scroll-container')
281
281
 
282
282
  // Get the current active tab ID
283
283
  let activeTabId: string | null = null
@@ -366,7 +366,7 @@ const updateAnchors = () => {
366
366
  }
367
367
 
368
368
  let updateInterval: ReturnType<typeof setInterval> | null = null
369
- const scrollParent = document.querySelector('#editorScrollContainer')
369
+ const scrollParent = document.querySelector('#editor-scroll-container')
370
370
 
371
371
  watch(() => props.editor?.state?.doc, updateAnchors, { deep: true })
372
372
 
@@ -131,6 +131,15 @@ img.ProseMirror-selectednode {
131
131
  background-color: var(--surface-gray-2);
132
132
  }
133
133
 
134
+ /* Applies the current color to the link's underline */
135
+ .ProseMirror a span[style] {
136
+ text-decoration: underline;
137
+ }
138
+
139
+ .ProseMirror .tableWrapper {
140
+ overflow-x: scroll;
141
+ }
142
+
134
143
  /* Edit prose classes to be more functional */
135
144
  .prose-v2 {
136
145
  line-height: 1.5 !important;
@@ -43,16 +43,12 @@ class FileUploadHandler {
43
43
  })
44
44
  }
45
45
  })
46
- xhr.upload.addEventListener('load', () => {
47
- this.trigger('finish')
48
- })
49
46
  xhr.addEventListener('error', () => {
50
47
  this.trigger('error')
51
48
  reject()
52
49
  })
53
50
  xhr.onreadystatechange = () => {
54
51
  if (xhr.readyState == XMLHttpRequest.DONE) {
55
- let error
56
52
  if (xhr.status === 200) {
57
53
  let r = null
58
54
  try {
@@ -61,21 +57,36 @@ class FileUploadHandler {
61
57
  r = xhr.responseText
62
58
  }
63
59
  let out = r.message || r
60
+ this.trigger('finish')
64
61
  resolve(out)
65
- } else if (xhr.status === 403) {
66
- error = JSON.parse(xhr.responseText)
67
62
  } else {
68
63
  this.failed = true
69
- try {
70
- error = JSON.parse(xhr.responseText)
71
- } catch (e) {
72
- // pass
64
+ let error: {
65
+ message?: string
66
+ exc?: string
67
+ _server_messages?: string
68
+ httpStatus?: number
69
+ } = {}
70
+
71
+ if (xhr.status === 413 || xhr.status === 0) {
72
+ error = {
73
+ message: 'File size exceeds the maximum allowed limit',
74
+ httpStatus: 413,
75
+ }
76
+ } else {
77
+ try {
78
+ error = JSON.parse(xhr.responseText)
79
+ } catch (e) {
80
+ // pass
81
+ }
73
82
  }
83
+
84
+ if (error && error.exc) {
85
+ console.error(JSON.parse(error.exc)[0])
86
+ }
87
+ this.trigger('error', error)
88
+ reject(error)
74
89
  }
75
- if (error && error.exc) {
76
- console.error(JSON.parse(error.exc)[0])
77
- }
78
- reject(error)
79
90
  }
80
91
  }
81
92