Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert-pdf-rtl #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Components/ConvertToPdf.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import html2pdf from 'html2pdf.js';
import { HiOutlineDownload } from 'react-icons/hi';
import { Tooltip } from 'react-tooltip';

function ConvertToPdf(props) {
const text = props.text;

const language = props.languege;
console.log(language);
function convertPdf() {
// Create a new div element to hold the text content
const contentDiv = document.createElement('div');

console.log(language == 'Hebrew');
if (language == 'Hebrew')
{contentDiv.style.direction = 'rtl'; // Set text direction to RTL for Hebrew
console.log("if");
}
// Loop through the characters in the text array
text.forEach((charInfo) => {
const charElement = document.createElement('span');
Expand Down Expand Up @@ -44,7 +50,7 @@ function ConvertToPdf(props) {
return (
<div className="Convert_To_Pdf" id="Convert_To_Pdf" data-tooltip-id="Convert-to-PDF" data-tooltip-content="Convert to PDF">
<button onClick={convertPdf}><HiOutlineDownload></HiOutlineDownload></button>
<Tooltip id="Convert-to-PDF" className= 'common-tooltip' />
<Tooltip id="Convert-to-PDF" className='common-tooltip' />
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/SpecialButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import ConvertToPdf from "./ConvertToPdf";
import { Tooltip } from 'react-tooltip';


function SpecialButtons({ handleEvent, isUndo, isRedo,text }) {
function SpecialButtons({ handleEvent, isUndo, isRedo,languege,text }) {
const notify = () => {
toast("Text is copied to clipboard!");
handleEvent("copy");
};

return (
<div id="spacial_buttons" className="spacial_buttons">
<ConvertToPdf text={text}></ConvertToPdf>
<ConvertToPdf text={text} languege={languege}></ConvertToPdf>
<Popup
trigger={
<button className="button" data-tooltip-id="delete-tooltip" data-tooltip-content="Delete All" >
Expand Down
10 changes: 9 additions & 1 deletion src/Components/virtualKeyBoard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,15 @@ const reducer = (state, action) => {
};
function VirtualKeyBoard() {
const [state, dispatch] = useReducer(reducer, initialState);
const { iso_639_2, language, keyList, placeholder, currentStyle, stack, emojiActive, isUndo, isRedo, redoStack } = state;
const { iso_639_2, languageName, keyList, placeholder, currentStyle, stack, emojiActive, isUndo, isRedo, redoStack } = state;
const [isShift, setisShift] = useState(false);

const [language, setLanguage] = useState(languageName);

useEffect(() => {
setLanguage(languageName);
console.log("Current language:", languageName);
}, [languageName]);
const setCurrentStyle = (newStyle) => {
dispatch({
type: "updateCurrentStyle",
Expand Down Expand Up @@ -351,6 +358,7 @@ function VirtualKeyBoard() {
handleEvent={handleEvent}
isUndo={isUndo}
isRedo={isRedo}
languege= {language}
text={ stack.length && stack[stack.length - 1].length
? stack[stack.length - 1]
: placeholder}
Expand Down