1
0
mirror of synced 2025-11-06 04:21:11 +08:00

feat: inline mode

This commit is contained in:
redhoodsu
2024-07-12 16:32:26 +08:00
parent 649bbb44ef
commit 5e23ffaec7
5 changed files with 62 additions and 2 deletions

4
eruda.d.ts vendored
View File

@@ -35,6 +35,10 @@ declare module 'eruda' {
* Use shadow dom for css encapsulation
*/
useShadowDom?: boolean
/**
* Enable inline mode
*/
inline?: boolean
/**
* Default settings
*/

View File

@@ -36,9 +36,12 @@ export default {
tool,
autoScale = true,
useShadowDom = true,
inline = false,
defaults = {},
} = {}) {
if (this._isInit) return
if (this._isInit) {
return
}
this._isInit = true
this._scale = 1
@@ -51,7 +54,14 @@ export default {
this._initTools(tool)
this._registerListener()
if (autoScale) this._autoScale()
if (autoScale) {
this._autoScale()
}
if (inline) {
this._entryBtn.hide()
this._$el.addClass('eruda-inline')
this.show()
}
},
_isInit: false,
version: VERSION,

View File

@@ -43,6 +43,12 @@
font-weight: normal;
}
}
&.inline {
position: static;
.dev-tools {
height: 100% !important;
}
}
}
.hidden {

View File

@@ -44,6 +44,9 @@
<li>
<a href="manual.html">manual</a>
</li>
<li>
<a href="inline.html">inline</a>
</li>
</ul>
</nav>
<script>

37
test/inline.html Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Inline</title>
<link rel="stylesheet" href="style.css" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/luna-window/luna-window.css"
/>
<script src="assets/eruda.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luna-window/luna-window.js"></script>
</head>
<body>
<script>
const content = document.createElement('div')
const win = new LunaWindow({
title: 'Window Title',
x: 50,
y: 50,
width: window.innerWidth - 100,
height: window.innerHeight - 100,
content,
})
win.show()
win.$container
.parent()
.addClass('__chobitsu-hide__')
.css('z-index', '200000')
eruda.init({
container: content,
inline: true,
})
</script>
</body>
</html>