@haklex/rich-litexml 0.0.101 → 0.0.102
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/dist/index.mjs +12 -1
- package/dist/serializer.d.ts +3 -1
- package/dist/serializer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1150,8 +1150,19 @@ function pad(indent) {
|
|
|
1150
1150
|
function serializeToXml(state, registry, options = {}) {
|
|
1151
1151
|
const root = state.root;
|
|
1152
1152
|
const children = root.children ?? [];
|
|
1153
|
+
const selectedBlockIds = options.selectedBlockIds;
|
|
1153
1154
|
const ctx = createWriterContext(registry);
|
|
1154
|
-
const content = children.flatMap((child) =>
|
|
1155
|
+
const content = children.flatMap((child) => {
|
|
1156
|
+
const result = ctx.serializeNode(child);
|
|
1157
|
+
const items = Array.isArray(result) ? result : [result];
|
|
1158
|
+
if (!selectedBlockIds?.size) return items;
|
|
1159
|
+
const blockId2 = child.$?.blockId;
|
|
1160
|
+
if (!blockId2 || !selectedBlockIds.has(blockId2)) return items;
|
|
1161
|
+
return items.map((item) => {
|
|
1162
|
+
if (typeof item === "string" || "cdata" in item) return item;
|
|
1163
|
+
return { ...item, attrs: { ...item.attrs, selected: "true" } };
|
|
1164
|
+
});
|
|
1165
|
+
});
|
|
1155
1166
|
if (options.compact) {
|
|
1156
1167
|
return `<doc>${renderXml(content, 0, options)}</doc>`;
|
|
1157
1168
|
}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import { LitexmlRegistry } from './registry';
|
|
3
3
|
import { XmlRenderOptions } from './xml-utils';
|
|
4
|
-
export
|
|
4
|
+
export interface XmlSerializerOptions extends XmlRenderOptions {
|
|
5
|
+
selectedBlockIds?: Set<string>;
|
|
6
|
+
}
|
|
5
7
|
export declare function serializeToXml(state: SerializedEditorState, registry: LitexmlRegistry, options?: XmlSerializerOptions): string;
|
|
6
8
|
export declare function serializeNodesToXml(nodes: SerializedLexicalNode[], registry: LitexmlRegistry, options?: XmlSerializerOptions): string;
|
|
7
9
|
//# sourceMappingURL=serializer.d.ts.map
|
package/dist/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,qBAAqB,EAC5B,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE,oBAAyB,GACjC,MAAM,CA0BR;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,qBAAqB,EAAE,EAC9B,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAIR"}
|