@stoker-platform/web-app 0.5.77 → 0.5.79
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/CHANGELOG.md +13 -0
- package/package.json +2 -2
- package/src/Form.tsx +36 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @stoker-platform/web-app
|
|
2
2
|
|
|
3
|
+
## 0.5.79
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @stoker-platform/node-client@0.5.45
|
|
9
|
+
|
|
10
|
+
## 0.5.78
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- fix: fix quill table initialisation
|
|
15
|
+
|
|
3
16
|
## 0.5.77
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoker-platform/web-app",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.79",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"scripts": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
52
52
|
"@react-google-maps/api": "^2.20.8",
|
|
53
53
|
"@sentry/react": "^10.47.0",
|
|
54
|
-
"@stoker-platform/node-client": "0.5.
|
|
54
|
+
"@stoker-platform/node-client": "0.5.45",
|
|
55
55
|
"@stoker-platform/utils": "0.5.37",
|
|
56
56
|
"@stoker-platform/web-client": "0.5.44",
|
|
57
57
|
"@tanstack/react-table": "^8.21.3",
|
package/src/Form.tsx
CHANGED
|
@@ -139,7 +139,7 @@ import { getFormattedFieldValue } from "./utils/getFormattedFieldValue"
|
|
|
139
139
|
import { getSafeUrl } from "./utils/isSafeUrl"
|
|
140
140
|
import { useConnection } from "./providers/ConnectionProvider"
|
|
141
141
|
import { getAuth } from "firebase/auth"
|
|
142
|
-
import Quill, { Delta } from "quill"
|
|
142
|
+
import Quill, { Delta, type Op } from "quill"
|
|
143
143
|
import QuillTableBetter from "quill-table-better"
|
|
144
144
|
import "quill/dist/quill.core.css"
|
|
145
145
|
import "quill/dist/quill.snow.css"
|
|
@@ -1589,17 +1589,43 @@ Quill.register(
|
|
|
1589
1589
|
true,
|
|
1590
1590
|
)
|
|
1591
1591
|
|
|
1592
|
+
const TABLE_BLOCK_KEYS = ["table-cell-block", "table-th-block", "table-header", "table-list"]
|
|
1593
|
+
const TABLE_CONTAINER_KEYS = ["table-cell", "table-th"]
|
|
1594
|
+
|
|
1595
|
+
const fixTableAttributeOrder = (delta: { ops?: Op[] }): Delta => {
|
|
1596
|
+
const ops = delta?.ops || []
|
|
1597
|
+
const fixed = ops.map((op) => {
|
|
1598
|
+
if (!op.attributes) return op
|
|
1599
|
+
const attrs = op.attributes as Record<string, unknown>
|
|
1600
|
+
const blockKey = TABLE_BLOCK_KEYS.find((key) => key in attrs)
|
|
1601
|
+
const containerKey = TABLE_CONTAINER_KEYS.find((key) => key in attrs)
|
|
1602
|
+
if (blockKey && containerKey) {
|
|
1603
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
1604
|
+
const reordered: Record<string, unknown> = { [blockKey]: attrs[blockKey] }
|
|
1605
|
+
for (const key of Object.keys(attrs)) {
|
|
1606
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
1607
|
+
if (key !== blockKey) reordered[key] = attrs[key]
|
|
1608
|
+
}
|
|
1609
|
+
return { ...op, attributes: reordered }
|
|
1610
|
+
}
|
|
1611
|
+
return op
|
|
1612
|
+
})
|
|
1613
|
+
return new Delta(fixed)
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1592
1616
|
const RichTextEditor = forwardRef<
|
|
1593
1617
|
Quill,
|
|
1594
1618
|
{ readOnly?: boolean; formField: ControllerRenderProps<FieldValues, string>; isDisabled?: boolean }
|
|
1595
1619
|
>(({ readOnly, formField, isDisabled }, ref) => {
|
|
1596
1620
|
const containerRef = useRef<HTMLDivElement>(null)
|
|
1621
|
+
const initializedRef = useRef(false)
|
|
1597
1622
|
|
|
1598
1623
|
useEffect(() => {
|
|
1624
|
+
if (!initializedRef.current) return
|
|
1599
1625
|
if (ref && typeof ref === "object" && ref.current) {
|
|
1600
1626
|
const quill = ref.current
|
|
1601
1627
|
const currentContents = quill.getContents()
|
|
1602
|
-
const incoming =
|
|
1628
|
+
const incoming = fixTableAttributeOrder(formField.value)
|
|
1603
1629
|
const diff = currentContents.diff(incoming)
|
|
1604
1630
|
if (diff.ops?.length > 0) {
|
|
1605
1631
|
quill.updateContents(diff, Quill.sources.SILENT)
|
|
@@ -1610,6 +1636,7 @@ const RichTextEditor = forwardRef<
|
|
|
1610
1636
|
useEffect(() => {
|
|
1611
1637
|
const container = containerRef.current
|
|
1612
1638
|
if (!container) return
|
|
1639
|
+
initializedRef.current = false
|
|
1613
1640
|
|
|
1614
1641
|
const toolbarOptions = [
|
|
1615
1642
|
[
|
|
@@ -1650,17 +1677,18 @@ const RichTextEditor = forwardRef<
|
|
|
1650
1677
|
}
|
|
1651
1678
|
|
|
1652
1679
|
if (formField.value) {
|
|
1653
|
-
|
|
1654
|
-
|
|
1680
|
+
const safeDelta = fixTableAttributeOrder(formField.value)
|
|
1681
|
+
quill.updateContents(safeDelta, Quill.sources.SILENT)
|
|
1655
1682
|
}
|
|
1656
1683
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1684
|
+
initializedRef.current = true
|
|
1685
|
+
|
|
1686
|
+
quill.on(Quill.events.TEXT_CHANGE, () => {
|
|
1687
|
+
formField.onChange(quill.getContents())
|
|
1661
1688
|
})
|
|
1662
1689
|
|
|
1663
1690
|
return () => {
|
|
1691
|
+
initializedRef.current = false
|
|
1664
1692
|
if (ref && typeof ref === "object") {
|
|
1665
1693
|
ref.current = null
|
|
1666
1694
|
}
|