wikidot编辑器网页版

无法获取插入的页面 ":scp-wiki-cn:theme:peroxide",可能是站点标识名有误,或您无权在该站点查看此页面

无法获取插入的页面 ":oxygennine:peroxide:palette-dark",可能是站点标识名有误,或您无权在该站点查看此页面

评分: +9+–x

需要加载一会·····

我制作了一个简易的维基语法/css/html高亮和自动补全

虽然无法和专业的补全相比,但支持维基语法的自动补全和高亮,

你点进来的时候就可以在下面编辑了,

记得保存,朋友如果你没有在沙盒保存的话,目前的编辑器不会调用浏览器缓存来保存你的进度所以一定要记得保存

在这个网页可以获得更好的编辑体验


@@

`;

window.insertCode = function(before, after = before) {
const view = window.editorInstance;
if (!view) return;
const { from, to } = view.state.selection.main;
const selectedText = view.state.doc.sliceString(from, to);
view.dispatch({
changes: { from, to, insert: `${before}${selectedText}${after}` },
selection: { anchor: from + before.length + selectedText.length }
});
view.focus();
};

window.handleAction = function(type) {
const view = window.editorInstance;
if (!view) return;

if (type === 'sync') {
const docContent = view.state.doc.toString();
const btn = document.querySelector('.btn-sync');
const originalText = btn.innerText;

// 降级复制方案 (处理 Wikidot 的无权限 iframe)
const fallbackCopy = (text) => {
const textArea = document.createElement("textarea");
textArea.value = text;
// 防止创建元素时页面跳动
textArea.style.top = "0";
textArea.style.left = "0";
textArea.style.position = "fixed";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();

try {
const successful = document.execCommand('copy');
if (successful) {
btn.innerText = "COPIED!";
setTimeout(() => btn.innerText = originalText, 2000);
} else {
btn.innerText = "FAILED";
btn.style.color = "red";
setTimeout(() => {
btn.innerText = originalText;
btn.style.color = "#00ff00";
}, 2000);
}
} catch (err) {
console.error('Fallback复制失败', err);
}
document.body.removeChild(textArea);
};

// 尝试用现代 API,如果报错(被 iframe 拦截)就走 Fallback
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(docContent).then(() => {
btn.innerText = "COPIED!";
setTimeout(() => btn.innerText = originalText, 2000);
}).catch(err => {
console.warn("现代剪贴板API被拦截,启用降级方案...");
fallbackCopy(docContent);
});
} else {
fallbackCopy(docContent);
}
} else if (type === 'clear') {
if (confirm("确定要清空所有内容吗?")) {
view.dispatch({
changes: { from: 0, to: view.state.doc.length, insert: "" }
});
}
} else if (type === 'init') {
if (confirm("确定要加载演示模板吗?这会覆盖当前内容。")) {
view.dispatch({
changes: { from: 0, to: view.state.doc.length, insert: EXAMPLE_CODE }
});
}
}
};

async function loadEditor() {
try {
// 导入远程 bundle
const module = await import('https://wasd243.github.io/SCP-Foundation-editor-web/assets/bundle_editor.js');

if (module.startEditor) {
module.startEditor();
} else if (window.startEditor) {
window.startEditor();
}

// 首次自动加载
setTimeout(() => {
if (window.editorInstance) {
window.editorInstance.dispatch({
changes: { from: 0, to: window.editorInstance.state.doc.length, insert: EXAMPLE_CODE }
});
document.getElementById('status').innerText = "Ready.";
setTimeout(() => document.getElementById('status').style.display = 'none', 2000);
}
}, 500);

} catch (err) {
document.getElementById('status').innerText = "加载失败: " + err.message;
}
}

window.addEventListener('load', loadEditor);
</script>
</body>
</html>

_default: uv至上 其他 文章
页面版本:36,最后编辑:2026年3月22日 21:30(UTC)
除非特别注明,本页内容采用以下授权方式:Creative Commons Attribution-ShareAlike 3.0 License。