Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #24 from Bwc9876/dev
Browse files Browse the repository at this point in the history
0.6.0
  • Loading branch information
Bwc9876 authored Aug 13, 2022
2 parents 09f61f4 + e342d18 commit ffdc79b
Show file tree
Hide file tree
Showing 30 changed files with 514 additions and 135 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@rjsf/core": "^4.2.3",
"@tauri-apps/api": "^1.0.2",
"bootstrap": "^5.2.0",
"jsonpath-plus": "^7.0.0",
"monaco-editor": "^0.33.0",
"react": "^18.2.0",
"react-bootstrap": "^2.5.0",
Expand All @@ -37,7 +38,8 @@
"react-hotkeys-hook": "^3.4.7",
"react-jsonschema-form": "^1.8.1",
"react-redux": "^8.0.2",
"sortablejs": "^1.15.0"
"sortablejs": "^1.15.0",
"vscode-json-languageservice": "^5.1.0"
},
"devDependencies": {
"@tauri-apps/cli": "^1.0.5",
Expand Down
60 changes: 60 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Common/AppData/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Settings = {
minify: boolean;

/**
* @description Always use a text editor for files instead of the inspector. (Reload Required)
* @description Always use a text editor for files instead of the inspector.
*/
alwaysUseTextEditor: boolean;

Expand Down
2 changes: 1 addition & 1 deletion src/Common/AppData/SettingsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"additionalProperties": false,
"properties": {
"alwaysUseTextEditor": {
"description": "Always use a text editor for files instead of the inspector. (Reload Required)",
"description": "Always use a text editor for files instead of the inspector.",
"type": "boolean"
},
"defaultAuthor": {
Expand Down
34 changes: 34 additions & 0 deletions src/Common/Popover/IconPopover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Placement } from "@popperjs/core";
import PropTypes from "prop-types";
import { Popover, PopoverBody, PopoverHeader } from "react-bootstrap";
import IconPopoverTrigger from "./IconPopoverTrigger";

export type DescriptionPopoverProps = {
id: string;
title: string;
body: string;
icon: PropTypes.ReactElementLike;
className?: string;
placement?: Placement;
};

function IconPopover(props: DescriptionPopoverProps) {
const popover = (
<Popover className="position-absolute" id={`${props.id}-popover`}>
<PopoverHeader>{props.title}</PopoverHeader>
<PopoverBody>{props.body}</PopoverBody>
</Popover>
);

return (
<IconPopoverTrigger
className={props.className}
popover={popover}
icon={props.icon}
placement={props.placement}
ariaLabel="Info"
/>
);
}

export default IconPopover;
33 changes: 33 additions & 0 deletions src/Common/Popover/IconPopoverTrigger.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Placement } from "@popperjs/core";
import PropTypes from "prop-types";
import { cloneElement } from "react";
import { OverlayTrigger } from "react-bootstrap";

export type InfoIconTriggerProps = {
popover: PropTypes.ReactElementLike;
icon: PropTypes.ReactElementLike;
ariaLabel: string;
className?: string;
placement?: Placement;
};

function IconPopoverTrigger(props: InfoIconTriggerProps) {
// noinspection RequiredAttributes
return (
<OverlayTrigger
delay={{ show: 50, hide: 50 }}
trigger={["hover", "focus"]}
placement={props.placement ?? "right"}
overlay={props.popover}
>
{cloneElement(props.icon, {
className: `ms-2 fs-6 text-secondary${
props.className ? ` ${props.className}` : ""
}`,
"aria-label": props.ariaLabel
})}
</OverlayTrigger>
);
}

export default IconPopoverTrigger;
7 changes: 0 additions & 7 deletions src/MainWindow/MenuBar/AboutGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ function ReloadItem() {
}
};

window.onbeforeunload = (e) => {
if (filesHaveChanged) {
e.preventDefault();
e.returnValue = "There are unsaved changes. Are you sure?";
}
};

return (
<IconDropDownItem
annotation="Ctrl+R"
Expand Down
3 changes: 0 additions & 3 deletions src/MainWindow/MenuBar/FileGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ function SaveFileItem() {
);

const onClick = () => {
console.debug("Save Action");
console.debug(selectedFile);
if (selectedIndex !== -1 && selectedFile !== undefined) {
console.debug("Saving file", selectedFile.name);
dispatch(saveFileData({ file: selectedFile, projectPath: project.path }));
}
};
Expand Down
8 changes: 6 additions & 2 deletions src/MainWindow/Panels/Editor/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactElement, useEffect, useMemo } from "react";
import { ReactElement, useEffect, useMemo, useRef } from "react";
import Col from "react-bootstrap/Col";
import { connect } from "react-redux";
import { SchemaStore } from "../../../Common/AppData/SchemaStore";
Expand All @@ -9,7 +9,8 @@ import {
OpenFile,
readFileData,
selectOpenFileByRelativePath,
selectOpenFileIsSelectedFactory
selectOpenFileIsSelectedFactory,
validateFile
} from "../../Store/OpenFilesSlice";
import { isAudio, isImage, usesInspector } from "../../Store/FileUtils";
import { RootState } from "../../Store/Store";
Expand Down Expand Up @@ -51,6 +52,7 @@ const determineEditor = (
function Editor(props: EditorProps) {
const { alwaysUseTextEditor } = useSettings();
const dispatch = useAppDispatch();
const currentValidationPromise = useRef<{ abort: () => void } | null>(null);

const file = useAppSelector((state: RootState) =>
selectOpenFileByRelativePath(state.openFiles, props.relativePath)
Expand All @@ -74,6 +76,8 @@ function Editor(props: EditorProps) {

const onDataChanged = (value: string) => {
dispatch(fileEdited({ id: file.relativePath, content: value }));
currentValidationPromise.current?.abort();
currentValidationPromise.current = dispatch(validateFile({ value, file }));
};

const ChosenEditor = useMemo(
Expand Down
7 changes: 5 additions & 2 deletions src/MainWindow/Panels/Editor/EditorTab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from "react";
import { cloneElement, useMemo } from "react";
import { X } from "react-bootstrap-icons";
import Col from "react-bootstrap/Col";
import { contextMenu } from "../../Store/ContextMenuSlice";
Expand Down Expand Up @@ -41,10 +41,13 @@ function EditorTab(props: EditorTabProps) {

const icon = useMemo(() => determineIcon(file), [props.id]);

const hasErrors =
(file.errors.length > 0 || file.otherErrors) && file.tabIndex !== selectedIndex;

return (
<Col data-relpath={props.id} onContextMenu={onContext} xs="auto" className={classes}>
<span onClick={onClick} className="d-flex align-items-center justify-content-center">
{icon}
{cloneElement(icon, { className: hasErrors ? "text-danger" : "" })}
<span className="ms-1">
{file.name + (file.memoryData !== file.diskData ? "*" : "")}
</span>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ArrayFieldTemplateProps } from "@rjsf/core";
import { cloneElement, useState } from "react";
import { Button, Collapse } from "react-bootstrap";
import { CaretRightFill } from "react-bootstrap-icons";
import { CaretRightFill, InfoCircle } from "react-bootstrap-icons";
import { camelToTitleCase } from "../../../../../../Common/Utils";
import DescriptionPopover from "./DescriptionPopover";
import IconPopover from "../../../../../../Common/Popover/IconPopover";

function InspectorArrayFieldTemplate({
canAdd,
Expand Down Expand Up @@ -35,10 +35,11 @@ function InspectorArrayFieldTemplate({
{camelToTitleCase(title)}
</span>
{schema.description !== undefined && (
<DescriptionPopover
<IconPopover
icon={<InfoCircle />}
id={title}
title={title}
description={schema.description}
body={schema.description}
/>
)}
</h4>
Expand Down
Loading

0 comments on commit ffdc79b

Please sign in to comment.