Skip to content

Commit

Permalink
chore: update .gitattributes 31855f2
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jan 17, 2025
1 parent 8675e74 commit d9b801f
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 156 deletions.
24 changes: 12 additions & 12 deletions README-zh.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
<meta property="twitter:title" content="宝宝字帖 - 「宝宝字帖」是一款功能强大的字帖生成工具,专为满足不同用户的书写练习需求而设计,并且会根据我自己宝宝的成长持续添加内容。字帖提供了多种类型的字帖生成功能,包括汉字字帖、汉字笔顺描写帖、字母字帖和笔控练习字帖。用户可以根据个人需求,自定义设置">
<meta property="twitter:description" content="「宝宝字帖」是一款功能强大的字帖生成工具,专为满足不同用户的书写练习需求而设计,并且会根据我自己宝宝的成长持续添加内容。字帖提供了多种类型的字帖生成功能,包括汉字字帖、汉字笔顺描写帖、字母字帖和笔控练习字帖。用户可以根据个人需求,自定义设置">
<meta name="apple-itunes-app" content="app-id=6476452351">
<link rel="stylesheet" type="text/css" href="css/main.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/tocbot.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/media.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/sidebar.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/copy.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/demo-preview.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/main.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/tocbot.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/media.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/sidebar.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/copy.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/demo-preview.css?v=1.34.1">
<link rel="icon" href="assets/logo.png" type="image/x-icon">
<script src="js/copy.js?v=1.33.2"></script>
<script src="js/dark-mode.js?v=1.33.2"></script>
<script src="js/markdown-style.js?v=1.33.2"></script>
<script src="js/copy.js?v=1.34.1"></script>
<script src="js/dark-mode.js?v=1.34.1"></script>
<script src="js/markdown-style.js?v=1.34.1"></script>
</head>
<body id="idoctotop"><a href="#idoctotop" class="gototop">top</a>
<header class="header">
Expand Down Expand Up @@ -121,14 +121,14 @@ <h3 id="适合什么样的人群"><a aria-hidden="true" tabindex="-1" href="#适
-->
</markdown-style>
</div>
<script src="js/demo-preview.js?v=1.33.2"></script>
<script src="js/demo-preview.js?v=1.34.1"></script>
<div class="footer warpper" style="max-width:720px;">
<a href="./terms-of-service.html" target="_blank">Terms of Service</a>
<a href="./privacy-policy.html" target="_blank">Privacy Policy</a>
<a href="https://wangchujiang.com/#/projects" target="_blank">Projects</a>
<a href="https://wangchujiang.com/#/sponsor" target="_blank">Sponsor</a>
<a href="https://wangchujiang.com/#/app" target="_blank">More Apps</a><br><br>Generated by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a> v1.33.2
<a href="https://wangchujiang.com/#/app" target="_blank">More Apps</a><br><br>Generated by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a> v1.34.1
</div>
<script src="js/tocbot.js?v=1.33.2"></script>
<script src="js/tocbot.js?v=1.34.1"></script>
</body>
</html>
24 changes: 12 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
<meta property="twitter:title" content="Copybook Generator - &#x22;Copybook Generator&#x22; is a powerful copybook generation tool designed to meet the writing practice needs of different use">
<meta property="twitter:description" content="&#x22;Copybook Generator&#x22; is a powerful copybook generation tool designed to meet the writing practice needs of different use">
<meta name="apple-itunes-app" content="app-id=6476452351">
<link rel="stylesheet" type="text/css" href="css/main.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/tocbot.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/media.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/sidebar.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/copy.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/demo-preview.css?v=1.33.2">
<link rel="stylesheet" type="text/css" href="css/main.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/tocbot.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/media.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/sidebar.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/copy.css?v=1.34.1">
<link rel="stylesheet" type="text/css" href="css/demo-preview.css?v=1.34.1">
<link rel="icon" href="assets/logo.png" type="image/x-icon">
<script src="js/copy.js?v=1.33.2"></script>
<script src="js/dark-mode.js?v=1.33.2"></script>
<script src="js/markdown-style.js?v=1.33.2"></script>
<script src="js/copy.js?v=1.34.1"></script>
<script src="js/dark-mode.js?v=1.34.1"></script>
<script src="js/markdown-style.js?v=1.34.1"></script>
</head>
<body id="idoctotop"><a href="#idoctotop" class="gototop">top</a>
<header class="header">
Expand Down Expand Up @@ -122,14 +122,14 @@ <h3 id="suitable-for-whom"><a aria-hidden="true" tabindex="-1" href="#suitable-f
-->
</markdown-style>
</div>
<script src="js/demo-preview.js?v=1.33.2"></script>
<script src="js/demo-preview.js?v=1.34.1"></script>
<div class="footer warpper" style="max-width:720px;">
<a href="./terms-of-service.html" target="_blank">Terms of Service</a>
<a href="./privacy-policy.html" target="_blank">Privacy Policy</a>
<a href="https://wangchujiang.com/#/projects" target="_blank">Projects</a>
<a href="https://wangchujiang.com/#/sponsor" target="_blank">Sponsor</a>
<a href="https://wangchujiang.com/#/app" target="_blank">More Apps</a><br><br>Generated by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a> v1.33.2
<a href="https://wangchujiang.com/#/app" target="_blank">More Apps</a><br><br>Generated by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a> v1.34.1
</div>
<script src="js/tocbot.js?v=1.33.2"></script>
<script src="js/tocbot.js?v=1.34.1"></script>
</body>
</html>
8 changes: 4 additions & 4 deletions js/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function copyTextToClipboard(text, cb) {
el.style = {
position: 'absolute',
left: '-9999px',
}
};
document.body.appendChild(el);
const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
el.select();
Expand All @@ -25,16 +25,16 @@ function copyTextToClipboard(text, cb) {
document.getSelection().addRange(selected);
}
cb && cb(isCopy);
};
}

function copied(target, str) {
target.classList.add('active');
const input = target.parentElement.querySelector('input');
if (input) {
copyTextToClipboard(input.value || '', function() {
copyTextToClipboard(input.value || '', function () {
setTimeout(() => {
target.classList.remove('active');
}, 2000);
});
}
}
}
8 changes: 4 additions & 4 deletions js/demo-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const demo = document.querySelectorAll('.idoc-demo-warpper .idoc-demo-previw');
function getButton(elm, type = 'BUTTON') {
let btn;
do {
elm = elm.nextElementSibling
elm = elm.nextElementSibling;
if (elm.tagName === type) {
btn = elm;
elm = undefined;
Expand All @@ -19,13 +19,13 @@ if (demo && demo.length > 0) {
if (button) {
button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code';
if (item.tagName === 'DIV') {
item.innerHTML = item.previousElementSibling.defaultValue
item.innerHTML = item.previousElementSibling.defaultValue;
}
button.onclick = () => {
item.classList.toggle('ishiden');
button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code';
}
};
}
}
});
}
}
46 changes: 23 additions & 23 deletions js/giscus.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
;(() => {
(() => {
const targetElement = document.documentElement;
const defaultTheme = targetElement.getAttribute("data-color-mode");
changeGiscusTheme(defaultTheme)
const defaultTheme = targetElement.getAttribute('data-color-mode');
changeGiscusTheme(defaultTheme);
const observer = new MutationObserver((mutationsList, observer) => {
for(const mutation of mutationsList) {
for (const mutation of mutationsList) {
if (mutation.type === 'attributes') {
const value = targetElement.getAttribute("data-color-mode");
changeGiscusTheme(value)
const value = targetElement.getAttribute('data-color-mode');
changeGiscusTheme(value);
}
}
});

observer.observe(targetElement, {
attributes: true,
attributeOldValue: true
attributeOldValue: true,
});
function changeGiscusTheme(theme = "light") {
const iframe = document.querySelector('.giscus-frame');
if (iframe) {
const config = {
giscus: {
setConfig: {
theme: theme.toLocaleLowerCase(),
},
}
};
iframe.contentWindow.postMessage(config, 'https://giscus.app');
const script = document.querySelector("script[data-script-id=\"giscus\"]")
script.setAttribute("data-theme", theme)
}

function changeGiscusTheme(theme = 'light') {
const iframe = document.querySelector('.giscus-frame');
if (iframe) {
const config = {
giscus: {
setConfig: {
theme: theme.toLocaleLowerCase(),
},
},
};
iframe.contentWindow.postMessage(config, 'https://giscus.app');
const script = document.querySelector('script[data-script-id="giscus"]');
script.setAttribute('data-theme', theme);
}
}
})();
82 changes: 40 additions & 42 deletions js/markdown-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @version 1.1.0
* @author 小弟调调
* https://github.com/jaywcjlove/markdown-style
*
*
* Integrate markdown styles into web components, Markdown CSS styles will not be conflicted.
* The minimal amount of CSS to replicate the GitHub Markdown style. Support dark-mode/night mode.
*/
Expand Down Expand Up @@ -1002,48 +1002,46 @@ markdown-style ::-webkit-calendar-picker-indicator {
<slot></slot>
`;
class MarkdownStyle extends HTMLElement {
get theme() {
const value = this.getAttribute('theme');
return value === null ? '' : value;
get theme() {
const value = this.getAttribute('theme');
return value === null ? '' : value;
}
set theme(name) {
this.setAttribute('theme', name);
}
constructor() {
super();
this.shadow = this.attachShadow({ mode: 'open' });
this.shadow.appendChild(__TEMPLATE__.content.cloneNode(true));
const style = Array.prototype.slice.call(this.shadow.children).find((item) => item.tagName === 'STYLE');
if (style) {
const id = '__MARKDOWN_STYLE__';
const findStyle = document.getElementById(id);
if (!findStyle) {
style.id = id;
document.head.append(style);
}
}
set theme(name) {
this.setAttribute('theme', name);
}
connectedCallback() {
const disableThemeAutoSwitch = this.getAttribute('theme-auto-switch-disabled');
if (disableThemeAutoSwitch == '' || (disableThemeAutoSwitch && disableThemeAutoSwitch.toLowerCase() === 'true')) {
return;
}
constructor() {
super();
this.shadow = this.attachShadow({ mode: 'open' });
this.shadow.appendChild(__TEMPLATE__.content.cloneNode(true));
const style = Array.prototype.slice
.call(this.shadow.children)
.find((item) => item.tagName === 'STYLE');
if (style) {
const id = '__MARKDOWN_STYLE__';
const findStyle = document.getElementById(id);
if (!findStyle) {
style.id = id;
document.head.append(style);
}
}
}
connectedCallback() {
const disableThemeAutoSwitch = this.getAttribute('theme-auto-switch-disabled');
if (disableThemeAutoSwitch == "" || disableThemeAutoSwitch && disableThemeAutoSwitch.toLowerCase() === 'true') {
return;
}
if (!this.theme) {
const { colorMode } = document.documentElement.dataset;
this.theme = colorMode;
const observer = new MutationObserver((mutationsList, observer) => {
this.theme = document.documentElement.dataset.colorMode;
});
observer.observe(document.documentElement, { attributes: true });
window.matchMedia('(prefers-color-scheme: light)').onchange = (event) => {
this.theme = event.matches ? 'light' : 'dark';
};
window.matchMedia('(prefers-color-scheme: dark)').onchange = (event) => {
this.theme = event.matches ? 'dark' : 'light';
};
}
if (!this.theme) {
const { colorMode } = document.documentElement.dataset;
this.theme = colorMode;
const observer = new MutationObserver((mutationsList, observer) => {
this.theme = document.documentElement.dataset.colorMode;
});
observer.observe(document.documentElement, { attributes: true });
window.matchMedia('(prefers-color-scheme: light)').onchange = (event) => {
this.theme = event.matches ? 'light' : 'dark';
};
window.matchMedia('(prefers-color-scheme: dark)').onchange = (event) => {
this.theme = event.matches ? 'dark' : 'light';
};
}
}
}
customElements.define('markdown-style', MarkdownStyle);
customElements.define('markdown-style', MarkdownStyle);
26 changes: 15 additions & 11 deletions js/tocbot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
;(() => {
(() => {
function debounce(fn, delay = 1000) {
let time = null
let time = null;
function _debounce(...args) {
if (time !== null) clearTimeout(time);
time = setTimeout(() => fn.apply(this, args), delay)
time = setTimeout(() => fn.apply(this, args), delay);
}
return _debounce
return _debounce;
}

const scrollSmoothOffset = 56;
Expand All @@ -25,7 +25,7 @@
location.hash = anchor.getAttribute('href');
updateScroll();
updateAnchor();
tocsCollapse()
tocsCollapse();
});
});
}
Expand Down Expand Up @@ -53,7 +53,7 @@
if (element) {
const tocElement = document.querySelector(`a.tocs-link[href='${decodeURIComponent(element.hash)}']`);
if (tocElement) {
updateAnchor(tocElement)
updateAnchor(tocElement);
tocsCollapse(tocElement);
} else {
const first = document.querySelector('a.tocs-link[href*="#"]');
Expand All @@ -65,7 +65,7 @@
}
}

document.addEventListener('scroll',debounce(scrollListener, 30), false);
document.addEventListener('scroll', debounce(scrollListener, 30), false);

function updateAnchor(element) {
const anchorContainer = document.querySelectorAll('.tocs aside.inner.toc a.tocs-link');
Expand Down Expand Up @@ -98,7 +98,12 @@
if (!element) {
element = document.querySelector(`a.tocs-link[href='${decodeURIComponent(location.hash)}']`);
}
if (element && element.parentElement && element.parentElement.tagName !== 'ASIDE' && !element.parentElement.classList.contains('toc')) {
if (
element &&
element.parentElement &&
element.parentElement.tagName !== 'ASIDE' &&
!element.parentElement.classList.contains('toc')
) {
isOpen(element.parentElement);
if (element.parentElement.classList.contains('is-collapsed')) {
element.parentElement.classList.add('is-open');
Expand All @@ -121,8 +126,7 @@
updateSiderBarScroll();
updateScroll();
updateAnchor();
tocsCollapse()
tocsCollapse();
clearTimeout(timer);
}, 100);

})();
})();
Loading

0 comments on commit d9b801f

Please sign in to comment.