@scrider/formatter 1.9.1 → 1.10.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.
package/dist/index.cjs CHANGED
@@ -44,6 +44,8 @@ __export(index_exports, {
44
44
  SCRIDER_LINE_HEIGHT_KEY: () => SCRIDER_LINE_HEIGHT_KEY,
45
45
  SCRIDER_MARGIN_AFTER_KEY: () => SCRIDER_MARGIN_AFTER_KEY,
46
46
  SCRIDER_MARGIN_BEFORE_KEY: () => SCRIDER_MARGIN_BEFORE_KEY,
47
+ SCRIDER_TEXT_INDENT_KEY: () => SCRIDER_TEXT_INDENT_KEY,
48
+ TEXT_INDENT_BLOCK_TAGS: () => TEXT_INDENT_BLOCK_TAGS,
47
49
  alertBlockHandler: () => alertBlockHandler,
48
50
  alignFormat: () => alignFormat,
49
51
  backgroundFormat: () => backgroundFormat,
@@ -53,6 +55,7 @@ __export(index_exports, {
53
55
  blockMarginBeforeStyleParts: () => blockMarginBeforeStyleParts,
54
56
  blockParagraphMarginStyleParts: () => blockParagraphMarginStyleParts,
55
57
  blockPresentationStyleParts: () => blockPresentationStyleParts,
58
+ blockTextIndentStyleParts: () => blockTextIndentStyleParts,
56
59
  blockquoteFormat: () => blockquoteFormat,
57
60
  boldFormat: () => boldFormat,
58
61
  boxBlockHandler: () => boxBlockHandler,
@@ -70,6 +73,7 @@ __export(index_exports, {
70
73
  defaultEmbedFormats: () => defaultEmbedFormats,
71
74
  defaultFormats: () => defaultFormats,
72
75
  defaultInlineFormats: () => defaultInlineFormats,
76
+ deltaToDom: () => deltaToDom,
73
77
  deltaToHtml: () => deltaToHtml,
74
78
  deltaToMarkdown: () => deltaToMarkdown,
75
79
  dividerFormat: () => dividerFormat,
@@ -112,6 +116,7 @@ __export(index_exports, {
112
116
  parseScriderMarginBeforeEm: () => parseScriderMarginBeforeEm,
113
117
  parseScriderMarginEm: () => parseScriderMarginEm,
114
118
  preloadRemark: () => preloadRemark,
119
+ renderDelta: () => renderDelta,
115
120
  resolveDocumentPresentation: () => resolveDocumentPresentation,
116
121
  resolveTablePresentation: () => resolveTablePresentation,
117
122
  sanitizeDelta: () => sanitizeDelta,
@@ -3130,7 +3135,9 @@ function slugifyWithDedup(text, usedSlugs) {
3130
3135
  var SCRIDER_LINE_HEIGHT_KEY = "scrider-line-height";
3131
3136
  var SCRIDER_MARGIN_AFTER_KEY = "scrider-margin-after";
3132
3137
  var SCRIDER_MARGIN_BEFORE_KEY = "scrider-margin-before";
3138
+ var SCRIDER_TEXT_INDENT_KEY = "scrider-text-indent";
3133
3139
  var LINE_HEIGHT_BLOCK_TAGS = /* @__PURE__ */ new Set(["p", "li", "blockquote"]);
3140
+ var TEXT_INDENT_BLOCK_TAGS = /* @__PURE__ */ new Set(["p"]);
3134
3141
  var PARAGRAPH_SPACING_BLOCK_TAGS = /* @__PURE__ */ new Set(["p"]);
3135
3142
  function parseScriderLineHeightMultiplier(value) {
3136
3143
  const trimmed = value.trim();
@@ -3160,6 +3167,18 @@ function blockLineHeightStyleParts(tag, blockAttributes, resolved) {
3160
3167
  }
3161
3168
  return [];
3162
3169
  }
3170
+ function blockTextIndentStyleParts(tag, blockAttributes, resolved) {
3171
+ if (!TEXT_INDENT_BLOCK_TAGS.has(tag)) return [];
3172
+ const raw = blockAttributes?.[SCRIDER_TEXT_INDENT_KEY];
3173
+ if (typeof raw === "string") {
3174
+ const trimmed = raw.trim();
3175
+ if (trimmed) return [`text-indent:${trimmed}`];
3176
+ }
3177
+ if (resolved?.textIndentCm !== void 0) {
3178
+ return [`text-indent:${resolved.textIndentCm}cm`];
3179
+ }
3180
+ return [];
3181
+ }
3163
3182
  function parseScriderMarginEm(value) {
3164
3183
  const trimmed = value.trim();
3165
3184
  if (!trimmed) return void 0;
@@ -3284,7 +3303,7 @@ function blockPresentationStyleParts(tag, blockAttributes, resolved) {
3284
3303
  return [
3285
3304
  ...blockLineHeightStyleParts(tag, blockAttributes, resolved),
3286
3305
  ...blockParagraphMarginStyleParts(tag, blockAttributes, resolved),
3287
- ...documentPresentationStyleParts(tag, resolved)
3306
+ ...blockTextIndentStyleParts(tag, blockAttributes, resolved)
3288
3307
  ];
3289
3308
  }
3290
3309
  function joinStyleParts(parts) {
@@ -3568,6 +3587,19 @@ function deltaToHtml(delta, options = {}) {
3568
3587
  }
3569
3588
  return html;
3570
3589
  }
3590
+ function stripPresentationForEditor(options) {
3591
+ const rest = { ...options };
3592
+ delete rest.documentPresentation;
3593
+ delete rest.documentMetadata;
3594
+ delete rest.tablePresentation;
3595
+ return rest;
3596
+ }
3597
+ function renderDelta(delta, profile, options = {}) {
3598
+ return profile === "editor" ? deltaToHtml(delta, stripPresentationForEditor(options)) : deltaToHtml(delta, options);
3599
+ }
3600
+ function deltaToDom(delta, options = {}) {
3601
+ return renderDelta(delta, "editor", options);
3602
+ }
3571
3603
  function getIndent(level) {
3572
3604
  return " ".repeat(level);
3573
3605
  }
@@ -6206,6 +6238,8 @@ function astToDelta(tree, customHandlers, mathBlock, mermaidBlock, plantumlBlock
6206
6238
  SCRIDER_LINE_HEIGHT_KEY,
6207
6239
  SCRIDER_MARGIN_AFTER_KEY,
6208
6240
  SCRIDER_MARGIN_BEFORE_KEY,
6241
+ SCRIDER_TEXT_INDENT_KEY,
6242
+ TEXT_INDENT_BLOCK_TAGS,
6209
6243
  alertBlockHandler,
6210
6244
  alignFormat,
6211
6245
  backgroundFormat,
@@ -6215,6 +6249,7 @@ function astToDelta(tree, customHandlers, mathBlock, mermaidBlock, plantumlBlock
6215
6249
  blockMarginBeforeStyleParts,
6216
6250
  blockParagraphMarginStyleParts,
6217
6251
  blockPresentationStyleParts,
6252
+ blockTextIndentStyleParts,
6218
6253
  blockquoteFormat,
6219
6254
  boldFormat,
6220
6255
  boxBlockHandler,
@@ -6232,6 +6267,7 @@ function astToDelta(tree, customHandlers, mathBlock, mermaidBlock, plantumlBlock
6232
6267
  defaultEmbedFormats,
6233
6268
  defaultFormats,
6234
6269
  defaultInlineFormats,
6270
+ deltaToDom,
6235
6271
  deltaToHtml,
6236
6272
  deltaToMarkdown,
6237
6273
  dividerFormat,
@@ -6274,6 +6310,7 @@ function astToDelta(tree, customHandlers, mathBlock, mermaidBlock, plantumlBlock
6274
6310
  parseScriderMarginBeforeEm,
6275
6311
  parseScriderMarginEm,
6276
6312
  preloadRemark,
6313
+ renderDelta,
6277
6314
  resolveDocumentPresentation,
6278
6315
  resolveTablePresentation,
6279
6316
  sanitizeDelta,