Prevent tables from overflowing

This commit is contained in:
Shadowfacts 2022-01-14 16:26:28 -05:00
parent 83c3bc927e
commit 4b0bda88b8
4 changed files with 16 additions and 0 deletions

View File

@ -16,6 +16,7 @@
D65B18BE275051A1004A9448 /* LocalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D65B18BD275051A1004A9448 /* LocalData.swift */; };
D65B18C127505348004A9448 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D65B18C027505348004A9448 /* HomeViewController.swift */; };
D68B303627907D9200E8B3FA /* ExcerptGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D68B303527907D9200E8B3FA /* ExcerptGenerator.swift */; };
D68B303D2792204B00E8B3FA /* read.js in Resources */ = {isa = PBXBuildFile; fileRef = D68B303C2792204B00E8B3FA /* read.js */; };
D6A8A33427766C2800CCEC72 /* PersistentContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A8A33327766C2800CCEC72 /* PersistentContainer.swift */; };
D6C687EC272CD27600874C10 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C687EB272CD27600874C10 /* AppDelegate.swift */; };
D6C687EE272CD27600874C10 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C687ED272CD27600874C10 /* SceneDelegate.swift */; };
@ -101,6 +102,7 @@
D68B3032278FDD1A00E8B3FA /* Reader-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Reader-Bridging-Header.h"; sourceTree = "<group>"; };
D68B303527907D9200E8B3FA /* ExcerptGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExcerptGenerator.swift; sourceTree = "<group>"; };
D68B3037279099FD00E8B3FA /* liblolhtml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblolhtml.a; path = "lol-html/c-api/target/aarch64-apple-ios-sim/release/liblolhtml.a"; sourceTree = "<group>"; };
D68B303C2792204B00E8B3FA /* read.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = read.js; sourceTree = "<group>"; };
D6A8A33327766C2800CCEC72 /* PersistentContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistentContainer.swift; sourceTree = "<group>"; };
D6C687E8272CD27600874C10 /* Reader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Reader.app; sourceTree = BUILT_PRODUCTS_DIR; };
D6C687EB272CD27600874C10 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@ -264,6 +266,7 @@
D6C687F9272CD27700874C10 /* LaunchScreen.storyboard */,
D6C687FC272CD27700874C10 /* Info.plist */,
D6E24372278BE2B80005E546 /* read.css */,
D68B303C2792204B00E8B3FA /* read.js */,
);
path = Reader;
sourceTree = "<group>";
@ -469,6 +472,7 @@
files = (
D6C687FB272CD27700874C10 /* LaunchScreen.storyboard in Resources */,
D6C687F8272CD27700874C10 /* Assets.xcassets in Resources */,
D68B303D2792204B00E8B3FA /* read.js in Resources */,
D6E24373278BE2B80005E546 /* read.css in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -71,6 +71,7 @@ class ReadViewController: UIViewController {
}
private static let css = try! String(contentsOf: Bundle.main.url(forResource: "read", withExtension: "css")!)
private static let js = try! String(contentsOf: Bundle.main.url(forResource: "read", withExtension: "js")!)
private func itemContentHTML() -> String? {
guard let content = item.content else {
@ -105,6 +106,7 @@ class ReadViewController: UIViewController {
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<style>\(ReadViewController.css)</style>
<script async>\(ReadViewController.js)</script>
</head>
<body>
<div id="item-info">

View File

@ -55,6 +55,10 @@ blockquote {
font-style: italic;
}
.item-content-table {
overflow-x: scroll;
}
#item-info {
margin-bottom: 1em;
}

6
Reader/read.js Normal file
View File

@ -0,0 +1,6 @@
document.addEventListener("DOMContentLoaded", () => {
for (const table of document.querySelectorAll("table")) {
// wrap tables in divs to which we can apply overflow-x: scroll;
table.outerHTML = `<div class="item-content-table">${table.outerHTML}</div>`;
}
});