Skip to content

Commit

Permalink
Version 1.0.9
Browse files Browse the repository at this point in the history
1. Fix keyboard hotkey mappings on iOS platforms.
  • Loading branch information
nuthrash committed Apr 9, 2023
1 parent 16e023d commit 331d1e3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ This section would try to explain some terms used by Operating Mode more detail.
<br />

### Hotkeys and touch gestures settings
Almost all keyboard hotkeys are taken from Obsidian's global hotkey settings, so you shall modify them via Settings → Options → Hotkeys. <br>
Almost all keyboard hotkeys are taken from Obsidian's global hotkey settings, so you shall modify them via ⚙"Settings" ⇨ "Hotkeys" options page. <br>
That means this plugin does not design any new configuration interface for keyboard hotkeys. And it just show the first two settings of corresponding hotkeys with readonly mode.

#### Search document text
Expand All @@ -111,11 +111,11 @@ Zoom out current file.
#### Reset document zoom
Reset current file zoom.
#### Quick document zoom in and out
Zoom the document using Ctrl + Wheel (zoom in: ↑, zoom out: ↓), or using the trackpad/touch screen/touch panel two-finger pinch-zoom gesture (zoom in: ← →, zoom out: → ←).
Zoom the document using Ctrl + Wheel (zoom in: ↑, zoom out: ↓), or using the trackpad/touch screen/touch panel by two-finger pinch-zoom gesture (zoom in: ← →, zoom out: → ←).


## More options
After opening HTML files, the three dots "more options" menu icon on right-upper corner of tab would add some menu items.
After opening HTML files, the three dots "more options" menu icon on right-upper corner of tab would be added some menu items.

![MoreOptions1.jpg](./assets/images/screenshots/MoreOptions1.jpg "More Options part1")

Expand Down Expand Up @@ -174,4 +174,4 @@ Reset current file zoom.
- The mobile version of Obsidian does not provide these settings, so this plugin also not provide them.

- The presentation style of search results is different with Markdown documents
- There are lots tags/elements inside HTML files, and some search results would across tags and overlap with each others. Therefore, this plugin use the block mark style (highlight with background color) instead outline style.
- There are lots tags/elements inside HTML files, and some search results would across tags and overlap with each others. Therefore, this plugin use the block mark style (highlight with background color) instead of outline style.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-html-plugin",
"name": "HTML Reader",
"version": "1.0.8",
"version": "1.0.9",
"minAppVersion": "0.15.3",
"description": "This is a HTML file reader plugin for Obsidian. Can open document with \".html\" and \".htm\" file extensions.",
"author": "Nuthrash",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-html-plugin",
"version": "1.0.8",
"version": "1.0.9",
"description": "This is a HTML file reader plugin for Obsidian. Can open document with \".html\" and \".htm\" file extensions.",
"main": "main.js",
"scripts": {
Expand Down
19 changes: 12 additions & 7 deletions src/HtmlPluginSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class HtmlSettingTab extends PluginSettingTab {

// ----- HotKeys and Touch Gestures Settings ----
containerEl.createEl('h2', { text: 'HotKeys and Touch Gestures Settings' });
containerEl.createEl('small', { text: `Almost all keyboard hotkeys are taken from Obsidian's global hotkey settings, so you shall modify them via Settings → Options → Hotkeys` });
containerEl.createEl('small', { text: `Almost all keyboard hotkeys are taken from Obsidian's global hotkey settings, so you shall modify them via ⚙"Settings" ⇨ "Hotkeys" options page.` });

this.buildHotkeySettings();

Expand Down Expand Up @@ -145,17 +145,14 @@ export class HtmlSettingTab extends PluginSettingTab {
}

toNativeModifierString( modifiers: Modifier[], key: string ): string {
const isMacPlat = isMacPlatform();
let str = modifiers.join( isMacPlat ? '' : ' + ' );
if( isMacPlat ) {
str = str
if( isMacPlatform() || isIosPlatform() ) {
return modifiers.join('')
.replace( 'Mod', '⌘' ).replace( 'Meta', '⌘' )
.replace( 'Shift', '⇧' ).replace( 'Alt', '⌥' )
.replace( 'Ctrl', '^' ).concat( key );
} else {
str = str.replace( 'Mod', 'Ctrl' ).replace( 'Meta', 'Win' ).concat( ` + ${key}` );
return modifiers.join( ' + ' ).replace( 'Mod', 'Ctrl' ).replace( 'Meta', 'Win' ).concat( ` + ${key}` );
}
return str;
}
}

Expand All @@ -166,4 +163,12 @@ export function isMacPlatform(): boolean {
return true;
return false;
}
export function isIosPlatform(): boolean {
const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
const userAgent = window.navigator.userAgent;
for( let plat of iosPlatforms )
if( userAgent.contains(plat) )
return true;
return false;
}

14 changes: 7 additions & 7 deletions src/HtmlView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WorkspaceLeaf, FileView, TFile, sanitizeHTMLToDom } from "obsidian";
import { HtmlPluginSettings, HtmlPluginOpMode, isMacPlatform, DEFAULT_SETTINGS } from './HtmlPluginSettings';
import { HtmlPluginSettings, HtmlPluginOpMode, isMacPlatform, isIosPlatform, DEFAULT_SETTINGS } from './HtmlPluginSettings';
import { HtmlPluginOpMode } from './HtmlPluginOpMode';

import { extract } from "single-filez-core/processors/compression/compression-extract.js";
Expand Down Expand Up @@ -378,7 +378,7 @@ function isUnselectableElement( elm: HTMLElement ): boolean {
return ((style.display === 'none') || (elm.offsetWidth === 0))
}

let isMacPlat = isMacPlatform();
let isAppleSys = isMacPlatform() || isIosPlatform();
function mapNativeHotkeys( app: App, cmdId: string ): Hotkey[] {
let ohks = app.hotkeyManager.getHotkeys(cmdId) || app.hotkeyManager.getDefaultHotkeys(cmdId);

Expand All @@ -395,7 +395,7 @@ function mapNativeHotkeys( app: App, cmdId: string ): Hotkey[] {
for( let mod of ohk.modifiers ) {
if( mod === 'Mod' ) {
// replace Obsidian's Mod modifier string to native platform's modifier
hk.modifiers.push( isMacPlat ? 'Meta' : 'Ctrl' );
hk.modifiers.push( isAppleSys ? 'Meta' : 'Ctrl' );
} else {
hk.modifiers.push( mod );
}
Expand Down Expand Up @@ -435,8 +435,8 @@ function checkHotkeyModifier( modifiers: Modifier[], evt: KeyboardEvent | MouseE
if( !evt.altKey ) // This key value is also used for the Apple Option key.
return false;
break;
case 'Mod': // Mod = Cmd on MacOS and Ctrl on other OS
if( isMacPlat ? !evt.metaKey : !evt.ctrlKey)
case 'Mod': // Mod = Cmd on MacOS(iOS?) and Ctrl on other OS
if( isAppleSys ? !evt.metaKey : !evt.ctrlKey)
return false;
break;
}
Expand Down Expand Up @@ -957,9 +957,9 @@ const MAINVIEW_HTML: string = `
<div class="document-search">
<input class="document-search-input" type="search" placeholder="${i18next.t("editor.search.placeholder-find")}" id="ohpSearchInput">
<div class="document-search-buttons">
<button class="document-search-button" aria-label="${isMacPlat ? "⇧F3" : "Shift + F3"}" aria-label-position="top" id="ohpSearchPrev">${i18next.t("editor.search.label-previous")}</button>
<button class="document-search-button" aria-label="${isAppleSys ? "⇧F3" : "Shift + F3"}" aria-label-position="top" id="ohpSearchPrev">${i18next.t("editor.search.label-previous")}</button>
<button class="document-search-button" aria-label="F3" aria-label-position="top" id="ohpSearchNext">${i18next.t("editor.search.label-next")}</button>
<button class="document-search-button" aria-label="${isMacPlat ? "⌥Enter" : "Alt + Enter"}" aria-label-position="top" id="ohpSearchSelectAll">${i18next.t("editor.search.label-all")}</button>
<button class="document-search-button" aria-label="${isAppleSys ? "⌥Enter" : "Alt + Enter"}" aria-label-position="top" id="ohpSearchSelectAll">${i18next.t("editor.search.label-all")}</button>
<span class="document-search-close-button" aria-label="${i18next.t("editor.search.label-exit-search")}" aria-label-position="top" id="ohpSearchExit"></span>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"1.0.5": "0.15.0",
"1.0.6": "0.15.0",
"1.0.7": "0.15.0",
"1.0.8": "0.15.3"
"1.0.8": "0.15.3",
"1.0.9": "0.15.3"
}

0 comments on commit 331d1e3

Please sign in to comment.