@miliastry/quasar 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Visuals/lyne.css +257 -3
- package/dist/Visuals/osu.css +357 -6
- package/dist/index.js +850 -98
- package/dist/index.mjs +846 -99
- package/dist/types/BBCode/BBCodeDocumentModel.d.ts +11 -1
- package/dist/types/Visitors/DOMMorpher.d.ts +6 -0
- package/dist/types/Visitors/HTMLRenderer.d.ts +120 -8
- package/dist/types/Visitors/index.d.ts +1 -1
- package/dist/types/Visuals/BoxDrawer.d.ts +10 -5
- package/dist/types/Visuals/LyneAudio.d.ts +8 -0
- package/dist/types/Visuals/index.d.ts +1 -0
- package/dist/types/index.d.ts +4 -3
- package/package.json +1 -1
- package/src/BBCode/BBCodeDocumentModel.ts +36 -1
- package/src/HTML/HTMLToGreenNode.ts +8 -0
- package/src/Semantic/SemanticAnalyzer.ts +43 -0
- package/src/Visitors/BBCodeExporter.ts +51 -5
- package/src/Visitors/BlockPatcher.ts +36 -11
- package/src/Visitors/DOMMorpher.ts +44 -38
- package/src/Visitors/HTMLRenderer.ts +402 -59
- package/src/Visitors/index.ts +1 -1
- package/src/Visuals/BoxDrawer.ts +56 -10
- package/src/Visuals/LyneAudio.ts +346 -0
- package/src/Visuals/index.ts +1 -0
- package/src/Visuals/lyne.css +257 -3
- package/src/Visuals/osu.css +357 -6
- package/src/index.ts +6 -3
|
@@ -97,44 +97,7 @@ function morphNodes(parent: Node, newParent: Node): void {
|
|
|
97
97
|
newNode.nodeType === 1 &&
|
|
98
98
|
(oldNode as Element).tagName === (newNode as Element).tagName
|
|
99
99
|
) {
|
|
100
|
-
|
|
101
|
-
const newEl = newNode as Element
|
|
102
|
-
|
|
103
|
-
// Preserve interactive runtime states (such as <details open> for spoilerboxes and boxes)
|
|
104
|
-
if (oldEl.tagName === 'DETAILS' && oldEl.hasAttribute('open')) {
|
|
105
|
-
newEl.setAttribute('open', '')
|
|
106
|
-
}
|
|
107
|
-
if (oldEl.classList.contains('open')) {
|
|
108
|
-
newEl.classList.add('open')
|
|
109
|
-
}
|
|
110
|
-
if (oldEl.classList.contains('is-open')) {
|
|
111
|
-
newEl.classList.add('is-open')
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Sync attributes in-place.
|
|
115
|
-
//
|
|
116
|
-
// `attributes` se recorre por índice: `Array.from` asignaba un array
|
|
117
|
-
// por elemento y por sentido, dos por pareja morfada, y esto corre
|
|
118
|
-
// sobre la ventana cambiada en cada pulsación.
|
|
119
|
-
const newAttrs = newEl.attributes
|
|
120
|
-
for (let i = 0; i < newAttrs.length; i++) {
|
|
121
|
-
const attr = newAttrs[i]
|
|
122
|
-
if (oldEl.getAttribute(attr.name) !== attr.value) {
|
|
123
|
-
oldEl.setAttribute(attr.name, attr.value)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// Hacia atrás: quitar un atributo compacta la colección viva, y
|
|
127
|
-
// recorrerla hacia delante mientras se borra se salta el siguiente.
|
|
128
|
-
const oldAttrs = oldEl.attributes
|
|
129
|
-
for (let i = oldAttrs.length - 1; i >= 0; i--) {
|
|
130
|
-
const name = oldAttrs[i].name
|
|
131
|
-
if (!newEl.hasAttribute(name)) {
|
|
132
|
-
oldEl.removeAttribute(name)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Morph child nodes recursively
|
|
137
|
-
morphNodes(oldEl, newEl)
|
|
100
|
+
morphElement(oldNode as Element, newNode as Element)
|
|
138
101
|
} else {
|
|
139
102
|
// Different tag or nodeType: replace node
|
|
140
103
|
oldNode.parentNode!.replaceChild(newNode.cloneNode(true), oldNode)
|
|
@@ -142,3 +105,46 @@ function morphNodes(parent: Node, newParent: Node): void {
|
|
|
142
105
|
}
|
|
143
106
|
}
|
|
144
107
|
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Reconcile two HTML elements of the same tag in-place.
|
|
111
|
+
* Syncs attributes, preserves interactive states (<details open>, .open classes),
|
|
112
|
+
* and recursively morphs child nodes.
|
|
113
|
+
*/
|
|
114
|
+
export function morphElement(oldEl: Element, newEl: Element): void {
|
|
115
|
+
// Preserve interactive runtime states (such as <details open> for spoilerboxes and boxes)
|
|
116
|
+
if (oldEl.tagName === 'DETAILS' && oldEl.hasAttribute('open')) {
|
|
117
|
+
newEl.setAttribute('open', '')
|
|
118
|
+
}
|
|
119
|
+
if (oldEl.classList.contains('open')) {
|
|
120
|
+
newEl.classList.add('open')
|
|
121
|
+
}
|
|
122
|
+
if (oldEl.classList.contains('is-open')) {
|
|
123
|
+
newEl.classList.add('is-open')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Sync attributes in-place.
|
|
127
|
+
//
|
|
128
|
+
// `attributes` se recorre por índice: `Array.from` asignaba un array
|
|
129
|
+
// por elemento y por sentido, dos por pareja morfada, y esto corre
|
|
130
|
+
// sobre la ventana cambiada en cada pulsación.
|
|
131
|
+
const newAttrs = newEl.attributes
|
|
132
|
+
for (let i = 0; i < newAttrs.length; i++) {
|
|
133
|
+
const attr = newAttrs[i]
|
|
134
|
+
if (oldEl.getAttribute(attr.name) !== attr.value) {
|
|
135
|
+
oldEl.setAttribute(attr.name, attr.value)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Hacia atrás: quitar un atributo compacta la colección viva, y
|
|
139
|
+
// recorrerla hacia delante mientras se borra se salta el siguiente.
|
|
140
|
+
const oldAttrs = oldEl.attributes
|
|
141
|
+
for (let i = oldAttrs.length - 1; i >= 0; i--) {
|
|
142
|
+
const name = oldAttrs[i].name
|
|
143
|
+
if (!newEl.hasAttribute(name)) {
|
|
144
|
+
oldEl.removeAttribute(name)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Morph child nodes recursively
|
|
149
|
+
morphNodes(oldEl, newEl)
|
|
150
|
+
}
|