vim-web 0.3.44-dev.12 → 0.3.44-dev.14
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/types/react-viewers/helpers/reactUtils.d.ts +26 -1
- package/dist/types/react-viewers/index.d.ts +1 -0
- package/dist/types/react-viewers/state/sectionBoxState.d.ts +4 -4
- package/dist/vim-web.iife.js +42 -20
- package/dist/vim-web.iife.js.map +1 -1
- package/dist/vim-web.js +42 -20
- package/dist/vim-web.js.map +1 -1
- package/package.json +1 -1
package/dist/vim-web.js
CHANGED
|
@@ -67829,7 +67829,7 @@ function controlBarSectionBox(section, hasSelection) {
|
|
|
67829
67829
|
enabled: () => section.enable.get(),
|
|
67830
67830
|
isOn: () => hasSelection,
|
|
67831
67831
|
style: (on) => buttonDisableStyle(on),
|
|
67832
|
-
action: () => section.sectionSelection(),
|
|
67832
|
+
action: () => section.sectionSelection.call(),
|
|
67833
67833
|
icon: sectionBoxShrink
|
|
67834
67834
|
},
|
|
67835
67835
|
{
|
|
@@ -67837,7 +67837,7 @@ function controlBarSectionBox(section, hasSelection) {
|
|
|
67837
67837
|
tip: "Reset Section",
|
|
67838
67838
|
enabled: () => section.enable.get(),
|
|
67839
67839
|
style: (on) => buttonDefaultStyle(on),
|
|
67840
|
-
action: () => section.sectionReset(),
|
|
67840
|
+
action: () => section.sectionReset.call(),
|
|
67841
67841
|
icon: sectionBoxReset
|
|
67842
67842
|
},
|
|
67843
67843
|
{
|
|
@@ -75819,7 +75819,7 @@ function useStateRef(initialValue) {
|
|
|
75819
75819
|
confirm() {
|
|
75820
75820
|
set3(confirm.current(ref.current));
|
|
75821
75821
|
},
|
|
75822
|
-
|
|
75822
|
+
useOnChange(on) {
|
|
75823
75823
|
useEffect(() => {
|
|
75824
75824
|
return event.current.subscribe(on);
|
|
75825
75825
|
}, []);
|
|
@@ -75839,6 +75839,28 @@ function useStateRef(initialValue) {
|
|
|
75839
75839
|
}
|
|
75840
75840
|
};
|
|
75841
75841
|
}
|
|
75842
|
+
function useArgActionRef(action) {
|
|
75843
|
+
const ref = useRef(action);
|
|
75844
|
+
return {
|
|
75845
|
+
call(arg) {
|
|
75846
|
+
ref == null ? void 0 : ref.current(arg);
|
|
75847
|
+
},
|
|
75848
|
+
set(func) {
|
|
75849
|
+
ref.current = func;
|
|
75850
|
+
}
|
|
75851
|
+
};
|
|
75852
|
+
}
|
|
75853
|
+
function useFuncRef(func) {
|
|
75854
|
+
const ref = useRef(func);
|
|
75855
|
+
return {
|
|
75856
|
+
call() {
|
|
75857
|
+
return ref == null ? void 0 : ref.current();
|
|
75858
|
+
},
|
|
75859
|
+
set(func2) {
|
|
75860
|
+
ref.current = func2;
|
|
75861
|
+
}
|
|
75862
|
+
};
|
|
75863
|
+
}
|
|
75842
75864
|
function useSectionBox(adapter) {
|
|
75843
75865
|
const enable = useStateRef(false);
|
|
75844
75866
|
const visible2 = useStateRef(false);
|
|
@@ -75848,14 +75870,14 @@ function useSectionBox(adapter) {
|
|
|
75848
75870
|
const sideOffset = useStateRef("1");
|
|
75849
75871
|
const bottomOffset = useStateRef("1");
|
|
75850
75872
|
const boxRef = useRef(adapter.getBox());
|
|
75851
|
-
enable.
|
|
75873
|
+
enable.useOnChange((v) => {
|
|
75852
75874
|
visible2.set(v);
|
|
75853
75875
|
auto.set(false);
|
|
75854
75876
|
showOffsetPanel.set(false);
|
|
75855
75877
|
topOffset.set("1");
|
|
75856
75878
|
sideOffset.set("1");
|
|
75857
75879
|
bottomOffset.set("1");
|
|
75858
|
-
void sectionReset();
|
|
75880
|
+
void sectionReset.call();
|
|
75859
75881
|
});
|
|
75860
75882
|
topOffset.useValidate((v) => sanitize(v, false));
|
|
75861
75883
|
sideOffset.useValidate((v) => sanitize(v, false));
|
|
@@ -75863,35 +75885,35 @@ function useSectionBox(adapter) {
|
|
|
75863
75885
|
topOffset.useConfirm((v) => sanitize(v, true));
|
|
75864
75886
|
sideOffset.useConfirm((v) => sanitize(v, true));
|
|
75865
75887
|
bottomOffset.useConfirm((v) => sanitize(v, true));
|
|
75866
|
-
topOffset.
|
|
75867
|
-
sideOffset.
|
|
75868
|
-
bottomOffset.
|
|
75869
|
-
auto.
|
|
75870
|
-
if (v) sectionSelection();
|
|
75888
|
+
topOffset.useOnChange((v) => section.call(boxRef.current));
|
|
75889
|
+
sideOffset.useOnChange((v) => section.call(boxRef.current));
|
|
75890
|
+
bottomOffset.useOnChange((v) => section.call(boxRef.current));
|
|
75891
|
+
auto.useOnChange((v) => {
|
|
75892
|
+
if (v) sectionSelection.call();
|
|
75871
75893
|
});
|
|
75872
75894
|
useEffect(() => {
|
|
75873
75895
|
return adapter.onSelectionChanged.sub(() => {
|
|
75874
|
-
if (auto.get()) sectionSelection();
|
|
75896
|
+
if (auto.get()) sectionSelection.call();
|
|
75875
75897
|
});
|
|
75876
75898
|
}, []);
|
|
75877
|
-
visible2.
|
|
75878
|
-
const section = (baseBox) => {
|
|
75899
|
+
visible2.useOnChange((v) => adapter.setVisible(v));
|
|
75900
|
+
const section = useArgActionRef((baseBox) => {
|
|
75879
75901
|
boxRef.current = baseBox;
|
|
75880
75902
|
const newBox = addBox(baseBox, offsetsToBox3(topOffset.get(), sideOffset.get(), bottomOffset.get()));
|
|
75881
75903
|
adapter.fitBox(newBox);
|
|
75882
|
-
};
|
|
75883
|
-
const sectionSelection = async () => {
|
|
75904
|
+
});
|
|
75905
|
+
const sectionSelection = useFuncRef(async () => {
|
|
75884
75906
|
try {
|
|
75885
75907
|
const box = await adapter.getSelectionBox() ?? await adapter.getRendererBox();
|
|
75886
|
-
section(box);
|
|
75908
|
+
section.call(box);
|
|
75887
75909
|
} catch (e) {
|
|
75888
75910
|
console.error(e);
|
|
75889
75911
|
}
|
|
75890
|
-
};
|
|
75891
|
-
const sectionReset = async () => {
|
|
75912
|
+
});
|
|
75913
|
+
const sectionReset = useFuncRef(async () => {
|
|
75892
75914
|
const box = await adapter.getRendererBox();
|
|
75893
|
-
section(box);
|
|
75894
|
-
};
|
|
75915
|
+
section.call(box);
|
|
75916
|
+
});
|
|
75895
75917
|
return {
|
|
75896
75918
|
enable,
|
|
75897
75919
|
visible: visible2,
|