added hyphenation toggle

This commit is contained in:
Danis
2025-08-25 19:11:05 +04:00
parent 2a41227199
commit ef5c5bf5e6
4 changed files with 34 additions and 3 deletions

View File

@ -749,6 +749,7 @@
"textMargins": "Margins",
"textMarginsH": "Top and bottom margins are too high for a given page height",
"textMarginsW": "Left and right margins are too wide for a given page width",
"textHyphenation": "Hyphenation",
"textMobileView": "Mobile View",
"textNavigation": "Navigation",
"textNo": "No",

View File

@ -12,6 +12,7 @@ class DocumentSettingsController extends Component {
this.applyMargins = this.applyMargins.bind(this);
this.onFormatChange = this.onFormatChange.bind(this);
this.onColorSchemeChange = this.onColorSchemeChange.bind(this);
this.onToggleHyphenation = this.onToggleHyphenation.bind(this);
}
onPageOrientation (value){
@ -98,6 +99,16 @@ class DocumentSettingsController extends Component {
}
}
onToggleHyphenation(value) {
const api = Common.EditorApi.get();
const storeDocumentSettings = this.props.storeDocumentSettings;
if (api) {
api.asc_setAutoHyphenation(value);
storeDocumentSettings.setHyphenation(value);
}
}
// Color Schemes
initPageColorSchemes() {
@ -119,6 +130,7 @@ class DocumentSettingsController extends Component {
applyMargins={this.applyMargins}
onColorSchemeChange={this.onColorSchemeChange}
initPageColorSchemes={this.initPageColorSchemes}
onToggleHyphenation={this.onToggleHyphenation}
/>
)
}

View File

@ -7,19 +7,30 @@ export class storeDocumentSettings {
widthDocument: observable,
heightDocument: observable,
allSchemes: observable,
isHyphenation: observable,
resetPortrait: action,
changeDocSize: action,
pageSizesIndex: computed,
addSchemes: action
addSchemes: action,
setHyphenation: action
});
}
isPortrait = true;
isHyphenation = false;
resetPortrait (isPortrait) {
this.isPortrait = isPortrait === true;
}
setHyphenation (value) {
this.isHyphenation = value;
}
getHyphenation () {
return this.isHyphenation;
}
//Document Formats
widthDocument;
@ -60,7 +71,7 @@ export class storeDocumentSettings {
];
return pageSizes;
}
get pageSizesIndex () {
let w = this.widthDocument;
let h = this.heightDocument;

View File

@ -1,6 +1,6 @@
import React, {useState} from 'react';
import {observer, inject} from "mobx-react";
import {Page, Navbar, List, ListItem, BlockTitle, Segmented, Button, Icon} from 'framework7-react';
import {Page, Navbar, List, ListItem, BlockTitle, Segmented, Button, Icon, Toggle} from 'framework7-react';
import { useTranslation } from 'react-i18next';
import {Device} from '../../../../../common/mobile/utils/device';
import { f7 } from 'framework7-react';
@ -223,6 +223,8 @@ const PageDocumentSettings = props => {
const pageSizesIndex = storeSettings.pageSizesIndex;
const widthDoc = storeSettings.widthDocument;
const heightDoc = storeSettings.heightDocument;
let isHyphenation = storeSettings.getHyphenation();
let textFormat;
let sizeW;
let sizeH;
@ -257,6 +259,11 @@ const PageDocumentSettings = props => {
applyMargins: props.applyMargins
}}></ListItem>
</List>
<List>
<ListItem title={_t.textHyphenation}>
<Toggle checked={isHyphenation} onToggleChange={() => {props.onToggleHyphenation(!isHyphenation)}}/>
</ListItem>
</List>
<List>
<ListItem title={_t.textColorSchemes} link="/color-schemes/" routeProps={{
onColorSchemeChange: props.onColorSchemeChange,