@stoker-platform/web-app 0.5.65 → 0.5.67

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.67
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: add rich text editor toolbar features
8
+
9
+ ## 0.5.66
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: remove list table header hover state
14
+
3
15
  ## 0.5.65
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.65",
3
+ "version": "0.5.67",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -70,6 +70,7 @@
70
70
  "moment-timezone": "latest",
71
71
  "qrcode.react": "^4.2.0",
72
72
  "quill": "^2.0.3",
73
+ "quill-table-better": "^1.2.3",
73
74
  "react": "18.3.1",
74
75
  "react-csv": "^2.2.2",
75
76
  "react-day-picker": "^8.10.1",
package/src/App.css CHANGED
@@ -57,6 +57,9 @@
57
57
  border-radius: var(--radius) var(--radius) 0 0 !important;
58
58
  border: 1px solid hsl(var(--border)) !important;
59
59
  }
60
+ .ql-snow .ql-tooltip {
61
+ left: 0 !important;
62
+ }
60
63
 
61
64
  .dark .ql-toolbar.ql-snow .ql-stroke {
62
65
  stroke: hsl(var(--foreground)) !important;
@@ -101,11 +104,51 @@
101
104
  }
102
105
 
103
106
  .dark .ql-toolbar.ql-snow .ql-picker-item:hover {
104
- background-color: hsl(var(--background)) !important;
105
107
  color: hsl(240 4.9% 83.9%) !important;
106
108
  }
107
109
 
108
110
  .dark .ql-toolbar.ql-snow .ql-picker-item.ql-selected {
109
- background-color: hsl(var(--background)) !important;
110
111
  color: hsl(240 4.9% 83.9%) !important;
111
112
  }
113
+
114
+ .label-field-view-input-wrapper label {
115
+ bottom: 40px !important;
116
+ }
117
+
118
+ .dark .ql-toolbar.ql-snow .ql-table-better svg path {
119
+ fill: hsl(240 4.9% 83.9%) !important;
120
+ }
121
+ .dark .ql-toolbar.ql-snow .ql-table-button-disabled {
122
+ background: transparent !important;
123
+ }
124
+
125
+ .dark .ql-editor table {
126
+ background: #fff;
127
+ color: #222;
128
+ }
129
+
130
+ .dark .ql-editor td,
131
+ .dark .ql-editor th {
132
+ border-color: #bbb !important;
133
+ }
134
+
135
+ .dark .ql-table-menus-container,
136
+ .dark .ql-table-dropdown-list,
137
+ .dark .ql-table-dropdown-properties-list,
138
+ .dark .ql-table-select-container,
139
+ .dark .ql-table-properties-form,
140
+ .dark .ql-table-color-container .color-picker .color-picker-select,
141
+ .dark .ql-table-color-container .color-picker .color-picker-palette {
142
+ background: #fff !important;
143
+ color: #333 !important;
144
+ border-color: #ccced1 !important;
145
+ }
146
+
147
+ .dark .ql-table-select-container span {
148
+ border-color: #000 !important;
149
+ }
150
+
151
+ .dark .ql-table-properties-form .properties-form-header {
152
+ color: #333 !important;
153
+ border-color: #ccced1 !important;
154
+ }
package/src/Form.tsx CHANGED
@@ -140,8 +140,10 @@ import { getSafeUrl } from "./utils/isSafeUrl"
140
140
  import { useConnection } from "./providers/ConnectionProvider"
141
141
  import { getAuth } from "firebase/auth"
142
142
  import Quill, { Delta } from "quill"
143
+ import QuillTableBetter from "quill-table-better"
143
144
  import "quill/dist/quill.core.css"
144
145
  import "quill/dist/quill.snow.css"
146
+ import "quill-table-better/dist/quill-table-better.css"
145
147
  import { Breadcrumbs } from "./Breadcrumbs"
146
148
  import { FilePermissionsDialog, FilePermissions } from "./FilePermissions"
147
149
  import { getStorage, ref, uploadBytesResumable, getDownloadURL } from "firebase/storage"
@@ -1580,6 +1582,13 @@ function ArrayField({
1580
1582
  )
1581
1583
  }
1582
1584
 
1585
+ Quill.register(
1586
+ {
1587
+ "modules/table-better": QuillTableBetter,
1588
+ },
1589
+ true,
1590
+ )
1591
+
1583
1592
  const RichTextEditor = forwardRef<
1584
1593
  Quill,
1585
1594
  { readOnly?: boolean; formField: ControllerRenderProps<FieldValues, string>; isDisabled?: boolean }
@@ -1590,10 +1599,10 @@ const RichTextEditor = forwardRef<
1590
1599
  if (ref && typeof ref === "object" && ref.current) {
1591
1600
  const quill = ref.current
1592
1601
  const currentContents = quill.getContents()
1593
- const newContents = formField.value
1594
-
1595
- if (JSON.stringify(currentContents) !== JSON.stringify(newContents)) {
1596
- quill.setContents(newContents || [])
1602
+ const incoming = new Delta(formField.value?.ops || [])
1603
+ const diff = currentContents.diff(incoming)
1604
+ if (diff.ops?.length > 0) {
1605
+ quill.updateContents(diff, Quill.sources.SILENT)
1597
1606
  }
1598
1607
  }
1599
1608
  }, [ref, formField.value])
@@ -1602,9 +1611,38 @@ const RichTextEditor = forwardRef<
1602
1611
  const container = containerRef.current
1603
1612
  if (!container) return
1604
1613
 
1614
+ const toolbarOptions = [
1615
+ [
1616
+ "table-better",
1617
+ { header: [] },
1618
+ "bold",
1619
+ "italic",
1620
+ "underline",
1621
+ "strike",
1622
+ "link",
1623
+ { align: [] },
1624
+ { list: "ordered" },
1625
+ { list: "bullet" },
1626
+ { color: [] },
1627
+ { background: [] },
1628
+ ],
1629
+ ]
1630
+
1605
1631
  const editorContainer = container.appendChild(container.ownerDocument.createElement("div"))
1606
1632
  const quill = new Quill(editorContainer, {
1607
1633
  theme: "snow",
1634
+ modules: {
1635
+ table: false,
1636
+ toolbar: toolbarOptions,
1637
+ "table-better": {
1638
+ language: "en_US",
1639
+ menus: ["column", "row", "merge", "table", "cell", "wrap", "copy", "delete"],
1640
+ toolbarTable: true,
1641
+ },
1642
+ keyboard: {
1643
+ bindings: QuillTableBetter.keyboardBindings,
1644
+ },
1645
+ },
1608
1646
  })
1609
1647
 
1610
1648
  if (ref && typeof ref === "object") {
@@ -1612,7 +1650,7 @@ const RichTextEditor = forwardRef<
1612
1650
  }
1613
1651
 
1614
1652
  if (formField.value) {
1615
- quill.setContents(formField.value)
1653
+ quill.updateContents(formField.value)
1616
1654
  }
1617
1655
 
1618
1656
  quill.on(Quill.events.TEXT_CHANGE, () => {
@@ -4361,7 +4399,7 @@ function RecordForm({
4361
4399
  </>
4362
4400
  )}
4363
4401
  <Form {...form}>
4364
- <form className="space-y-8 max-w-[750px]">
4402
+ <form className="space-y-8 max-w-[750px]" onSubmit={(e) => e.preventDefault()}>
4365
4403
  {formImagesEnabled && operation === "update" && !isOffline && (
4366
4404
  <div className="flex flex-col gap-3 mt-2">
4367
4405
  <Label>Images</Label>
package/src/List.tsx CHANGED
@@ -1715,7 +1715,7 @@ export function List({
1715
1715
  <Table className="list-table">
1716
1716
  <TableHeader>
1717
1717
  {table.getHeaderGroups().map((headerGroup) => (
1718
- <TableRow key={headerGroup.id}>
1718
+ <TableRow key={headerGroup.id} className="hover:bg-transparent">
1719
1719
  {headerGroup.headers.map((header) => {
1720
1720
  let className = ""
1721
1721
  if (header.id !== "select") {