fix(xml-editor): prettify xml even without root node

- update js dependencies to latest
- add indentWithTab to xml-editor
- tailwindcss 3.1: replace withOpacity with <alpha-value>
This commit is contained in:
Yassine Doghri 2022-07-02 17:15:29 +00:00
parent c9fb987fcf
commit ca55c248d0
20 changed files with 5449 additions and 4764 deletions

View File

@ -1,14 +1,21 @@
import { basicSetup } from "@codemirror/basic-setup";
import { indentWithTab } from "@codemirror/commands";
import { xml } from "@codemirror/lang-xml";
import { EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
import {
defaultHighlightStyle,
syntaxHighlighting,
} from "@codemirror/language";
import { Compartment, EditorState } from "@codemirror/state";
import { keymap } from "@codemirror/view";
import { basicSetup, EditorView } from "codemirror";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, queryAssignedNodes, state } from "lit/decorators.js";
import prettifyXML from "xml-formatter";
const language = new Compartment();
@customElement("xml-editor")
export class XMLEditor extends LitElement {
@queryAssignedNodes("textarea", true)
@queryAssignedNodes({ slot: "textarea" })
_textarea!: NodeListOf<HTMLTextAreaElement>;
@state()
@ -24,13 +31,39 @@ export class XMLEditor extends LitElement {
},
});
this.editorState = EditorState.create({
doc: this._textarea[0].value
? prettifyXML(this._textarea[0].value, {
let editorContents = "";
if (this._textarea[0].value) {
try {
editorContents = prettifyXML(this._textarea[0].value, {
indentation: " ",
});
} catch (e) {
// xml doesn't have a root node
editorContents = prettifyXML(
"<root>" + this._textarea[0].value + "</root>",
{
indentation: " ",
})
: "",
extensions: [basicSetup, xml(), minHeightEditor],
}
);
// remove root, unnecessary lines and indents
editorContents = editorContents
.replace(/^<root>/, "")
.replace(/<\/root>$/, "")
.replace(/^\s*[\r\n]/gm, "")
.replace(/[\r\n] {2}/gm, "\r\n")
.trim();
}
}
this.editorState = EditorState.create({
doc: editorContents,
extensions: [
basicSetup,
keymap.of([indentWithTab]),
language.of(xml()),
minHeightEditor,
syntaxHighlighting(defaultHighlightStyle),
],
});
this.editorView = new EditorView({

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ Podcastenden auf &nbsp;der&nbsp; ganzen Welt verwendet!
- 🌱 Kostenlos & Open-Source (AGPL v3 Lizenz)
- 🔐 &nbsp;Fokussiert auf die Datensouveränität: Ihre Inhalte, Ihr Publikum und
Analysen gehören zu Ihnen, und&nbsp;nur Ihnen&nbsp;
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,9 @@ et est utilisé par des podcasters partout autour du monde&nbsp;!
- 🌱 &nbsp;Libre, gratuit & open-source (Licence AGPL v3)
- 🔐 &nbsp;Focalisé sur la souveraineté des données: votre contenu, votre
audience et vos statistiques vous appartiennent, et à vous seulement
- 🪄&nbsp;Fonctionnalités de Podcasting 2.0 : GUID, verrouillage, transcriptions,
financement, chapitres, géo-localisation, intervenants, extraits sonores, …
- 🪄&nbsp;Fonctionnalités de Podcasting 2.0 : GUID, verrouillage,
transcriptions, financement, chapitres, géo-localisation, intervenants,
extraits sonores, …
- 💬 &nbsp;Réseau social intégré:
- 🚀 &nbsp;Castopod fait partie du Fédivers, un réseau social décentralisé
- ❤️ &nbsp;Créer des publications, partager, mettre en favori et commenter des

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -30,8 +30,8 @@ over heile verda&nbsp;bruker&nbsp;det!
- 🌱 &nbsp;Fri og open (AGPL v3-lisens)
- 🔐 &nbsp;Legg vekt på at du eig dine eigne data: innhaldet, publikum og
analysedata høyrer deg til, og&nbsp;berre&nbsp;deg
- 🪄 &nbsp;Podkasting 2.0-funksjonar: GUID, låsing, transkribering, finansiering,
kapittel, stader, personar, lydbetar…
- 🪄 &nbsp;Podkasting 2.0-funksjonar: GUID, låsing, transkribering,
finansiering, kapittel, stader, personar, lydbetar…
- 💬 &nbsp;Innebygd sosialt nettverk:
- 🚀 &nbsp;Castopod er ein del av fødiverset, som er eit desentralisert
sosialt nettverk

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

View File

@ -29,8 +29,8 @@ podcasters around&nbsp;the&nbsp;world!
- 🌱 &nbsp;Free & open-source (AGPL v3 License)
- 🔐 &nbsp;Focused on data sovereignty: your content, audience, and analytics
belong to you, and&nbsp;you&nbsp;only
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding, chapters,
location, persons, soundbites, …
- 🪄 &nbsp;Podcasting 2.0 features: GUID, locked, transcripts, funding,
chapters, location, persons, soundbites, …
- 💬 &nbsp;Built-in social network:
- 🚀 &nbsp;Castopod is part of the Fediverse, a decentralized social network
- ❤️ &nbsp;Create posts, share, favourite, and comment on episodes

9939
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,71 +27,71 @@
"prepare": "is-ci || husky install"
},
"dependencies": {
"@amcharts/amcharts4": "^4.10.24",
"@amcharts/amcharts4-geodata": "^4.1.22",
"@codemirror/basic-setup": "^0.19.1",
"@codemirror/commands": "^0.19.8",
"@codemirror/lang-xml": "^0.19.2",
"@codemirror/state": "^0.19.9",
"@codemirror/view": "^0.19.45",
"@floating-ui/dom": "^0.3.1",
"@amcharts/amcharts4": "^4.10.25",
"@amcharts/amcharts4-geodata": "^4.1.23",
"codemirror": "^6.0.1",
"@codemirror/commands": "^6.0.1",
"@codemirror/lang-xml": "^6.0.0",
"@codemirror/state": "^6.1.0",
"@codemirror/language": "^6.2.0",
"@floating-ui/dom": "^0.5.4",
"@github/clipboard-copy-element": "^1.1.2",
"@github/hotkey": "^2.0.0",
"@github/markdown-toolbar-element": "^2.1.0",
"@github/markdown-toolbar-element": "^2.1.1",
"@github/time-elements": "^3.1.2",
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
"@vime/core": "^5.3.1",
"choices.js": "^10.1.0",
"flatpickr": "^4.6.9",
"leaflet": "^1.7.1",
"flatpickr": "^4.6.13",
"leaflet": "^1.8.0",
"leaflet.markercluster": "^1.5.3",
"lit": "^2.2.0",
"marked": "^4.0.12",
"wavesurfer.js": "^6.0.2",
"lit": "^2.2.7",
"marked": "^4.0.17",
"wavesurfer.js": "^6.2.0",
"xml-formatter": "^2.6.1"
},
"devDependencies": {
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^7.0.4",
"@tailwindcss/forms": "^0.4.0-alpha.2",
"@tailwindcss/line-clamp": "^0.3.1",
"@semantic-release/gitlab": "^9.3.2",
"@tailwindcss/forms": "^0.5.2",
"@tailwindcss/line-clamp": "^0.4.0",
"@tailwindcss/typography": "^0.5.2",
"@types/leaflet": "^1.7.9",
"@types/marked": "^4.0.2",
"@types/wavesurfer.js": "^6.0.1",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"@types/leaflet": "^1.7.11",
"@types/marked": "^4.0.3",
"@types/wavesurfer.js": "^6.0.3",
"@typescript-eslint/eslint-plugin": "^5.30.3",
"@typescript-eslint/parser": "^5.30.3",
"cross-env": "^7.0.3",
"cssnano": "^5.0.17",
"cssnano": "^5.1.12",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.4.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"is-ci": "^3.0.1",
"lint-staged": "^12.3.4",
"postcss-import": "^14.0.2",
"postcss-nesting": "^10.1.2",
"postcss-preset-env": "^7.4.1",
"lint-staged": "^13.0.3",
"postcss-import": "^14.1.0",
"postcss-nesting": "^10.1.10",
"postcss-preset-env": "^7.7.2",
"postcss-reporter": "^7.0.5",
"prettier": "2.5.1",
"prettier-plugin-organize-imports": "^2.3.4",
"semantic-release": "^19.0.2",
"stylelint": "^14.5.3",
"stylelint-config-standard": "^25.0.0",
"prettier": "2.7.1",
"prettier-plugin-organize-imports": "^3.0.0",
"semantic-release": "^19.0.3",
"stylelint": "^14.9.1",
"stylelint-config-standard": "^26.0.0",
"svgo": "^2.8.0",
"tailwindcss": "^3.0.23",
"typescript": "^4.6.2",
"vite": "^2.8.6",
"vite-plugin-pwa": "^0.11.13",
"workbox-build": "^6.5.0",
"workbox-core": "^6.5.0",
"workbox-routing": "^6.5.0",
"workbox-strategies": "^6.5.0"
"tailwindcss": "^3.1.4",
"typescript": "^4.7.4",
"vite": "^2.9.13",
"vite-plugin-pwa": "^0.12.2",
"workbox-build": "^6.5.3",
"workbox-core": "^6.5.3",
"workbox-routing": "^6.5.3",
"workbox-strategies": "^6.5.3"
},
"lint-staged": {
"*.{js,ts,css,md,json}": "prettier --write",

View File

@ -2,7 +2,6 @@
module.exports = {
plugins: [
require("postcss-import"),
require("postcss-reporter"),
require("tailwindcss/nesting")(require("postcss-nesting")),
require("tailwindcss"),

View File

@ -1,15 +1,7 @@
/* eslint-disable */
const defaultTheme = require("tailwindcss/defaultTheme");
function withOpacity(variableName) {
return ({ opacityValue }) => {
if (opacityValue !== undefined) {
return `hsl(var(${variableName}) / ${opacityValue})`;
}
return `hsl(var(${variableName}))`;
};
}
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./app/Views/**/*.php",
@ -27,56 +19,57 @@ module.exports = {
},
textColor: {
skin: {
base: withOpacity("--color-text-base"),
muted: withOpacity("--color-text-muted"),
base: "hsl(var(--color-text-base) / <alpha-value>)",
muted: "hsl(var(--color-text-muted) / <alpha-value>)",
},
accent: {
base: withOpacity("--color-accent-base"),
hover: withOpacity("--color-accent-hover"),
muted: withOpacity("--color-accent-muted"),
contrast: withOpacity("--color-accent-contrast"),
base: "hsl(var(--color-accent-base) / <alpha-value>)",
hover: "hsl(var(--color-accent-hover) / <alpha-value>)",
muted: "hsl(var(--color-accent-muted) / <alpha-value>)",
contrast: "hsl(var(--color-accent-contrast) / <alpha-value>)",
},
},
backgroundColor: {
base: withOpacity("--color-background-base"),
elevated: withOpacity("--color-background-elevated"),
navigation: withOpacity("--color-background-navigation"),
backdrop: withOpacity("--color-background-backdrop"),
header: withOpacity("--color-background-header"),
base: "hsl(var(--color-background-base) / <alpha-value>)",
elevated: "hsl(var(--color-background-elevated) / <alpha-value>)",
navigation: "hsl(var(--color-background-navigation) / <alpha-value>)",
backdrop: "hsl(var(--color-background-backdrop) / <alpha-value>)",
header: "hsl(var(--color-background-header) / <alpha-value>)",
accent: {
base: withOpacity("--color-accent-base"),
hover: withOpacity("--color-accent-hover"),
base: "hsl(var(--color-accent-base) / <alpha-value>)",
hover: "hsl(var(--color-accent-hover) / <alpha-value>)",
},
highlight: withOpacity("--color-background-highlight"),
highlight: "hsl(var(--color-background-highlight) / <alpha-value>)",
},
borderColor: {
subtle: withOpacity("--color-border-subtle"),
contrast: withOpacity("--color-border-contrast"),
navigation: withOpacity("--color-border-navigation"),
"navigation-bg": withOpacity("--color-background-navigation"),
subtle: "hsl(var(--color-border-subtle) / <alpha-value>)",
contrast: "hsl(var(--color-border-contrast) / <alpha-value>)",
navigation: "hsl(var(--color-border-navigation) / <alpha-value>)",
"navigation-bg":
"hsl(var(--color-background-navigation) / <alpha-value>)",
accent: {
base: withOpacity("--color-accent-base"),
hover: withOpacity("--color-accent-hover"),
base: "hsl(var(--color-accent-base) / <alpha-value>)",
hover: "hsl(var(--color-accent-hover) / <alpha-value>)",
},
background: {
base: withOpacity("--color-background-base"),
elevated: withOpacity("--color-background-elevated"),
base: "hsl(var(--color-background-base) / <alpha-value>)",
elevated: "hsl(var(--color-background-elevated) / <alpha-value>)",
},
},
ringColor: {
contrast: withOpacity("--color-border-contrast"),
contrast: "hsl(var(--color-border-contrast) / <alpha-value>)",
background: {
base: withOpacity("--color-background-base"),
elevated: withOpacity("--color-background-elevated"),
base: "hsl(var(--color-background-base) / <alpha-value>)",
elevated: "hsl(var(--color-background-elevated) / <alpha-value>)",
},
},
colors: {
background: {
header: withOpacity("--color-background-header"),
header: "hsl(var(--color-background-header) / <alpha-value>)",
},
heading: {
foreground: withOpacity("--color-heading-foreground"),
background: withOpacity("--color-heading-background"),
foreground: "hsl(var(--color-heading-foreground) / <alpha-value>)",
background: "hsl(var(--color-heading-background) / <alpha-value>)",
},
pine: {
50: "#F2FAF9",