inline-style-editor 1.4.0 → 1.4.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.
package/index.d.ts CHANGED
@@ -24,6 +24,7 @@ export interface SliderDefinition {
24
24
  getter: (el: HTMLElement) => number | null;
25
25
  setter: (el: SVGElement, val: number) => void;
26
26
  }
27
+
27
28
  export interface InlineStyleEditorOptions {
28
29
  onStyleChanged?: (
29
30
  target: HTMLElement,
@@ -34,5 +35,6 @@ export interface InlineStyleEditorOptions {
34
35
  getElems: (el: HTMLElement) => void;
35
36
  customProps: Record<string, ColorDefinition | SelectDefinition | SliderDefinition>;
36
37
  cssRuleFilter: (el: HTMLElement, cssSelector: string) => boolean;
38
+ getCssRuleName: (ruleName: string, el: HTMLElement) => string;
37
39
  inlineDeletable: (el: HTMLElement) => boolean,
38
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inline-style-editor",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Update CSS rules or add inline style to elements visualy",
5
5
  "scripts": {
6
6
  "build": "rollup --config",
@@ -21,31 +21,32 @@
21
21
  "typings": "index.d.ts",
22
22
  "files": [
23
23
  "dist/",
24
+ "src/",
24
25
  "index.d.ts",
25
26
  "README.md"
26
27
  ],
27
- "svelte": "src/index.js",
28
+ "svelte": "src/components/InlineStyleEditor.svelte",
28
29
  "module": "dist/inline-style-editor.mjs",
29
30
  "main": "dist/inline-style-editor.js",
30
- "style": "dist/inline-style-editor.css",
31
+ "style": "inline-style-editor.css",
31
32
  "devDependencies": {
32
- "@rollup/plugin-commonjs": "^22.0.2",
33
- "@rollup/plugin-node-resolve": "^13.3.0",
33
+ "@rollup/plugin-commonjs": "^28.0.3",
34
+ "@rollup/plugin-node-resolve": "^16.0.1",
34
35
  "rollup": "^4.41.1",
35
36
  "rollup-plugin-analyzer": "^4.0.0",
36
- "rollup-plugin-filesize": "^9.1.2",
37
- "rollup-plugin-import-css": "^3.0.3",
37
+ "rollup-plugin-filesize": "^10.0.0",
38
+ "rollup-plugin-import-css": "^4.0.1",
38
39
  "rollup-plugin-sass": "^1.2.13",
39
- "rollup-plugin-scss": "^3.0.0",
40
+ "rollup-plugin-scss": "^4.0.1",
40
41
  "rollup-plugin-svelte": "^7.1.0",
41
42
  "rollup-plugin-terser": "^7.0.2",
42
- "rollup-plugin-visualizer": "^5.8.0",
43
+ "rollup-plugin-visualizer": "^6.0.1",
43
44
  "sass": "^1.54.4"
44
45
  },
45
46
  "dependencies": {
46
47
  "d3-contour": "^4.0.0",
47
48
  "parse-svg-path": "^0.1.2",
48
- "svelte": "^3.49.0",
49
+ "svelte": "^5.33.10",
49
50
  "vanilla-picker": "^2.12.1"
50
51
  }
51
52
  }
@@ -0,0 +1,2 @@
1
+ @use 'vanilla-picker/dist/vanilla-picker.csp';
2
+ @use './style.scss';
@@ -0,0 +1,175 @@
1
+ .ise {
2
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
3
+ font-size: 14px;
4
+ z-index: 9999999;
5
+ position: absolute;
6
+ background-color: #edf2f7;
7
+ max-width: 300px;
8
+ border-radius: 5px;
9
+ box-shadow: 0px 8px 17px 2px #0000007c;
10
+
11
+ select {
12
+ appearance: none;
13
+ -webkit-appearance: none;
14
+ -moz-appearance: none;
15
+ font-size: inherit;
16
+ font-family: inherit;
17
+ padding: 0.5rem;
18
+ color: #212121;
19
+ background: white;
20
+ border: 1px solid #d8dae1;
21
+ border-radius: 5px;
22
+ box-shadow: none;
23
+ max-width: 100%;
24
+ display: inline-block;
25
+ }
26
+
27
+ select:not([multiple]) {
28
+ background-image: linear-gradient(45deg, transparent 49%, #212121 51%),
29
+ linear-gradient(135deg, #212121 51%, transparent 49%);
30
+ background-position: calc(100% - 15px), calc(100% - 10px);
31
+ background-size: 5px 5px, 5px 5px;
32
+ background-repeat: no-repeat;
33
+ padding: 5px 25px 5px 5px;
34
+ }
35
+
36
+ input[type="range"] {
37
+ width: 100%;
38
+ margin: auto;
39
+ }
40
+
41
+ .prop-name {
42
+ display: flex;
43
+ align-items: center;
44
+
45
+ &>span {
46
+ margin-left: 4px;
47
+ }
48
+ }
49
+
50
+ .delete {
51
+ cursor: pointer;
52
+ font-size: 20px;
53
+ margin: 0 4px;
54
+ margin-bottom: 2px;
55
+ }
56
+
57
+ .select-tab {
58
+ display: flex;
59
+ align-items: center;
60
+ background-color: #edf2f7;
61
+ padding: 5px 0 5px 0;
62
+ margin: 0 10px 0 10px;
63
+ border-bottom: 1px solid #dee2e6;
64
+ }
65
+
66
+ .select-tab>span {
67
+ text-overflow: ellipsis;
68
+ overflow: hidden;
69
+ white-space: nowrap;
70
+ min-width: 50px;
71
+ padding: 3px;
72
+ text-align: center;
73
+ color: #718096;
74
+ cursor: pointer;
75
+ }
76
+
77
+ .select-tab>b {
78
+ margin-right: 5px;
79
+ color: #5d5d5d;
80
+ }
81
+
82
+ .select-tab span.selected {
83
+ border-radius: 2px;
84
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px 0 rgba(0, 0, 0, .06);
85
+ color: #0069d9;
86
+ background-color: white;
87
+ }
88
+
89
+ .editor {
90
+ padding: 5px;
91
+ }
92
+
93
+ .editor .prop-section {
94
+ display: flex;
95
+ align-items: center;
96
+ margin: 5px 0;
97
+ align-items: baseline;
98
+ }
99
+
100
+ .editor .prop-section>span {
101
+ margin: 0 5px;
102
+ }
103
+
104
+ .editor .prop-section :first-child {
105
+ color: #5d5d5d;
106
+ font-weight: bold;
107
+ }
108
+
109
+ .editor .btn {
110
+ &.active {
111
+ background-color: #4d84bf;
112
+ }
113
+
114
+ &.delete-elem {
115
+ background-color: #d13737;
116
+ }
117
+
118
+ margin: 0 5px;
119
+ background-color: #3333330d;
120
+ border-radius: 4px;
121
+ border: 1px solid #d8dae1;
122
+ color: #333333;
123
+ cursor: pointer;
124
+ display: inline-block;
125
+ padding: 5px;
126
+ }
127
+
128
+ .close-button {
129
+ position: absolute;
130
+ top: -7px;
131
+ right: -7px;
132
+ background-color: #dbdbdb;
133
+ color: #818181;
134
+ width: 15px;
135
+ height: 15px;
136
+ display: flex;
137
+ justify-content: center;
138
+ align-items: center;
139
+ cursor: pointer;
140
+ border-radius: 3px;
141
+ }
142
+
143
+ .layout_default.picker_wrapper {
144
+ background: none;
145
+ box-shadow: none;
146
+ width: 100%;
147
+
148
+ .picker_done {
149
+ display: none;
150
+ }
151
+
152
+ .picker_slider,
153
+ .picker_selector {
154
+ padding: 0.5em;
155
+ }
156
+
157
+ .picker_editor input {
158
+ font-size: 0.7rem;
159
+ }
160
+ }
161
+ }
162
+
163
+ .ise-helper-wrapper {
164
+ z-index: 9999998;
165
+ position: absolute;
166
+ top: 0;
167
+ left: 0;
168
+ pointer-events: none;
169
+
170
+ .overlay-over {
171
+ fill: #000000A0;
172
+ clip-path: url(#overlay-clip);
173
+ pointer-events: painted;
174
+ }
175
+ }
@@ -0,0 +1,56 @@
1
+ <script>
2
+ import Picker from "vanilla-picker/csp";
3
+ import { onMount, onDestroy } from "svelte";
4
+
5
+ // Props
6
+ let { value = $bindable("#AAAAAAFF"), options = {}, onChange = () => {} } = $props();
7
+
8
+ // State
9
+ let self = $state();
10
+ let pickerElem = $state();
11
+
12
+ // Effect to update picker when value changes
13
+ $effect(() => {
14
+ if (pickerElem) {
15
+ pickerElem.setColor(value);
16
+ }
17
+ });
18
+
19
+ export function setColor(rgbaString) {
20
+ pickerElem.setColor(rgbaString);
21
+ }
22
+
23
+ function setValue(val) {
24
+ if (val === value) return;
25
+ onChange(val, value);
26
+ value = val;
27
+ }
28
+
29
+ function _onChange(color) {
30
+ setValue(color.hex);
31
+ }
32
+
33
+ onMount(() => {
34
+ init(options);
35
+ });
36
+
37
+ onDestroy(() => {
38
+ pickerElem?.destroy();
39
+ });
40
+
41
+ function init(opts) {
42
+ if (!self) return;
43
+ if (pickerElem) pickerElem.destroy();
44
+ opts.onChange = _onChange;
45
+ pickerElem = new Picker({
46
+ parent: self,
47
+ color: value,
48
+ popup: false,
49
+ ...opts,
50
+ });
51
+ pickerElem.show();
52
+ pickerElem.openHandler();
53
+ }
54
+ </script>
55
+
56
+ <div class="picker" bind:this={self}></div>