From d86195c3b7dc2726a9eff10fdb2b9f5190ca15fe Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 14 Jan 2025 16:15:17 +0100 Subject: [PATCH] numeracja --- src/redakcja/static/css/html.scss | 24 +++++++++++++++++++ .../static/js/wiki/view_editor_wysiwyg.js | 18 ++++++++++++++ src/wlxml/templates/wlxml/wl2html.xsl | 14 +++++++++++ 3 files changed, 56 insertions(+) diff --git a/src/redakcja/static/css/html.scss b/src/redakcja/static/css/html.scss index 91482107..3819c821 100644 --- a/src/redakcja/static/css/html.scss +++ b/src/redakcja/static/css/html.scss @@ -556,3 +556,27 @@ div[x-node] > .uwaga { } } } + + + +div[x-node="numeracja"] { + background: lightblue; + margin: 2em; + padding: 2em; + border-radius: 1em; + &::before { + content: "Reset numeracji"; + } +} + +*[x-number]::before { + display: block; + content: attr(x-number); + position: absolute; + text-align: right; + width: 40px; + left: -60px; + font-size: .9em; + opacity: .8; + +} diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index c5fa8c13..2e1c28d2 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -753,6 +753,7 @@ callback(); } + let self = this; xml2html({ xml: this.doc.text, base: this.doc.getBase(), @@ -760,6 +761,7 @@ var htmlView = $('#html-view'); htmlView.html(element); + self.renumber(); if ('PropertiesPerspective' in $.wiki.perspectives) $.wiki.perspectives.PropertiesPerspective.enable(); @@ -942,6 +944,22 @@ } }) } + + renumber() { + let number = 0; + $('#html-view *').each((i, e) => { + let $e = $(e); + if ($e.closest('[x-node="abstrakt"]').length) return; + if ($e.closest('[x-node="nota_red"]').length) return; + let node = $e.attr('x-node'); + if (node == 'numeracja') { + number = 0; + } else if (['werset', 'akap', 'wers'].includes(node)) { + number ++; + $e.attr('x-number', number); + } + }) + } } $.wiki.VisualPerspective = VisualPerspective; diff --git a/src/wlxml/templates/wlxml/wl2html.xsl b/src/wlxml/templates/wlxml/wl2html.xsl index fbb66fba..9716e19f 100644 --- a/src/wlxml/templates/wlxml/wl2html.xsl +++ b/src/wlxml/templates/wlxml/wl2html.xsl @@ -57,6 +57,20 @@ + +
+ +
+ + + + + + +
+
+
+