Skip to content

Commit

Permalink
#126 iphone support
Browse files Browse the repository at this point in the history
  • Loading branch information
cumany committed Mar 24, 2024
1 parent 3e26fa1 commit a73a77e
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 115 deletions.
2 changes: 1 addition & 1 deletion build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "editing-toolbar",
"name": "Editing Toolbar",
"version": "2.4.0",
"version": "2.4.1",
"minAppVersion": "0.14.0",
"description": "The Obsidian Editing Toolbar is modified from cmenu, which provides more powerful customization settings and has many built-in editing commands to be a MS Word-like toolbar editing experience.",
"author": "Cuman",
Expand Down
16 changes: 15 additions & 1 deletion build/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ button[class^=cMenuToolbarCommandsubItem]::after {
display: inline-flex;
align-items: center;
width: fit-content;
z-index: var(--layer-status-bar);
z-index: var(--layer-popover);
background-color: var(--color-base-10, --background-primary);
background-clip: padding-box;
border-radius: 6px;
Expand Down Expand Up @@ -921,4 +921,18 @@ button[class^=cMenuToolbarCommandsubItem]::after {

.setting-item.toolbar-cta {
position: relative;
}

.toolbar-pickr .pcr-last-color,
.pickr .pcr-button{
background-color: var(--pcr-color);
}
.toolbar-pickr .pcr-interaction :not(:is(input.pcr-save,.pcr-result)){
display:none;
}
.toolbar-pickr .pcr-swatches {
display:none;
}
.toolbar-pickr {
display:flex;
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "editing-toolbar",
"name": "Editing Toolbar",
"version": "2.4.0",
"version": "2.4.1",
"minAppVersion": "0.14.0",
"description": "The Obsidian Editing Toolbar is modified from cmenu, which provides more powerful customization settings and has many built-in editing commands to be a MS Word-like toolbar editing experience.",
"author": "Cuman",
Expand Down
2 changes: 1 addition & 1 deletion src/modals/cMenuToolbarModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export function setFormateraser(app: App, plugin: cMenuToolbarPlugin) {
else plugin.Temp_Notice = new Notice(t("Clear formatting brush ON!\nClick the mouse middle or right key to close the formatting-brush"), 0);

} else {
let mdText = /(^#+\s|(?<=^|\s*)#|^\>|^\- \[( |x)\]|^\+ |\<[^\<\>]+?\>|^1\. |^\s*\- |^\-+$|^\*+$)/mg;
let mdText = /(^#+\s|^#(?=\s)|^\>|^\- \[( |x)\]|^\+ |\<[^\<\>]+?\>|^1\. |^\s*\- |^\-+$|^\*+$)/mg;
selectText = selectText.replace(mdText, "");
selectText = selectText.replace(/^[ ]+|[ ]+$/mg, "");
selectText = selectText.replace(/\!?\[\[([^\[\]\|]*\|)*([^\(\)\[\]]+)\]\]/g, "$2");
Expand Down
1 change: 1 addition & 0 deletions src/settings/settingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function getPickrSettings(opts: {
el,
container: isView ? document.body : containerEl,
theme: "nano",
appClass: 'toolbar-pickr',
swatches,
lockOpacity: !opacity,
default: defaultColor,
Expand Down
220 changes: 109 additions & 111 deletions src/util/fullscreen.ts
Original file line number Diff line number Diff line change
@@ -1,133 +1,131 @@
import { App,MarkdownView,requireApiVersion } from "obsidian";
import { App, MarkdownView, requireApiVersion } from "obsidian";
let activeDocument: Document;
export function workplacefullscreenMode(app: App)
{
requireApiVersion("0.15.0")?activeDocument=activeWindow.document:activeDocument=window.document;
let rightleaf= activeDocument.body?.querySelector(" .mod-right-split.is-collapsed");
let leftleaf= activeDocument.body?.querySelector(" .mod-left-split.is-collapsed");
if(rightleaf&&!leftleaf) //@ts-ignore
app.commands.executeCommandById("app:toggle-left-sidebar");
if(!rightleaf&&leftleaf) //@ts-ignore
app.commands.executeCommandById("app:toggle-right-sidebar");
if(!rightleaf&&!leftleaf||rightleaf&&leftleaf) {
export function workplacefullscreenMode(app: App) {
requireApiVersion("0.15.0") ? activeDocument = activeWindow.document : activeDocument = window.document;
let rightleaf = activeDocument.body?.querySelector(" .mod-right-split.is-collapsed");
let leftleaf = activeDocument.body?.querySelector(" .mod-left-split.is-collapsed");
if (rightleaf && !leftleaf) //@ts-ignore
app.commands.executeCommandById("app:toggle-left-sidebar");
if (!rightleaf && leftleaf) //@ts-ignore
app.commands.executeCommandById("app:toggle-right-sidebar");
if (!rightleaf && !leftleaf || rightleaf && leftleaf) {

//@ts-ignore
app.commands.executeCommandById("app:toggle-left-sidebar");
//@ts-ignore
app.commands.executeCommandById("app:toggle-right-sidebar")}
//@ts-ignore
app.commands.executeCommandById("app:toggle-left-sidebar");
//@ts-ignore
app.commands.executeCommandById("app:toggle-right-sidebar")
}


}


//full screen mode
export function fullscreenMode(app: App) {
const leaf = app.workspace.getActiveViewOfType(MarkdownView)
if (!leaf)
return;
let el = leaf.containerEl ;
let modroot= document.body?.querySelector(".mod-vertical.mod-root .workspace-tab-container") as HTMLElement
let fullscreenMutationObserver: MutationObserver;
fullscreenMutationObserver = new MutationObserver(function (mutationRecords) {
mutationRecords.forEach(function (mutationRecord) {
mutationRecord.addedNodes.forEach(function (node) {
if(isFull(modroot)){
try{

document.body.removeChild(node);
el.appendChild(node);
}catch (error)
{
console.log(error.message)
}


Object.defineProperty(exports, "__esModule", { value: true });
exports.toggleFull = exports.isFull = exports.exitFull = exports.beFull = void 0;
let DOC_EL = document.documentElement;
let headEl = DOC_EL.querySelector('head');
let styleEl = document.createElement('style');
let TYPE_REQUEST_FULL_SCREEN = 'requestFullscreen';
let TYPE_EXIT_FULL_SCREEN = 'exitFullscreen';
let TYPE_FULL_SCREEN_ELEMENT = 'fullscreenElement';
let TYPE_ON_FULL_SCREEN_CHANGE = 'onfullscreenchange';
if ("webkitRequestFullScreen" in DOC_EL) {
TYPE_REQUEST_FULL_SCREEN = 'webkitRequestFullScreen';
TYPE_EXIT_FULL_SCREEN = 'webkitExitFullscreen';
TYPE_FULL_SCREEN_ELEMENT = 'webkitFullscreenElement';
TYPE_ON_FULL_SCREEN_CHANGE = 'onwebkitfullscreenchange';
}
else if ("msRequestFullscreen" in DOC_EL) {
TYPE_REQUEST_FULL_SCREEN = 'msRequestFullscreen';
TYPE_EXIT_FULL_SCREEN = 'msExitFullscreen';
TYPE_FULL_SCREEN_ELEMENT = 'msFullscreenElement';
TYPE_ON_FULL_SCREEN_CHANGE = 'MSFullscreenChange';
}
else if ("mozRequestFullScreen" in DOC_EL) {
TYPE_REQUEST_FULL_SCREEN = 'mozRequestFullScreen';
TYPE_EXIT_FULL_SCREEN = 'mozCancelFullScreen';
TYPE_FULL_SCREEN_ELEMENT = 'mozFullScreenElement';
TYPE_ON_FULL_SCREEN_CHANGE = 'onmozfullscreenchange';
}
else if (!("requestFullscreen" in DOC_EL)) {
// throw "\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";
console.log("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !");
}
const leaf = app.workspace.getActiveViewOfType(MarkdownView)
if (!leaf)
return;
let el = leaf.containerEl;
let modroot = document.body?.querySelector(".mod-vertical.mod-root .workspace-tab-container") as HTMLElement
let fullscreenMutationObserver: MutationObserver;
fullscreenMutationObserver = new MutationObserver(function (mutationRecords) {
mutationRecords.forEach(function (mutationRecord) {
mutationRecord.addedNodes.forEach(function (node) {
if (isFull(modroot)) {
try {

document.body.removeChild(node);
el.appendChild(node);
} catch (error) {
console.log(error.message)
}

}else
{
return;
} else {
return;
}
});
});
});
modroot.addEventListener("fullscreenchange", function (event: any) {
});
});

});
modroot.addEventListener("fullscreenchange", function (event: any) {
if (!isFull(modroot)) {
fullscreenMutationObserver.disconnect();
}
}
});
if(isFull(modroot))
{
fullscreenMutationObserver.disconnect();

exitFull()

}else
{

beFull(modroot)
fullscreenMutationObserver.observe(document.body, { childList: true });
if (isFull(modroot)) {
fullscreenMutationObserver.disconnect();

}
}
exitFull()

Object.defineProperty(exports, "__esModule", { value: true });
exports.toggleFull = exports.isFull = exports.exitFull = exports.beFull = void 0;
let DOC_EL = document.documentElement;
let headEl = DOC_EL.querySelector('head');
let styleEl = document.createElement('style');
let TYPE_REQUEST_FULL_SCREEN = 'requestFullscreen';
let TYPE_EXIT_FULL_SCREEN = 'exitFullscreen';
let TYPE_FULL_SCREEN_ELEMENT = 'fullscreenElement';
let TYPE_ON_FULL_SCREEN_CHANGE = 'onfullscreenchange';
if ("webkitRequestFullScreen" in DOC_EL) {
TYPE_REQUEST_FULL_SCREEN = 'webkitRequestFullScreen';
TYPE_EXIT_FULL_SCREEN = 'webkitExitFullscreen';
TYPE_FULL_SCREEN_ELEMENT = 'webkitFullscreenElement';
TYPE_ON_FULL_SCREEN_CHANGE = 'onwebkitfullscreenchange';
}
else if ("msRequestFullscreen" in DOC_EL) {
TYPE_REQUEST_FULL_SCREEN = 'msRequestFullscreen';
TYPE_EXIT_FULL_SCREEN = 'msExitFullscreen';
TYPE_FULL_SCREEN_ELEMENT = 'msFullscreenElement';
TYPE_ON_FULL_SCREEN_CHANGE = 'MSFullscreenChange';
}
else if ("mozRequestFullScreen" in DOC_EL) {
TYPE_REQUEST_FULL_SCREEN = 'mozRequestFullScreen';
TYPE_EXIT_FULL_SCREEN = 'mozCancelFullScreen';
TYPE_FULL_SCREEN_ELEMENT = 'mozFullScreenElement';
TYPE_ON_FULL_SCREEN_CHANGE = 'onmozfullscreenchange';
}
else if (!("requestFullscreen" in DOC_EL)) {
throw "\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";
}
function getCurrentElement(el: HTMLElement) {
return el instanceof HTMLElement ? el : DOC_EL;
}
function beFull(el: HTMLElement) {
} else {

beFull(modroot)
fullscreenMutationObserver.observe(document.body, { childList: true });

return getCurrentElement(el)[TYPE_REQUEST_FULL_SCREEN]();
}
exports.beFull = beFull;
function exitFull() {
if (DOC_EL.contains(styleEl)) {
headEl === null || headEl === void 0 ? void 0 : headEl.removeChild(styleEl);
}
return document[TYPE_EXIT_FULL_SCREEN]();
}
exports.exitFull = exitFull;
function isFull(el: any) {
return getCurrentElement(el) === document[TYPE_FULL_SCREEN_ELEMENT];
}
exports.isFull = isFull;
function toggleFull(el: any) {
if (isFull(el)) {
exitFull();
return false;

function getCurrentElement(el: HTMLElement) {
return el instanceof HTMLElement ? el : DOC_EL;
}
function beFull(el: HTMLElement) {

return getCurrentElement(el)[TYPE_REQUEST_FULL_SCREEN]();
}
else {
beFull(el);
return true;
exports.beFull = beFull;
function exitFull() {
if (DOC_EL.contains(styleEl)) {
headEl === null || headEl === void 0 ? void 0 : headEl.removeChild(styleEl);
}
return document[TYPE_EXIT_FULL_SCREEN]();
}
exports.exitFull = exitFull;
function isFull(el: any) {
return getCurrentElement(el) === document[TYPE_FULL_SCREEN_ELEMENT];
}
exports.isFull = isFull;
function toggleFull(el: any) {
if (isFull(el)) {
exitFull();
return false;
}
else {
beFull(el);
return true;
}
}
exports.toggleFull = toggleFull;
}
exports.toggleFull = toggleFull;


0 comments on commit a73a77e

Please sign in to comment.