@startinblox/core 0.17.30 → 0.17.31

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.
@@ -13,6 +13,7 @@
13
13
  "lit-html/directives/unsafe-html": "./lit-html/directives/unsafe-html.js",
14
14
  "lit-html/directives/until": "./lit-html/directives/until.js",
15
15
  "markdown-it": "./markdown-it.js",
16
+ "markdown-it-link-attributes": "./markdown-it-link-attributes.js",
16
17
  "quill": "./quill.js",
17
18
  "quill-delta-to-markdown": "./quill-delta-to-markdown.js",
18
19
  "quill/dist/quill.snow.css": "./quill/dist/quill.snow.css",
@@ -0,0 +1,87 @@
1
+ // Adapted from https://github.com/markdown-it/markdown-it/blob/fbc6b0fed563ba7c00557ab638fd19752f8e759d/docs/architecture.md
2
+
3
+ function findFirstMatchingConfig(link, configs) {
4
+ var i, config;
5
+ var href = link.attrs[link.attrIndex("href")][1];
6
+
7
+ for (i = 0; i < configs.length; ++i) {
8
+ config = configs[i];
9
+
10
+ // If there is a matcher function defined then call it
11
+ // Matcher Function should return a boolean indicating
12
+ // whether or not it matched. If it matched, use that
13
+ // configuration, otherwise, try the next one.
14
+ if (typeof config.matcher === "function") {
15
+ if (config.matcher(href, config)) {
16
+ return config;
17
+ } else {
18
+ continue;
19
+ }
20
+ }
21
+
22
+ return config;
23
+ }
24
+ }
25
+
26
+ function applyAttributes(idx, tokens, attributes) {
27
+ Object.keys(attributes).forEach(function (attr) {
28
+ var attrIndex;
29
+ var value = attributes[attr];
30
+
31
+ if (attr === "className") {
32
+ // when dealing with applying classes
33
+ // programatically, some programmers
34
+ // may prefer to use the className syntax
35
+ attr = "class";
36
+ }
37
+
38
+ attrIndex = tokens[idx].attrIndex(attr);
39
+
40
+ if (attrIndex < 0) {
41
+ // attr doesn't exist, add new attribute
42
+ tokens[idx].attrPush([attr, value]);
43
+ } else {
44
+ // attr already exists, overwrite it
45
+ tokens[idx].attrs[attrIndex][1] = value; // replace value of existing attr
46
+ }
47
+ });
48
+ }
49
+
50
+ function markdownitLinkAttributes(md, configs) {
51
+ if (!configs) {
52
+ configs = [];
53
+ } else {
54
+ configs = Array.isArray(configs) ? configs : [configs];
55
+ }
56
+
57
+ Object.freeze(configs);
58
+
59
+ var defaultRender = md.renderer.rules.link_open || this.defaultRender;
60
+
61
+ md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
62
+ var config = findFirstMatchingConfig(tokens[idx], configs);
63
+ var attributes = config && config.attrs;
64
+
65
+ if (attributes) {
66
+ applyAttributes(idx, tokens, attributes);
67
+ }
68
+
69
+ // pass token to default renderer.
70
+ return defaultRender(tokens, idx, options, env, self);
71
+ };
72
+ }
73
+
74
+ markdownitLinkAttributes.defaultRender = function (
75
+ tokens,
76
+ idx,
77
+ options,
78
+ env,
79
+ self
80
+ ) {
81
+ return self.renderToken(tokens, idx, options);
82
+ };
83
+
84
+ var markdownItLinkAttributes = markdownitLinkAttributes;
85
+
86
+ export default markdownItLinkAttributes;
87
+ //# sourceMappingURL=markdown-it-link-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-it-link-attributes.js","sources":["../../../node_modules/markdown-it-link-attributes/index.js"],"sourcesContent":["\"use strict\";\n\n// Adapted from https://github.com/markdown-it/markdown-it/blob/fbc6b0fed563ba7c00557ab638fd19752f8e759d/docs/architecture.md\n\nfunction findFirstMatchingConfig(link, configs) {\n var i, config;\n var href = link.attrs[link.attrIndex(\"href\")][1];\n\n for (i = 0; i < configs.length; ++i) {\n config = configs[i];\n\n // If there is a matcher function defined then call it\n // Matcher Function should return a boolean indicating\n // whether or not it matched. If it matched, use that\n // configuration, otherwise, try the next one.\n if (typeof config.matcher === \"function\") {\n if (config.matcher(href, config)) {\n return config;\n } else {\n continue;\n }\n }\n\n return config;\n }\n}\n\nfunction applyAttributes(idx, tokens, attributes) {\n Object.keys(attributes).forEach(function (attr) {\n var attrIndex;\n var value = attributes[attr];\n\n if (attr === \"className\") {\n // when dealing with applying classes\n // programatically, some programmers\n // may prefer to use the className syntax\n attr = \"class\";\n }\n\n attrIndex = tokens[idx].attrIndex(attr);\n\n if (attrIndex < 0) {\n // attr doesn't exist, add new attribute\n tokens[idx].attrPush([attr, value]);\n } else {\n // attr already exists, overwrite it\n tokens[idx].attrs[attrIndex][1] = value; // replace value of existing attr\n }\n });\n}\n\nfunction markdownitLinkAttributes(md, configs) {\n if (!configs) {\n configs = [];\n } else {\n configs = Array.isArray(configs) ? configs : [configs];\n }\n\n Object.freeze(configs);\n\n var defaultRender = md.renderer.rules.link_open || this.defaultRender;\n\n md.renderer.rules.link_open = function (tokens, idx, options, env, self) {\n var config = findFirstMatchingConfig(tokens[idx], configs);\n var attributes = config && config.attrs;\n\n if (attributes) {\n applyAttributes(idx, tokens, attributes);\n }\n\n // pass token to default renderer.\n return defaultRender(tokens, idx, options, env, self);\n };\n}\n\nmarkdownitLinkAttributes.defaultRender = function (\n tokens,\n idx,\n options,\n env,\n self\n) {\n return self.renderToken(tokens, idx, options);\n};\n\nmodule.exports = markdownitLinkAttributes;\n"],"names":[],"mappings":"AAEA;AACA;AACA,SAAS,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE;AAChD,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC;AAChB,EAAE,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD;AACA,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;AACvC,IAAI,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACxB;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE;AAC9C,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;AACxC,QAAQ,OAAO,MAAM,CAAC;AAC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AAC,QAAQ,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC;AACxE;AACA,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,GAAG,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE;AAC3E,IAAI,IAAI,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/D,IAAI,IAAI,UAAU,GAAG,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC;AAC5C;AACA,IAAI,IAAI,UAAU,EAAE;AACpB,MAAM,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAC/C,KAAK;AACL;AACA;AACA,IAAI,OAAO,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AAC1D,GAAG,CAAC;AACJ,CAAC;AACD;AACA,wBAAwB,CAAC,aAAa,GAAG;AACzC,EAAE,MAAM;AACR,EAAE,GAAG;AACL,EAAE,OAAO;AACT,EAAE,GAAG;AACL,EAAE,IAAI;AACN,EAAE;AACF,EAAE,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC,CAAC;AACF;4BACc,GAAG;;;;"}
@@ -0,0 +1 @@
1
+ export default "/_snowpack/pkg/markdown-it-link-attributes.js.map";
@@ -1,5 +1,6 @@
1
1
  import { unsafeHTML } from '../../_snowpack/pkg/lit-html/directives/unsafe-html.js';
2
2
  import markdownit from '../../_snowpack/pkg/markdown-it.js';
3
+ import mila from '../../_snowpack/pkg/markdown-it-link-attributes.js';
3
4
  const MarkdownMixin = {
4
5
  name: 'markdown-mixin',
5
6
 
@@ -13,7 +14,14 @@ const MarkdownMixin = {
13
14
  if (value) {
14
15
  const md = markdownit({
15
16
  breaks: true,
16
- html: false
17
+ html: false,
18
+ linkify: true
19
+ });
20
+ md.use(mila, {
21
+ attrs: {
22
+ target: '_blank',
23
+ rel: 'noopener'
24
+ }
17
25
  });
18
26
  const html = md.render(value);
19
27
  newValue = unsafeHTML(html);
@@ -1 +1 @@
1
- {"version":3,"sources":["markdownMixin.ts"],"names":["unsafeHTML","markdownit","MarkdownMixin","name","created","listValueTransformations","push","transformValue","bind","value","newValue","md","breaks","html","render","nextProcessor","shift"],"mappings":"AAAA,SAASA,UAAT,QAA2B,iCAA3B;AAEA,OAAOC,UAAP,MAAuB,aAAvB;AAEA,MAAMC,aAAa,GAAG;AACpBC,EAAAA,IAAI,EAAE,gBADc;;AAEpBC,EAAAA,OAAO,GAAG;AACR,SAAKC,wBAAL,CAA8BC,IAA9B,CAAmC,KAAKC,cAAL,CAAoBC,IAApB,CAAyB,IAAzB,CAAnC;AACD,GAJmB;;AAKpBD,EAAAA,cAAc,CAACE,KAAD,EAAgBJ,wBAAhB,EAAsD;AAClE,QAAIK,QAAa,GAAG,EAApB;;AACA,QAAID,KAAJ,EAAW;AACT,YAAME,EAAE,GAAGV,UAAU,CAAC;AACpBW,QAAAA,MAAM,EAAE,IADY;AAEpBC,QAAAA,IAAI,EAAE;AAFc,OAAD,CAArB;AAKA,YAAMA,IAAI,GAAGF,EAAE,CAACG,MAAH,CAAUL,KAAV,CAAb;AACAC,MAAAA,QAAQ,GAAGV,UAAU,CAACa,IAAD,CAArB;AACD;;AAED,UAAME,aAAa,GAAGV,wBAAwB,CAACW,KAAzB,EAAtB;AACA,QAAGD,aAAH,EAAkBA,aAAa,CAACL,QAAD,EAAWL,wBAAX,CAAb;AACnB;;AAnBmB,CAAtB;AAsBA,SACEH,aADF","sourcesContent":["import { unsafeHTML } from 'lit-html/directives/unsafe-html';\n\nimport markdownit from 'markdown-it';\n\nconst MarkdownMixin = {\n name: 'markdown-mixin',\n created() {\n this.listValueTransformations.push(this.transformValue.bind(this));\n },\n transformValue(value: string, listValueTransformations: Function[]) {\n let newValue: any = '';\n if (value) {\n const md = markdownit({\n breaks: true,\n html: false\n });\n\n const html = md.render(value);\n newValue = unsafeHTML(html);\n }\n\n const nextProcessor = listValueTransformations.shift();\n if(nextProcessor) nextProcessor(newValue, listValueTransformations);\n }\n}\n\nexport {\n MarkdownMixin\n}"]}
1
+ {"version":3,"sources":["markdownMixin.ts"],"names":["unsafeHTML","markdownit","mila","MarkdownMixin","name","created","listValueTransformations","push","transformValue","bind","value","newValue","md","breaks","html","linkify","use","attrs","target","rel","render","nextProcessor","shift"],"mappings":"AAAA,SAASA,UAAT,QAA2B,iCAA3B;AAEA,OAAOC,UAAP,MAAuB,aAAvB;AACA,OAAOC,IAAP,MAAiB,6BAAjB;AAEA,MAAMC,aAAa,GAAG;AACpBC,EAAAA,IAAI,EAAE,gBADc;;AAEpBC,EAAAA,OAAO,GAAG;AACR,SAAKC,wBAAL,CAA8BC,IAA9B,CAAmC,KAAKC,cAAL,CAAoBC,IAApB,CAAyB,IAAzB,CAAnC;AACD,GAJmB;;AAKpBD,EAAAA,cAAc,CAACE,KAAD,EAAgBJ,wBAAhB,EAAsD;AAClE,QAAIK,QAAa,GAAG,EAApB;;AACA,QAAID,KAAJ,EAAW;AACT,YAAME,EAAE,GAAGX,UAAU,CAAC;AACpBY,QAAAA,MAAM,EAAE,IADY;AAEpBC,QAAAA,IAAI,EAAE,KAFc;AAGpBC,QAAAA,OAAO,EAAE;AAHW,OAAD,CAArB;AAMAH,MAAAA,EAAE,CAACI,GAAH,CAAOd,IAAP,EAAa;AACXe,QAAAA,KAAK,EAAE;AACLC,UAAAA,MAAM,EAAE,QADH;AAELC,UAAAA,GAAG,EAAE;AAFA;AADI,OAAb;AAOA,YAAML,IAAI,GAAGF,EAAE,CAACQ,MAAH,CAAUV,KAAV,CAAb;AACAC,MAAAA,QAAQ,GAAGX,UAAU,CAACc,IAAD,CAArB;AACD;;AAED,UAAMO,aAAa,GAAGf,wBAAwB,CAACgB,KAAzB,EAAtB;AACA,QAAGD,aAAH,EAAkBA,aAAa,CAACV,QAAD,EAAWL,wBAAX,CAAb;AACnB;;AA3BmB,CAAtB;AA8BA,SACEH,aADF","sourcesContent":["import { unsafeHTML } from 'lit-html/directives/unsafe-html';\n\nimport markdownit from 'markdown-it';\nimport mila from 'markdown-it-link-attributes';\n\nconst MarkdownMixin = {\n name: 'markdown-mixin',\n created() {\n this.listValueTransformations.push(this.transformValue.bind(this));\n },\n transformValue(value: string, listValueTransformations: Function[]) {\n let newValue: any = '';\n if (value) {\n const md = markdownit({\n breaks: true,\n html: false,\n linkify: true,\n });\n\n md.use(mila, {\n attrs: {\n target: '_blank',\n rel: 'noopener',\n }\n });\n\n const html = md.render(value);\n newValue = unsafeHTML(html);\n }\n\n const nextProcessor = listValueTransformations.shift();\n if(nextProcessor) nextProcessor(newValue, listValueTransformations);\n }\n}\n\nexport {\n MarkdownMixin\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.17.30",
3
+ "version": "0.17.31",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -96,6 +96,7 @@
96
96
  "leaflet.markercluster": "1.4.1",
97
97
  "lit-html": "^1.3.0",
98
98
  "markdown-it": "^12.0.4",
99
+ "markdown-it-link-attributes": "4.0.1",
99
100
  "pubsub-js": "^1.9.2",
100
101
  "quill": "^1.3.7",
101
102
  "quill-delta-to-markdown": "^0.6.0",