2236d2ef24
refs TryGhost/Team#2904 <!-- Leave the line below if you'd like GitHub Copilot to generate a summary from your commit --> <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 2ba5e2a</samp> This pull request adds the lexical editor feature to the Ghost admin app, which allows users to create and edit snippets in a natural language format. It modifies the `snippet` model, adapter, and controller, and the `lexical-editor` template and component to support the new feature.
21 lines
623 B
JavaScript
21 lines
623 B
JavaScript
import ApplicationAdapter from 'ghost-admin/adapters/application';
|
|
|
|
export default class Snippet extends ApplicationAdapter {
|
|
buildURL() {
|
|
const url = super.buildURL(...arguments);
|
|
|
|
try {
|
|
const parsedUrl = new URL(url);
|
|
if (!parsedUrl.searchParams.get('formats')) {
|
|
parsedUrl.searchParams.set('formats', 'mobiledoc,lexical');
|
|
return parsedUrl.href;
|
|
}
|
|
} catch (e) {
|
|
// noop, just use the original url
|
|
console.error('Couldn\'t parse URL', e); // eslint-disable-line
|
|
}
|
|
|
|
return url;
|
|
}
|
|
}
|