@dxos/react-ui-editor 0.6.2-main.c33bf0c → 0.6.2-main.c53e208
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/lib/browser/index.mjs +13 -4
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +4 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/package.json +25 -25
- package/src/components/Toolbar/Toolbar.tsx +2 -2
- package/src/extensions/automerge/sync.ts +4 -1
- package/src/extensions/comments.ts +17 -4
|
@@ -1833,6 +1833,9 @@ var selectionOverlapsComment = (state2) => {
|
|
|
1833
1833
|
}
|
|
1834
1834
|
return false;
|
|
1835
1835
|
};
|
|
1836
|
+
var hasActiveSelection = (state2) => {
|
|
1837
|
+
return state2.selection.ranges.some((range) => !range.empty);
|
|
1838
|
+
};
|
|
1836
1839
|
var useComments = (view, id, comments2) => {
|
|
1837
1840
|
useEffect(() => {
|
|
1838
1841
|
if (view) {
|
|
@@ -1852,14 +1855,20 @@ var useComments = (view, id, comments2) => {
|
|
|
1852
1855
|
]);
|
|
1853
1856
|
};
|
|
1854
1857
|
var useCommentState = () => {
|
|
1855
|
-
const [
|
|
1858
|
+
const [state2, setState] = useState({
|
|
1859
|
+
comment: false,
|
|
1860
|
+
selection: false
|
|
1861
|
+
});
|
|
1856
1862
|
const observer = useMemo(() => EditorView7.updateListener.of((update2) => {
|
|
1857
1863
|
if (update2.docChanged || update2.selectionSet) {
|
|
1858
|
-
|
|
1864
|
+
setState({
|
|
1865
|
+
comment: selectionOverlapsComment(update2.state),
|
|
1866
|
+
selection: hasActiveSelection(update2.state)
|
|
1867
|
+
});
|
|
1859
1868
|
}
|
|
1860
1869
|
}), []);
|
|
1861
1870
|
return [
|
|
1862
|
-
|
|
1871
|
+
state2,
|
|
1863
1872
|
observer
|
|
1864
1873
|
];
|
|
1865
1874
|
};
|
|
@@ -4960,7 +4969,7 @@ var MarkdownActions = () => {
|
|
|
4960
4969
|
onClick: () => onAction?.({
|
|
4961
4970
|
type: "comment"
|
|
4962
4971
|
}),
|
|
4963
|
-
disabled: !state2 || state2.comment
|
|
4972
|
+
disabled: !state2 || state2.comment || !state2.selection
|
|
4964
4973
|
}, t("comment label")));
|
|
4965
4974
|
};
|
|
4966
4975
|
var Toolbar = {
|