From 45daec183cb2dbc2216cdd1592d367016579179a Mon Sep 17 00:00:00 2001 From: Martin99y Date: Wed, 14 Jul 2021 20:03:38 +0200 Subject: [PATCH] content-reference Hello i wrote a class to reference content in the html text itself its really easy to setup and visualizes propositions or theorems in a new window like footnote does. All some one needs to do is define a div which should be referenced later on
and then later reference the div with --- examples/content-ref.html | 78 +++++++++++++++++++++++++++++++++ src/components.js | 3 +- src/components/d-content-ref.js | 69 +++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 examples/content-ref.html create mode 100644 src/components/d-content-ref.js diff --git a/examples/content-ref.html b/examples/content-ref.html new file mode 100644 index 0000000..3e8d915 --- /dev/null +++ b/examples/content-ref.html @@ -0,0 +1,78 @@ + + + + + + + + + + + + + +
+
+
+

+Definition 1.6 + Let X and Y be sets. For all x\in X and y\in Y the pair (x,y) is defined as + the set \big\{ \{x \}, \{ x, y \} \big\}. The cartesian product + X \times Y is defined as +

+ \big\{ z \in \mathscr{P}(\mathscr{P}(X \cup Y)) \mid \exists x \in X \, \exists y \in Y : \: + z = \{ \{x \}, \{ x, y \}\} \big\} . + +

+
+
+

+See as an example. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

+
+

+Proposition 1.8 + Let L, M, N be sets. Then the following associativity law for the cartesian product is satisfied: + +

    + +
  1. + L \times (M \times N) = (L \times M) \times N. + +

+ + Moreover, the following distributivity laws hold true: + +

    + +
  1. + L \times (M \cup N) = (L \times M) \cup (L \times N) and + (M \cup N) \times L = (M \times L) \cup (N \times L), +
  2. + L \times (M \cap N) = (L \times M) \cap (L \times N) and + (M \cap N) \times L = (M \times L) \cap (N \times L), +
  3. + L \times (M \setminus N) = (L \times M) \setminus (L \times N) and + (M \setminus N) \times L = (M \times L) \setminus (N \times L). + +

+

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt + ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. +

+
+ + + diff --git a/src/components.js b/src/components.js index 4cd4477..5f68951 100644 --- a/src/components.js +++ b/src/components.js @@ -28,6 +28,7 @@ import { Byline } from './components/d-byline'; import { Cite } from './components/d-cite'; import { CitationList } from './components/d-citation-list'; import { Code } from './components/d-code'; +import { ContentRef } from './components/d-content-ref'; import { Footnote } from './components/d-footnote'; import { FootnoteList } from './components/d-footnote-list'; import { FrontMatter } from './components/d-front-matter'; @@ -83,7 +84,7 @@ const initialize = function() { /* 4. Register components */ const components = [ - Abstract, Appendix, Article, Bibliography, Byline, Cite, CitationList, Code, + Abstract, Appendix, Article, Bibliography, Byline, Cite, CitationList, Code,ContentRef, Footnote, FootnoteList, FrontMatter, HoverBox, Title, DMath, References, TOC, Figure, Slider, Interstitial ]; diff --git a/src/components/d-content-ref.js b/src/components/d-content-ref.js new file mode 100644 index 0000000..112b3a7 --- /dev/null +++ b/src/components/d-content-ref.js @@ -0,0 +1,69 @@ +// Copyright 2018 The Distill Template Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Template } from '../mixins/template.js'; + +const T = Template('d-content-ref', ` + + + +
+ +
+
+ + + +`); + + +export class ContentRef extends T(HTMLElement) { + + connectedCallback() { + var ref = this.getAttribute('ref') + ref = document.getElementById(ref); + ref = ref.innerHTML + this.innerHTML = ref + this.hoverBox = this.root.querySelector('d-hover-box'); + const val = this.getAttribute('val') + + window.customElements.whenDefined('d-hover-box').then(() => { + this.hoverBox.listen(this); + } + ); + const span = this.root.querySelector('#fn-'); + span.textContent = val; + + } +} \ No newline at end of file