增加注入更改VisualEditor的标题选择器

master
落雨楓 1 year ago
parent caed544561
commit fa0a99203c

@ -121,9 +121,9 @@
"mobile"
]
},
"ext.isekai.ve": {
"ve.ext.isekai.misc": {
"scripts": [
"ext.isekai.ve.js"
"ve.ext.isekai.misc.js"
],
"targets": [
"desktop",
@ -131,8 +131,15 @@
],
"dependencies": [
"ext.visualEditor.mwcore",
"ext.visualEditor.mwmeta",
"ext.visualEditor.desktopArticleTarget"
"ext.visualEditor.mwextensions"
],
"messages": [
"isekai-ve-formatdropdown-format-mw-heading1",
"isekai-ve-formatdropdown-format-mw-heading2",
"isekai-ve-formatdropdown-format-mw-heading3",
"isekai-ve-formatdropdown-format-mw-heading4",
"isekai-ve-formatdropdown-format-mw-heading5",
"isekai-ve-formatdropdown-format-mw-heading6"
]
},
"ext.isekai.function-btn": {
@ -153,6 +160,13 @@
]
}
},
"attributes": {
"VisualEditor": {
"PluginModules": [
"ve.ext.isekai.misc"
]
}
},
"ResourceFileModulePaths": {
"localBasePath": "modules",
"remoteExtPath": "IsekaiMisc/modules"

@ -38,5 +38,12 @@
"isekai-function-btn-exit-fullscreen": "Exit full screen",
"group-activated-editor": "Editor",
"group-activated-editor-member": "Editor"
"group-activated-editor-member": "Editor",
"isekai-ve-formatdropdown-format-mw-heading1": "Heading",
"isekai-ve-formatdropdown-format-mw-heading2": "Sub-heading",
"isekai-ve-formatdropdown-format-mw-heading3": "Sub-heading 3",
"isekai-ve-formatdropdown-format-mw-heading4": "Sub-heading 4",
"isekai-ve-formatdropdown-format-mw-heading5": "Sub-heading 5",
"isekai-ve-formatdropdown-format-mw-heading6": "Sub-heading 6"
}

@ -38,5 +38,12 @@
"isekai-function-btn-exit-fullscreen": "退出全屏",
"group-activated-editor": "作者",
"group-activated-editor-member": "作者"
"group-activated-editor-member": "作者",
"isekai-ve-formatdropdown-format-mw-heading1": "标题",
"isekai-ve-formatdropdown-format-mw-heading2": "子标题",
"isekai-ve-formatdropdown-format-mw-heading3": "三级标题",
"isekai-ve-formatdropdown-format-mw-heading4": "四级标题",
"isekai-ve-formatdropdown-format-mw-heading5": "五级标题",
"isekai-ve-formatdropdown-format-mw-heading6": "六级标题"
}

@ -38,5 +38,12 @@
"isekai-function-btn-exit-fullscreen": "退出全屏",
"group-activated-editor": "作者",
"group-activated-editor-member": "作者"
"group-activated-editor-member": "作者",
"isekai-ve-formatdropdown-format-mw-heading1": "標題",
"isekai-ve-formatdropdown-format-mw-heading2": "子標題",
"isekai-ve-formatdropdown-format-mw-heading3": "三级標題",
"isekai-ve-formatdropdown-format-mw-heading4": "四级標題",
"isekai-ve-formatdropdown-format-mw-heading5": "五级標題",
"isekai-ve-formatdropdown-format-mw-heading6": "六级標題"
}

@ -0,0 +1,35 @@
function updateVisualEditorConfig() {
if (ve) {
if (ve.init && ve.init.mw && ve.init.mw.Target) {
ve.init.mw.Target.static.toolbarGroups.forEach(function (toolbarItem) {
if (toolbarItem.name === 'format') {
// 将heading1从demote中移除防止heading1出现在底部
toolbarItem.demote = toolbarItem.demote.filter(function (item) {
return item !== 'heading1';
});
}
});
} else {
console.warn('Cannot find "ve.init.Target"');
}
if (ve.ui) {
// 重命名heading1-6
for (var i = 1; i <= 6; i ++) {
var className = 'MWHeading' + i + 'FormatTool';
var msgId = 'isekai-ve-formatdropdown-format-mw-heading' + i;
if (ve.ui[className]) {
ve.ui[className].static.title = OO.ui.deferMsg(msgId);
} else {
console.warn('Cannot find "ve.ui.' + className + '"');
}
}
} else {
console.warn('Cannot find "ve.ui"');
}
} else {
console.warn('Cannot find ve lib');
}
}
updateVisualEditorConfig();
Loading…
Cancel
Save