added escape sequences for special chars

master
Michael Ochmann 2 years ago
parent d74650e32e
commit f29069c3d6
  1. 3
      contextAPI.js
  2. 10837
      package-lock.json
  3. 12
      src/WindowManager.js
  4. 2
      src/ui/src/assets/css/_slide.scss
  5. 20
      src/ui/src/components/SlideItem.js

@ -26,7 +26,8 @@ contextBridge.exposeInMainWorld("api", {
clearCache : () => webFrame.clearCache(),
appVersion : async () => await ipcRenderer.invoke("Ation::appVersion"),
fonts : async () => await ipcRenderer.invoke("FontManager::fonts"),
resize : size => ipcRenderer.invoke("WindowManager::resize", size)
resize : size => ipcRenderer.invoke("WindowManager::resize", size),
fullscreen : fullscreen => ipcRenderer.invoke("WindowManager::presentFullscreen", fullscreen)
});
contextBridge.exposeInMainWorld("appSettings", {

10837
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -2,7 +2,6 @@
const {app, BrowserWindow, ipcMain, globalShortcut} = require("electron");
const path = require("path");
const util = require("util");
const {isDevelopment} = require("./Util");
@ -20,6 +19,7 @@ class WindowManager {
ipcMain.on("WindowManager::openFileDialog", () => this.app.openFile());
ipcMain.on("WindowManager::openFile", (_, path) => this.app.openFile(path));
ipcMain.handle("WindowManager::resize", (_, height) => this.windows.settings.setSize(800, height + (process.platform === "win32" ? 50 : 0), true));
ipcMain.handle("WindowManager::presentFullscreen", (_, fullscreen) => this.windows.main.setFullScreen(fullscreen));
}
init() {
@ -39,14 +39,7 @@ class WindowManager {
// window, because it would look odd.
if (["win32", "linux"].includes(process.platform)) {
this.windows.settings.removeMenu();
// we also need to hide the application menu
this.mainWindow.on("enter-full-screen", () => {
this.mainWindow.setAutoHideMenuBar(true);
});
this.mainWindow.on("leave-full-screen", () => {
this.mainWindow.setAutoHideMenuBar(false);
});
}
this.windows.settings.on("close", event => {
@ -81,6 +74,7 @@ class WindowManager {
show : false,
devTools : isDevelopment(),
titleBarStyle : "hiddenInset",
autoHideMenuBar : process.platform === "win32",
webPreferences : {
contextIsolation : true,
preload : path.join(__dirname, "..", "contextAPI.js")

@ -122,7 +122,7 @@
}
pre {
font-size: 0.3em;
//font-size: 0.3em;
width: 90%;
padding: 1em !important;

@ -5,6 +5,14 @@ import {monokai} from "react-syntax-highlighter/dist/esm/styles/hljs";
import SlideContext from "../shared/SlideContext";
const EscapeSequences = {
""" : '"',
"&lt;" : "<",
"&gt;" : ">",
"&amp;" : "&"
};
const EscapeSequencesRegex = new RegExp(Object.keys(EscapeSequences).join('|'), "g");
const Children = ({items}) => {
if (items instanceof Array)
return <>{items.map((child, index) => <SlideItem item={child} key={index} />)}</>;
@ -14,8 +22,14 @@ const Children = ({items}) => {
const SlideItem = ({item}) => {
const {basePath} = useContext(SlideContext);
const processEscapeSequences = text => {
return text.replace(EscapeSequencesRegex, match => EscapeSequences[match]);
};
const content = useMemo(() => {
if (item.type === "paragraph")
console.log(item.type, item);
switch (item.type) {
case "heading":
const level = item.level || item.depth;
@ -66,17 +80,19 @@ const SlideItem = ({item}) => {
return <span dangerouslySetInnerHTML={{__html : item.raw}}></span>
case "link":
case "text":
return <>{item.tokens ? <Children items={item.tokens} /> : item.text}</>
return <>{item.tokens ? <Children items={item.tokens} /> : processEscapeSequences(item.text)}</>
case "escape":
switch(item.text) {
case "&lt;":
return '<';
case "&gt;":
return '>';
case '"':
case "&quot;":
return '"';
default:
return "";
}
break;
default:
return "UNKNOWN ITEM" + JSON.stringify(item);
}

Loading…
Cancel
Save