vim-web 0.3.44-dev.10 → 0.3.44-dev.13
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/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,37 +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
|
-
|
|
75867
|
-
|
|
75868
|
-
|
|
75869
|
-
)
|
|
75870
|
-
|
|
75871
|
-
auto.useRegister((v) => {
|
|
75872
|
-
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();
|
|
75873
75893
|
});
|
|
75874
75894
|
useEffect(() => {
|
|
75875
75895
|
return adapter.onSelectionChanged.sub(() => {
|
|
75876
|
-
if (auto.get()) sectionSelection();
|
|
75896
|
+
if (auto.get()) sectionSelection.call();
|
|
75877
75897
|
});
|
|
75878
75898
|
}, []);
|
|
75879
|
-
visible2.
|
|
75880
|
-
const section = (baseBox) => {
|
|
75899
|
+
visible2.useOnChange((v) => adapter.setVisible(v));
|
|
75900
|
+
const section = useArgActionRef((baseBox) => {
|
|
75881
75901
|
boxRef.current = baseBox;
|
|
75882
|
-
const newBox = addBox(baseBox,
|
|
75902
|
+
const newBox = addBox(baseBox, offsetsToBox3(topOffset.get(), sideOffset.get(), bottomOffset.get()));
|
|
75883
75903
|
adapter.fitBox(newBox);
|
|
75884
|
-
};
|
|
75885
|
-
const sectionSelection = async () => {
|
|
75904
|
+
});
|
|
75905
|
+
const sectionSelection = useFuncRef(async () => {
|
|
75886
75906
|
try {
|
|
75887
75907
|
const box = await adapter.getSelectionBox() ?? await adapter.getRendererBox();
|
|
75888
|
-
section(box);
|
|
75908
|
+
section.call(box);
|
|
75889
75909
|
} catch (e) {
|
|
75890
75910
|
console.error(e);
|
|
75891
75911
|
}
|
|
75892
|
-
};
|
|
75893
|
-
const sectionReset = async () => {
|
|
75912
|
+
});
|
|
75913
|
+
const sectionReset = useFuncRef(async () => {
|
|
75894
75914
|
const box = await adapter.getRendererBox();
|
|
75895
|
-
section(box);
|
|
75896
|
-
};
|
|
75915
|
+
section.call(box);
|
|
75916
|
+
});
|
|
75897
75917
|
return {
|
|
75898
75918
|
enable,
|
|
75899
75919
|
visible: visible2,
|