Prepare LaySite 1.4.5 site icons, Head settings and release images
This commit is contained in:
+15
-3
@@ -435,15 +435,27 @@
|
||||
@media (max-width: 42rem) { .media-filters { grid-template-columns: minmax(0, 1fr); } }
|
||||
|
||||
.canvas-source { width: min(56rem, calc(100% - 2rem)); }
|
||||
.canvas-source textarea { font: .9rem / 1.55 var(--mono); tab-size: 4; }
|
||||
.canvas-source .CodeMirror {
|
||||
:is(.canvas-source, .head-settings) textarea { font: .9rem / 1.55 var(--mono); tab-size: 4; }
|
||||
:is(.canvas-source, .head-settings) .CodeMirror {
|
||||
height: clamp(12rem, 50vh, 32rem);
|
||||
margin-top: .4rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: .5rem;
|
||||
font: .9rem / 1.55 var(--mono);
|
||||
}
|
||||
.canvas-source .CodeMirror-focused { outline: 2px solid var(--accent); outline-offset: 1px; }
|
||||
:is(.canvas-source, .head-settings) .CodeMirror-focused { outline: 2px solid var(--accent); outline-offset: 1px; }
|
||||
.head-settings-fields { display: grid; gap: .65rem; margin-block-start: .6rem; }
|
||||
.head-settings .CodeMirror { height: clamp(13rem, 38vh, 22rem); margin: 0; }
|
||||
.favicon-editor-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
|
||||
.favicon-preview {
|
||||
display: grid; place-items: center; inline-size: 6rem; block-size: 6rem;
|
||||
border: 1px solid var(--line); border-radius: .65rem; background: var(--paper);
|
||||
}
|
||||
.favicon-preview :is(img, canvas) { inline-size: 4rem; block-size: 4rem; object-fit: contain; }
|
||||
.favicon-editor-controls { display: grid; gap: .5rem; flex: 1 1 16rem; min-width: 0; }
|
||||
.favicon-crop-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; }
|
||||
.favicon-crop-controls input { width: 100%; margin: 0; accent-color: var(--accent); }
|
||||
@media (max-width: 32rem) { .favicon-crop-controls { grid-template-columns: minmax(0, 1fr); } }
|
||||
.picker-actions { justify-content: flex-start; margin-top: .85rem; }
|
||||
.admin-action-dialog { max-width: min(30rem, calc(100% - 2rem)); }
|
||||
.admin-action-dialog h2, #media-picker h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.018em; }
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
jQuery(function ($) {
|
||||
$('[data-favicon-editor]').each(function () {
|
||||
const $editor = $(this);
|
||||
const $form = $editor.closest('form');
|
||||
const $status = $editor.find('[data-favicon-status]');
|
||||
const $action = $editor.find('[name=favicon_action]');
|
||||
const $png = $editor.find('[name=favicon_png]');
|
||||
const $file = $editor.find('[data-favicon-file]');
|
||||
const $current = $editor.find('[data-favicon-current]');
|
||||
const $controls = $editor.find('[data-favicon-controls]');
|
||||
const $zoom = $controls.find('[data-favicon-zoom]');
|
||||
const $x = $controls.find('[data-favicon-x]');
|
||||
const $y = $controls.find('[data-favicon-y]');
|
||||
const $reset = $editor.find('[data-favicon-reset]');
|
||||
const $canvas = $editor.find('[data-favicon-canvas]');
|
||||
const canvas = $canvas.get(0);
|
||||
const context = canvas.getContext('2d');
|
||||
let image;
|
||||
let selection = 0;
|
||||
|
||||
function draw() {
|
||||
if (!image) return;
|
||||
const {naturalWidth: width, naturalHeight: height} = image;
|
||||
const side = Math.min(width, height) / Number($zoom.val());
|
||||
const x = (width - side) * Number($x.val()) / 100;
|
||||
const y = (height - side) * Number($y.val()) / 100;
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
context.drawImage(image, x, y, side, side, 0, 0, canvas.width, canvas.height);
|
||||
$png.val(canvas.toDataURL('image/png').split(',')[1]);
|
||||
}
|
||||
|
||||
async function selectImage(url) {
|
||||
const currentSelection = ++selection;
|
||||
const $submit = $form.find(':submit');
|
||||
$submit.prop('disabled', true);
|
||||
$status.text('正在读取图片…');
|
||||
try {
|
||||
const next = new Image();
|
||||
next.src = url;
|
||||
await next.decode();
|
||||
if (currentSelection !== selection) return;
|
||||
if (!next.naturalWidth || !next.naturalHeight || Math.max(next.naturalWidth, next.naturalHeight) > 8192) {
|
||||
throw new Error('Unsupported image dimensions');
|
||||
}
|
||||
image = next;
|
||||
$zoom.val(1);
|
||||
$x.add($y).val(50);
|
||||
draw();
|
||||
$action.val('replace');
|
||||
$controls.add($canvas).add($reset).prop('hidden', false);
|
||||
$current.prop('hidden', true);
|
||||
$status.text('调整裁剪范围后,点击「保存设置」。');
|
||||
} catch {
|
||||
if (currentSelection === selection) $status.text('无法读取图片,请选择边长不超过 8192 px 的常见图片格式。');
|
||||
} finally {
|
||||
if (currentSelection === selection) $submit.prop('disabled', false);
|
||||
if (url.startsWith('blob:')) URL.revokeObjectURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
$file.on('change', function () {
|
||||
const [file] = this.files;
|
||||
if (!file) return;
|
||||
if (file.size > 16 * 1024 * 1024) {
|
||||
$status.text('请选用不超过 16 MB 的源图片。');
|
||||
return;
|
||||
}
|
||||
selectImage(URL.createObjectURL(file));
|
||||
});
|
||||
$controls.on('input', 'input', draw);
|
||||
$editor.on('click', '[data-favicon-library]', () => {
|
||||
$('#media-picker').trigger('studio:pick', ['image/', (file) => {
|
||||
$file.val('');
|
||||
selectImage(file.url);
|
||||
}]);
|
||||
});
|
||||
$reset.on('click', () => {
|
||||
++selection;
|
||||
image = null;
|
||||
$file.val('');
|
||||
$action.val('reset');
|
||||
$png.val('');
|
||||
$canvas.add($controls).add($reset).prop('hidden', true);
|
||||
$current.attr('src', $editor.data('defaultIcon')).prop('hidden', false);
|
||||
$form.find(':submit').prop('disabled', false);
|
||||
$status.text('保存设置后将恢复默认图标。');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
jQuery(function ($) {
|
||||
$('[data-head-settings]').each(function () {
|
||||
const $details = $(this);
|
||||
const source = $details.find('[data-head-source]').get(0);
|
||||
let editor;
|
||||
$details.on('toggle', () => {
|
||||
if (!this.open || !window.CodeMirror) return;
|
||||
if (!editor) {
|
||||
editor = window.CodeMirror.fromTextArea(source, {
|
||||
mode: 'htmlmixed', lineNumbers: true, lineWrapping: true, indentUnit: 2, tabSize: 2,
|
||||
});
|
||||
editor.getInputField().setAttribute('aria-labelledby', 'head-source-label');
|
||||
editor.on('change', () => editor.save());
|
||||
}
|
||||
editor.refresh();
|
||||
});
|
||||
$details.on('click', '[data-head-asset]', function () {
|
||||
const mime = this.dataset.headAsset;
|
||||
$('#media-picker').trigger('studio:pick', [mime, (file) => {
|
||||
const tag = mime === 'text/css'
|
||||
? $('<link>', {rel: 'stylesheet', href: file.url})
|
||||
: $('<script>', {src: file.url, defer: true});
|
||||
const value = tag.prop('outerHTML') + '\n';
|
||||
if (editor) {
|
||||
editor.replaceSelection(value);
|
||||
editor.focus();
|
||||
} else {
|
||||
source.setRangeText(value, source.selectionStart, source.selectionEnd, 'end');
|
||||
source.focus();
|
||||
}
|
||||
}]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -121,7 +121,7 @@ jQuery(function ($) {
|
||||
$cards.each(function () {
|
||||
const $card = $(this);
|
||||
const mime = $card.data('mime');
|
||||
const matchesType = category === 'other' ? !/^(image|audio|video)\//.test(mime) : mime.startsWith(category);
|
||||
const matchesType = category === 'other' ? !/^(image|audio|video|text)\//.test(mime) : mime.startsWith(category);
|
||||
const visible = matchesType && $card.data('search').toLowerCase().includes(query);
|
||||
$card.prop('hidden', !visible);
|
||||
if (visible) count++;
|
||||
@@ -407,9 +407,10 @@ jQuery(function ($) {
|
||||
let deletedSections = [];
|
||||
const propertyInput = (name) => $propertyForm.find('[name="' + name + '"]');
|
||||
const pageInput = (name) => $settings.find('[name="' + name + '"]');
|
||||
const settingsSnapshot = () => $settings.serializeArray()
|
||||
.filter(({name}) => !['csrf', 'canvas_sections', 'canvas_order', 'provider_secret'].includes(name));
|
||||
let savedSettings = JSON.stringify(settingsSnapshot());
|
||||
const settingsSnapshot = (includeHead = false) => $settings.serializeArray()
|
||||
.filter(({name}) => !['csrf', 'canvas_sections', 'canvas_order', 'provider_secret'].includes(name)
|
||||
&& (includeHead || name !== 'head_html'));
|
||||
let savedSettings = JSON.stringify(settingsSnapshot(true));
|
||||
let dialogAction;
|
||||
let doc;
|
||||
let activeBody;
|
||||
@@ -620,7 +621,7 @@ jQuery(function ($) {
|
||||
$(window).on('beforeunload', (event) => {
|
||||
if (!saveComplete && (sectionChanges(false).length || pageInput('provider_secret').filter(':enabled').val()
|
||||
|| initialOrder !== undefined && canvasOrder() !== initialOrder
|
||||
|| JSON.stringify(settingsSnapshot()) !== savedSettings)) {
|
||||
|| JSON.stringify(settingsSnapshot(true)) !== savedSettings)) {
|
||||
event.preventDefault();
|
||||
event.originalEvent.returnValue = '';
|
||||
}
|
||||
@@ -2355,7 +2356,7 @@ jQuery(function ($) {
|
||||
initialOrder = canvasOrder();
|
||||
syncMemberSettings();
|
||||
syncPagePresentation();
|
||||
savedSettings = JSON.stringify(settingsSnapshot());
|
||||
savedSettings = JSON.stringify(settingsSnapshot(true));
|
||||
history.length = 0;
|
||||
historyIndex = 0;
|
||||
lastHistoryGroup = null;
|
||||
|
||||
+8
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Minified by jsDelivr using Terser v5.39.0.
|
||||
* Original file: /npm/codemirror@5.65.21/mode/htmlmixed/htmlmixed.js
|
||||
*
|
||||
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
||||
*/
|
||||
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],t):t(CodeMirror)}((function(t){"use strict";var e={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]};var a={};function n(t,e){var n=t.match(function(t){var e=a[t];return e||(a[t]=new RegExp("\\s+"+t+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"))}(e));return n?/^\s*(.*?)\s*$/.exec(n[2])[1]:""}function l(t,e){return new RegExp((e?"^":"")+"</\\s*"+t+"\\s*>","i")}function r(t,e){for(var a in t)for(var n=e[a]||(e[a]=[]),l=t[a],r=l.length-1;r>=0;r--)n.unshift(l[r])}t.defineMode("htmlmixed",(function(a,o){var i=t.getMode(a,{name:"xml",htmlMode:!0,multilineTagIndentFactor:o.multilineTagIndentFactor,multilineTagIndentPastTag:o.multilineTagIndentPastTag,allowMissingTagName:o.allowMissingTagName}),c={},s=o&&o.tags,u=o&&o.scriptTypes;if(r(e,c),s&&r(s,c),u)for(var m=u.length-1;m>=0;m--)c.script.unshift(["type",u[m].matches,u[m].mode]);function d(e,r){var o,s=i.token(e,r.htmlState),u=/\btag\b/.test(s);if(u&&!/[<>\s\/]/.test(e.current())&&(o=r.htmlState.tagName&&r.htmlState.tagName.toLowerCase())&&c.hasOwnProperty(o))r.inTag=o+" ";else if(r.inTag&&u&&/>$/.test(e.current())){var m=/^([\S]+) (.*)/.exec(r.inTag);r.inTag=null;var f=">"==e.current()&&function(t,e){for(var a=0;a<t.length;a++){var l=t[a];if(!l[0]||l[1].test(n(e,l[0])))return l[2]}}(c[m[1]],m[2]),g=t.getMode(a,f),p=l(m[1],!0),h=l(m[1],!1);r.token=function(t,e){return t.match(p,!1)?(e.token=d,e.localState=e.localMode=null,null):function(t,e,a){var n=t.current(),l=n.search(e);return l>-1?t.backUp(n.length-l):n.match(/<\/?$/)&&(t.backUp(n.length),t.match(e,!1)||t.match(n)),a}(t,h,e.localMode.token(t,e.localState))},r.localMode=g,r.localState=t.startState(g,i.indent(r.htmlState,"",""))}else r.inTag&&(r.inTag+=e.current(),e.eol()&&(r.inTag+=" "));return s}return{startState:function(){return{token:d,inTag:null,localMode:null,localState:null,htmlState:t.startState(i)}},copyState:function(e){var a;return e.localState&&(a=t.copyState(e.localMode,e.localState)),{token:e.token,inTag:e.inTag,localMode:e.localMode,localState:a,htmlState:t.copyState(i,e.htmlState)}},token:function(t,e){return e.token(t,e)},indent:function(e,a,n){return!e.localMode||/^\s*<\//.test(a)?i.indent(e.htmlState,a,n):e.localMode.indent?e.localMode.indent(e.localState,a,n):t.Pass},innerMode:function(t){return{state:t.localState||t.htmlState,mode:t.localMode||i}}}}),"xml","javascript","css"),t.defineMIME("text/html","htmlmixed")}));
|
||||
//# sourceMappingURL=/sm/e2c7ccb5e794d8515250b328c4947e850defb14ee2247c63cd3549e4879addb0.map
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user