@yurikilian/lex4 1.10.0 → 1.11.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"import-document-content.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/import-document-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,aAAa,EAGnB,MAAM,SAAS,CAAC;AAOjB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAsHzD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAiC5F"}
1
+ {"version":3,"file":"import-document-content.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/import-document-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,aAAa,EAGnB,MAAM,SAAS,CAAC;AAOjB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA4HzD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAiC5F"}
package/dist/style.css CHANGED
@@ -1109,8 +1109,19 @@
1109
1109
  }
1110
1110
 
1111
1111
  /* ── Variable chip (inline node) ─────────────────────────── */
1112
+ /* Zero-width spaces restore a soft-wrap opportunity around the
1113
+ non-editable decorator wrapper so a chip that does not fit the
1114
+ remaining line wraps instead of being clipped by the page body. */
1115
+ .lex4-variable::before,
1116
+ .lex4-variable::after {
1117
+ content: '\200B';
1118
+ }
1119
+
1112
1120
  .lex4-variable-chip {
1113
1121
  display: inline-block;
1122
+ max-width: 100%;
1123
+ overflow: hidden;
1124
+ text-overflow: ellipsis;
1114
1125
  border-radius: 0.22em;
1115
1126
  border: 1px solid var(--lex4-variable-border, var(--color-border));
1116
1127
  background-color: var(--lex4-variable-bg, color-mix(in srgb, var(--color-surface-elevated) 92%, var(--color-secondary)));
@@ -1124,7 +1135,9 @@
1124
1135
  user-select: none;
1125
1136
  cursor: default;
1126
1137
  white-space: nowrap;
1127
- vertical-align: -0.04em;
1138
+ /* overflow: hidden moves the inline-block baseline to the box bottom
1139
+ edge; shift the chip down so it visually sits on the text baseline. */
1140
+ vertical-align: -0.26em;
1128
1141
  margin: 0 0.0625em;
1129
1142
  transition: border-color 150ms, background-color 150ms, box-shadow 150ms;
1130
1143
  }
@@ -1142,6 +1155,34 @@
1142
1155
  vertical-align: middle;
1143
1156
  }
1144
1157
 
1158
+ /* ── Optional segment (inline conditional fragment) ──────── */
1159
+ .lex4-optional-segment {
1160
+ border-bottom: 1px dashed color-mix(in srgb, var(--color-muted-foreground) 55%, transparent);
1161
+ background-color: color-mix(in srgb, var(--color-secondary) 26%, transparent);
1162
+ border-radius: 0.18em;
1163
+ padding: 0 0.05em;
1164
+ }
1165
+
1166
+ .lex4-optional-segment::before,
1167
+ .lex4-optional-segment::after {
1168
+ color: var(--color-muted-foreground);
1169
+ font-size: 0.9em;
1170
+ -webkit-user-select: none;
1171
+ -moz-user-select: none;
1172
+ user-select: none;
1173
+ pointer-events: none;
1174
+ }
1175
+
1176
+ .lex4-optional-segment::before {
1177
+ content: '⟮';
1178
+ margin-right: 0.04em;
1179
+ }
1180
+
1181
+ .lex4-optional-segment::after {
1182
+ content: '⟯';
1183
+ margin-left: 0.04em;
1184
+ }
1185
+
1145
1186
  .lex4-variable-chip:hover {
1146
1187
  background-color: color-mix(in srgb, var(--lex4-variable-bg, var(--color-surface-elevated)) 90%, var(--color-surface-elevated));
1147
1188
  border-color: color-mix(in srgb, var(--lex4-variable-accent, var(--color-border-strong)) 40%, var(--color-border));
@@ -2,4 +2,7 @@ export type { VariableDefinition, VariableContextValue } from './types';
2
2
  export { VariableNode, $createVariableNode, $isVariableNode, type SerializedVariableNode, } from './variable-node';
3
3
  export { INSERT_VARIABLE_COMMAND, insertVariable, } from './variable-commands';
4
4
  export { VariablePlugin } from './variable-plugin';
5
+ export { OptionalSegmentNode, $createOptionalSegmentNode, $isOptionalSegmentNode, type SerializedOptionalSegmentNode, } from './optional-segment-node';
6
+ export { TOGGLE_OPTIONAL_SEGMENT_COMMAND, $toggleOptionalSegment, $getAncestorOptionalSegment, $unwrapOptionalSegment, } from './optional-segment-commands';
7
+ export { OptionalSegmentPlugin } from './optional-segment-plugin';
5
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/variables/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAExE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,uBAAuB,EACvB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/variables/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAExE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,uBAAuB,EACvB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { LexicalNode } from 'lexical';
2
+ import { OptionalSegmentNode } from './optional-segment-node';
3
+ /**
4
+ * Command that toggles an optional segment around the current selection.
5
+ *
6
+ * - Selection (or caret) inside an existing segment → unwraps that segment.
7
+ * - Non-collapsed selection within a single block → wraps it in a segment.
8
+ * - Cross-block selections and nesting are refused (no-op).
9
+ */
10
+ export declare const TOGGLE_OPTIONAL_SEGMENT_COMMAND: import('lexical').LexicalCommand<void>;
11
+ /**
12
+ * Returns the nearest OptionalSegmentNode ancestor (or the node itself).
13
+ */
14
+ export declare function $getAncestorOptionalSegment(node: LexicalNode | null): OptionalSegmentNode | null;
15
+ /**
16
+ * Replaces a segment with its children (unwrap).
17
+ */
18
+ export declare function $unwrapOptionalSegment(segment: OptionalSegmentNode): void;
19
+ /**
20
+ * Toggles an optional segment at the current selection.
21
+ * Must be called inside editor.update(). Returns true when a change was made.
22
+ */
23
+ export declare function $toggleOptionalSegment(): boolean;
24
+ //# sourceMappingURL=optional-segment-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional-segment-commands.d.ts","sourceRoot":"","sources":["../../src/variables/optional-segment-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAGL,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,wCAE3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,WAAW,GAAG,IAAI,GACvB,mBAAmB,GAAG,IAAI,CAU5B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAKzE;AAYD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAuDhD"}
@@ -0,0 +1,32 @@
1
+ import { ElementNode, BaseSelection, DOMConversionMap, DOMExportOutput, LexicalNode, NodeKey, RangeSelection, SerializedElementNode } from 'lexical';
2
+ export type SerializedOptionalSegmentNode = SerializedElementNode;
3
+ /**
4
+ * OptionalSegmentNode — an inline ElementNode that groups text and
5
+ * variable chips into a conditional fragment.
6
+ *
7
+ * At generation time the whole segment (including its punctuation) is
8
+ * dropped when any variable inside it resolves to an empty value;
9
+ * otherwise its children render normally.
10
+ *
11
+ * Behaves like LinkNode: editable children, inline, cannot be empty.
12
+ */
13
+ export declare class OptionalSegmentNode extends ElementNode {
14
+ static getType(): string;
15
+ static clone(node: OptionalSegmentNode): OptionalSegmentNode;
16
+ constructor(key?: NodeKey);
17
+ static importJSON(serializedNode: SerializedOptionalSegmentNode): OptionalSegmentNode;
18
+ exportJSON(): SerializedOptionalSegmentNode;
19
+ createDOM(): HTMLElement;
20
+ updateDOM(): boolean;
21
+ exportDOM(): DOMExportOutput;
22
+ static importDOM(): DOMConversionMap | null;
23
+ isInline(): true;
24
+ canBeEmpty(): false;
25
+ canInsertTextBefore(): false;
26
+ canInsertTextAfter(): false;
27
+ insertNewAfter(_: RangeSelection, restoreSelection?: boolean): null | ElementNode;
28
+ extractWithChild(_child: LexicalNode, selection: BaseSelection, _destination: 'clone' | 'html'): boolean;
29
+ }
30
+ export declare function $createOptionalSegmentNode(): OptionalSegmentNode;
31
+ export declare function $isOptionalSegmentNode(node: LexicalNode | null | undefined): node is OptionalSegmentNode;
32
+ //# sourceMappingURL=optional-segment-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional-segment-node.d.ts","sourceRoot":"","sources":["../../src/variables/optional-segment-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AAElE;;;;;;;;;GASG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,mBAAmB,GAAG,mBAAmB;gBAIhD,GAAG,CAAC,EAAE,OAAO;IAMzB,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,6BAA6B,GAAG,mBAAmB;IAQrF,UAAU,IAAI,6BAA6B;IAU3C,SAAS,IAAI,WAAW;IAQxB,SAAS,IAAI,OAAO;IAIpB,SAAS,IAAI,eAAe;IAM5B,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAM3C,QAAQ,IAAI,IAAI;IAIhB,UAAU,IAAI,KAAK;IAInB,mBAAmB,IAAI,KAAK;IAI5B,kBAAkB,IAAI,KAAK;IAI3B,cAAc,CAAC,CAAC,EAAE,cAAc,EAAE,gBAAgB,UAAO,GAAG,IAAI,GAAG,WAAW;IAM9E,gBAAgB,CACd,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,aAAa,EACxB,YAAY,EAAE,OAAO,GAAG,MAAM,GAC7B,OAAO;CAcX;AAED,wBAAgB,0BAA0B,IAAI,mBAAmB,CAEhE;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,mBAAmB,CAE7B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * OptionalSegmentPlugin — registers the TOGGLE_OPTIONAL_SEGMENT_COMMAND
3
+ * handler and keeps the localized tooltip on segment DOM elements.
4
+ */
5
+ export declare const OptionalSegmentPlugin: React.FC;
6
+ //# sourceMappingURL=optional-segment-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional-segment-plugin.d.ts","sourceRoot":"","sources":["../../src/variables/optional-segment-plugin.tsx"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAsCzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yurikilian/lex4",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",