@fluid-topics/ft-wc-utils 1.1.0 → 1.1.2

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.
@@ -0,0 +1,3 @@
1
+ export declare const highlightHtmlColorCssVariable: import("@fluid-topics/design-system-variables").FtCssVariable;
2
+ export declare const highlightHtmlStyles: import("lit").CSSResult;
3
+ export declare function highlightHtml(container: HTMLElement, query?: string): void;
@@ -0,0 +1,23 @@
1
+ import { css } from "lit";
2
+ import { FtCssVariableFactory } from "@fluid-topics/design-system-variables";
3
+ // This library works but is pretty badly built 🙄
4
+ //@ts-ignore
5
+ import MarkJs from "mark.js/src/vanilla.js";
6
+ const Mark = MarkJs;
7
+ export const highlightHtmlColorCssVariable = FtCssVariableFactory.create("--ft-utils-highlight-html-background-color", "", "COLOR", "#FFF26E");
8
+ //language=CSS
9
+ export const highlightHtmlStyles = css `
10
+ .highlight-html-match {
11
+ background: ${highlightHtmlColorCssVariable};
12
+ }
13
+ `;
14
+ const markOptions = {
15
+ className: "highlight-html-match"
16
+ };
17
+ export function highlightHtml(container, query) {
18
+ const mark = new Mark(container);
19
+ mark.unmark(markOptions);
20
+ if (query && query.trim()) {
21
+ mark.mark(query, markOptions);
22
+ }
23
+ }
package/build/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from "./FtCssVariables";
10
10
  export * from "./FtLitElement";
11
11
  export * from "./generic-types";
12
12
  export * from "./helpers";
13
+ export * from "./highlight-html";
13
14
  export * from "./mixins.css";
14
15
  export * from "./ParametrizedLabelResolver";
15
16
  export * from "./redux";
package/build/index.js CHANGED
@@ -12,6 +12,7 @@ export * from "./FtCssVariables";
12
12
  export * from "./FtLitElement";
13
13
  export * from "./generic-types";
14
14
  export * from "./helpers";
15
+ export * from "./highlight-html";
15
16
  export * from "./mixins.css";
16
17
  export * from "./ParametrizedLabelResolver";
17
18
  export * from "./redux";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -14,10 +14,12 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@fluid-topics/design-system-variables": "0.0.18",
17
- "@fluid-topics/public-api": "1.0.50",
17
+ "@fluid-topics/public-api": "1.0.51",
18
18
  "@reduxjs/toolkit": "1.9.5",
19
+ "@types/mark.js": "8.11.12",
19
20
  "@webcomponents/scoped-custom-element-registry": "0.0.9",
20
- "lit": "3.1.0"
21
+ "lit": "3.1.0",
22
+ "mark.js": "8.11.1"
21
23
  },
22
- "gitHead": "3f2a051fc84a0e27b942f311efee39954f6d2883"
24
+ "gitHead": "53ce99f657872582bca43cbb7ad691b239b22823"
23
25
  }