feat: The translation box can be set to adaptive height
This commit is contained in:
@@ -1349,6 +1349,11 @@ export const I18N = {
|
|||||||
en: `Transbox Follow Selection`,
|
en: `Transbox Follow Selection`,
|
||||||
zh_TW: `翻譯框跟隨選取文字`,
|
zh_TW: `翻譯框跟隨選取文字`,
|
||||||
},
|
},
|
||||||
|
tranbox_auto_height: {
|
||||||
|
zh: `翻译框自适应高度`,
|
||||||
|
en: `Translation box adaptive height`,
|
||||||
|
zh_TW: `翻譯框自適應高度`,
|
||||||
|
},
|
||||||
translate_start_hook: {
|
translate_start_hook: {
|
||||||
zh: `翻译开始钩子函数`,
|
zh: `翻译开始钩子函数`,
|
||||||
en: `Translate Start Hook`,
|
en: `Translate Start Hook`,
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export const DEFAULT_TRANBOX_SETTING = {
|
|||||||
hideClickAway: false, // 是否点击外部关闭弹窗
|
hideClickAway: false, // 是否点击外部关闭弹窗
|
||||||
simpleStyle: false, // 是否简洁界面
|
simpleStyle: false, // 是否简洁界面
|
||||||
followSelection: false, // 翻译框是否跟随选中文本
|
followSelection: false, // 翻译框是否跟随选中文本
|
||||||
|
autoHeight: false, // 自适应高度
|
||||||
triggerMode: OPT_TRANBOX_TRIGGER_CLICK, // 触发翻译方式
|
triggerMode: OPT_TRANBOX_TRIGGER_CLICK, // 触发翻译方式
|
||||||
// extStyles: "", // 附加样式
|
// extStyles: "", // 附加样式
|
||||||
enDict: OPT_DICT_BING, // 英文词典
|
enDict: OPT_DICT_BING, // 英文词典
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export default function Tranbox() {
|
|||||||
hideClickAway = false,
|
hideClickAway = false,
|
||||||
simpleStyle = false,
|
simpleStyle = false,
|
||||||
followSelection = false,
|
followSelection = false,
|
||||||
|
autoHeight = false,
|
||||||
triggerMode = OPT_TRANBOX_TRIGGER_CLICK,
|
triggerMode = OPT_TRANBOX_TRIGGER_CLICK,
|
||||||
// extStyles = "",
|
// extStyles = "",
|
||||||
enDict = OPT_DICT_BING,
|
enDict = OPT_DICT_BING,
|
||||||
@@ -330,6 +331,20 @@ export default function Tranbox() {
|
|||||||
max={200}
|
max={200}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid item xs={12} sm={12} md={6} lg={3}>
|
||||||
|
<TextField
|
||||||
|
fullWidth
|
||||||
|
select
|
||||||
|
size="small"
|
||||||
|
name="autoHeight"
|
||||||
|
value={autoHeight}
|
||||||
|
label={i18n("tranbox_auto_height")}
|
||||||
|
onChange={handleChange}
|
||||||
|
>
|
||||||
|
<MenuItem value={false}>{i18n("disable")}</MenuItem>
|
||||||
|
<MenuItem value={true}>{i18n("enable")}</MenuItem>
|
||||||
|
</TextField>
|
||||||
|
</Grid>
|
||||||
{!isExt && (
|
{!isExt && (
|
||||||
<Grid item xs={12} sm={12} md={6} lg={3}>
|
<Grid item xs={12} sm={12} md={6} lg={3}>
|
||||||
<ShortcutInput
|
<ShortcutInput
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ export default function DraggableResizable({
|
|||||||
setPosition,
|
setPosition,
|
||||||
onChangeSize,
|
onChangeSize,
|
||||||
onChangePosition,
|
onChangePosition,
|
||||||
|
autoHeight,
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const lineWidth = 4;
|
const lineWidth = 4;
|
||||||
@@ -222,11 +223,19 @@ export default function DraggableResizable({
|
|||||||
</Pointer>
|
</Pointer>
|
||||||
<Box
|
<Box
|
||||||
className="KT-draggable-container"
|
className="KT-draggable-container"
|
||||||
style={{
|
style={
|
||||||
width: size.w,
|
autoHeight
|
||||||
height: size.h,
|
? {
|
||||||
overflow: "hidden auto",
|
width: size.w,
|
||||||
}}
|
maxHeight: size.h,
|
||||||
|
overflow: "hidden auto",
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
width: size.w,
|
||||||
|
height: size.h,
|
||||||
|
overflow: "hidden auto",
|
||||||
|
}
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -115,7 +115,15 @@ export default function TranBox({
|
|||||||
text,
|
text,
|
||||||
setText,
|
setText,
|
||||||
setShowBox,
|
setShowBox,
|
||||||
tranboxSetting: { enDict, enSug, apiSlugs, fromLang, toLang, toLang2 },
|
tranboxSetting: {
|
||||||
|
enDict,
|
||||||
|
enSug,
|
||||||
|
apiSlugs,
|
||||||
|
fromLang,
|
||||||
|
toLang,
|
||||||
|
toLang2,
|
||||||
|
autoHeight,
|
||||||
|
},
|
||||||
transApis,
|
transApis,
|
||||||
boxSize,
|
boxSize,
|
||||||
setBoxSize,
|
setBoxSize,
|
||||||
@@ -141,6 +149,7 @@ export default function TranBox({
|
|||||||
size={boxSize}
|
size={boxSize}
|
||||||
setSize={setBoxSize}
|
setSize={setBoxSize}
|
||||||
setPosition={setBoxPosition}
|
setPosition={setBoxPosition}
|
||||||
|
autoHeight={autoHeight}
|
||||||
header={
|
header={
|
||||||
<Header
|
<Header
|
||||||
setShowBox={setShowBox}
|
setShowBox={setShowBox}
|
||||||
|
|||||||
Reference in New Issue
Block a user