@open-pencil/scene-graph 0.18.0-beta.1 → 0.18.0-beta.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/dist/arrow-caps.d.ts +14 -17
- package/dist/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +1 -2
- package/dist/asset-keys.d.ts +5 -8
- package/dist/asset-keys.d.ts.map +1 -1
- package/dist/asset-keys.js +2 -3
- package/dist/behaviours/index.d.ts +4 -3
- package/dist/behaviours/index.js +6 -5
- package/dist/behaviours/kinds.d.ts +38 -15
- package/dist/behaviours/kinds.d.ts.map +1 -1
- package/dist/behaviours/kinds.js +119 -4
- package/dist/behaviours/kinds.js.map +1 -1
- package/dist/behaviours/layers.d.ts +3 -6
- package/dist/behaviours/layers.d.ts.map +1 -1
- package/dist/behaviours/layers.js +1 -2
- package/dist/behaviours/listing.d.ts +58 -0
- package/dist/behaviours/listing.d.ts.map +1 -0
- package/dist/behaviours/listing.js +98 -0
- package/dist/behaviours/listing.js.map +1 -0
- package/dist/behaviours/model.d.ts +19 -16
- package/dist/behaviours/model.d.ts.map +1 -1
- package/dist/behaviours/model.js +14 -6
- package/dist/behaviours/model.js.map +1 -1
- package/dist/behaviours/schema.d.ts +16 -18
- package/dist/behaviours/schema.d.ts.map +1 -1
- package/dist/behaviours/schema.js +2 -3
- package/dist/behaviours/spec.d.ts +3 -6
- package/dist/behaviours/spec.d.ts.map +1 -1
- package/dist/behaviours/spec.js +4 -5
- package/dist/behaviours/transition.d.ts +6 -9
- package/dist/behaviours/transition.d.ts.map +1 -1
- package/dist/behaviours/transition.js +1 -2
- package/dist/bindings.js +2 -3
- package/dist/blur.d.ts +35 -0
- package/dist/blur.d.ts.map +1 -0
- package/dist/blur.js +69 -0
- package/dist/blur.js.map +1 -0
- package/dist/buffered-events.d.ts +3 -6
- package/dist/buffered-events.d.ts.map +1 -1
- package/dist/buffered-events.js +1 -2
- package/dist/buffered-events.js.map +1 -1
- package/dist/checkpoint.d.ts +3 -6
- package/dist/checkpoint.d.ts.map +1 -1
- package/dist/checkpoint.js +2 -3
- package/dist/clipping.d.ts +4 -7
- package/dist/clipping.d.ts.map +1 -1
- package/dist/clipping.js +4 -16
- package/dist/clipping.js.map +1 -1
- package/dist/color/contrast.d.ts +4 -7
- package/dist/color/contrast.d.ts.map +1 -1
- package/dist/color/contrast.js +2 -3
- package/dist/color/index.d.ts +13 -15
- package/dist/color/index.d.ts.map +1 -1
- package/dist/color/index.js +3 -4
- package/dist/color/management.d.ts +11 -14
- package/dist/color/management.d.ts.map +1 -1
- package/dist/color/management.js +2 -3
- package/dist/color/normalize.d.ts +1 -4
- package/dist/color/normalize.d.ts.map +1 -1
- package/dist/color/normalize.js +1 -2
- package/dist/color/okhcl.d.ts +16 -19
- package/dist/color/okhcl.d.ts.map +1 -1
- package/dist/color/okhcl.js +3 -4
- package/dist/color/schema.d.ts +4 -7
- package/dist/color/schema.d.ts.map +1 -1
- package/dist/color/schema.js +2 -3
- package/dist/comments/document.d.ts +3 -6
- package/dist/comments/document.d.ts.map +1 -1
- package/dist/comments/document.js +1 -2
- package/dist/comments/index.js +2 -2
- package/dist/comments/list.d.ts +5 -8
- package/dist/comments/list.d.ts.map +1 -1
- package/dist/comments/list.js +1 -2
- package/dist/comments/merge.d.ts +2 -5
- package/dist/comments/merge.d.ts.map +1 -1
- package/dist/comments/merge.js +1 -2
- package/dist/comments/schema.d.ts +2 -5
- package/dist/comments/schema.d.ts.map +1 -1
- package/dist/comments/schema.js +1 -2
- package/dist/comments/threads.d.ts +16 -19
- package/dist/comments/threads.d.ts.map +1 -1
- package/dist/comments/threads.js +8 -3
- package/dist/comments/threads.js.map +1 -1
- package/dist/components/exposure.d.ts +4 -7
- package/dist/components/exposure.d.ts.map +1 -1
- package/dist/components/exposure.js +1 -2
- package/dist/components/properties.d.ts +13 -16
- package/dist/components/properties.d.ts.map +1 -1
- package/dist/components/properties.js +3 -4
- package/dist/components/variants.d.ts +5 -8
- package/dist/components/variants.d.ts.map +1 -1
- package/dist/components/variants.js +1 -2
- package/dist/connectors/controls.d.ts +6 -9
- package/dist/connectors/controls.d.ts.map +1 -1
- package/dist/connectors/controls.js +2 -3
- package/dist/connectors/create.d.ts +3 -6
- package/dist/connectors/create.d.ts.map +1 -1
- package/dist/connectors/create.js +2 -3
- package/dist/connectors/elbow.js +0 -1
- package/dist/connectors/gaps.d.ts +1 -4
- package/dist/connectors/gaps.d.ts.map +1 -1
- package/dist/connectors/gaps.js +1 -2
- package/dist/connectors/hit.d.ts +1 -4
- package/dist/connectors/hit.d.ts.map +1 -1
- package/dist/connectors/hit.js +3 -4
- package/dist/connectors/index.d.ts +3 -3
- package/dist/connectors/index.js +6 -6
- package/dist/connectors/label.d.ts +4 -7
- package/dist/connectors/label.d.ts.map +1 -1
- package/dist/connectors/label.js +1 -2
- package/dist/connectors/layout.d.ts +8 -10
- package/dist/connectors/layout.d.ts.map +1 -1
- package/dist/connectors/layout.js +12 -10
- package/dist/connectors/layout.js.map +1 -1
- package/dist/connectors/pieces.d.ts +2 -5
- package/dist/connectors/pieces.d.ts.map +1 -1
- package/dist/connectors/pieces.js +3 -4
- package/dist/connectors/pieces.js.map +1 -1
- package/dist/connectors/route.d.ts +2 -5
- package/dist/connectors/route.d.ts.map +1 -1
- package/dist/connectors/route.js +4 -5
- package/dist/connectors/sides.d.ts +3 -6
- package/dist/connectors/sides.d.ts.map +1 -1
- package/dist/connectors/sides.js +2 -3
- package/dist/connectors/sublayers.d.ts +21 -24
- package/dist/connectors/sublayers.d.ts.map +1 -1
- package/dist/connectors/sublayers.js +3 -3
- package/dist/connectors/sublayers.js.map +1 -1
- package/dist/constants.d.ts +13 -16
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -2
- package/dist/constraints.d.ts +6 -8
- package/dist/constraints.d.ts.map +1 -1
- package/dist/constraints.js +1 -2
- package/dist/coordinate.d.ts +27 -29
- package/dist/coordinate.d.ts.map +1 -1
- package/dist/coordinate.js +19 -38
- package/dist/coordinate.js.map +1 -1
- package/dist/copy.d.ts +31 -25
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +13 -5
- package/dist/copy.js.map +1 -1
- package/dist/corners.d.ts +8 -10
- package/dist/corners.d.ts.map +1 -1
- package/dist/corners.js +1 -2
- package/dist/css/blend.d.ts +1 -4
- package/dist/css/blend.d.ts.map +1 -1
- package/dist/css/blend.js +1 -2
- package/dist/css/grid.d.ts +1 -4
- package/dist/css/grid.d.ts.map +1 -1
- package/dist/css/grid.js +4 -5
- package/dist/css/index.js +2 -2
- package/dist/css/layout.d.ts +7 -10
- package/dist/css/layout.d.ts.map +1 -1
- package/dist/css/layout.js +2 -3
- package/dist/css/motion.d.ts +2 -5
- package/dist/css/motion.d.ts.map +1 -1
- package/dist/css/motion.js +2 -3
- package/dist/css/shadows.d.ts +1 -4
- package/dist/css/shadows.d.ts.map +1 -1
- package/dist/css/shadows.js +3 -4
- package/dist/css/text.d.ts +8 -11
- package/dist/css/text.d.ts.map +1 -1
- package/dist/css/text.js +1 -2
- package/dist/css/transform.d.ts +6 -9
- package/dist/css/transform.d.ts.map +1 -1
- package/dist/css/transform.js +2 -3
- package/dist/css/values.d.ts +9 -12
- package/dist/css/values.d.ts.map +1 -1
- package/dist/css/values.js +2 -3
- package/dist/cubic.d.ts +11 -5
- package/dist/cubic.d.ts.map +1 -1
- package/dist/cubic.js +71 -3
- package/dist/cubic.js.map +1 -1
- package/dist/events.js +1 -2
- package/dist/export-format.d.ts +5 -8
- package/dist/export-format.d.ts.map +1 -1
- package/dist/export-format.js +4 -3
- package/dist/export-format.js.map +1 -1
- package/dist/export-scale.d.ts +4 -7
- package/dist/export-scale.d.ts.map +1 -1
- package/dist/export-scale.js +1 -2
- package/dist/fields/appearance.d.ts +3 -6
- package/dist/fields/appearance.d.ts.map +1 -1
- package/dist/fields/appearance.js +1 -2
- package/dist/fields/geometry.d.ts +2 -5
- package/dist/fields/geometry.d.ts.map +1 -1
- package/dist/fields/geometry.js +1 -2
- package/dist/fields/index.js +1 -1
- package/dist/fields/layout.d.ts +4 -7
- package/dist/fields/layout.d.ts.map +1 -1
- package/dist/fields/layout.js +1 -2
- package/dist/fields/text.d.ts +5 -8
- package/dist/fields/text.d.ts.map +1 -1
- package/dist/fields/text.js +1 -2
- package/dist/fig-compression.d.ts +3 -6
- package/dist/fig-compression.d.ts.map +1 -1
- package/dist/fig-compression.js +1 -2
- package/dist/figjam/index.js +1 -1
- package/dist/figjam/palette.d.ts +21 -23
- package/dist/figjam/palette.d.ts.map +1 -1
- package/dist/figjam/palette.js +3 -4
- package/dist/figjam/text.d.ts +10 -13
- package/dist/figjam/text.d.ts.map +1 -1
- package/dist/figjam/text.js +1 -2
- package/dist/font-style.d.ts +18 -18
- package/dist/font-style.d.ts.map +1 -1
- package/dist/font-style.js +5 -5
- package/dist/font-style.js.map +1 -1
- package/dist/generated/index.d.ts +32 -16
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +37 -9
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/kind.d.ts +17 -6
- package/dist/generated/kind.d.ts.map +1 -1
- package/dist/generated/shape-with-text.d.ts +10 -13
- package/dist/generated/shape-with-text.d.ts.map +1 -1
- package/dist/generated/shape-with-text.js +3 -3
- package/dist/generated/shape-with-text.js.map +1 -1
- package/dist/generated/spec.d.ts +45 -0
- package/dist/generated/spec.d.ts.map +1 -0
- package/dist/generated/spec.js +281 -0
- package/dist/generated/spec.js.map +1 -0
- package/dist/generated/sticky.d.ts +23 -26
- package/dist/generated/sticky.d.ts.map +1 -1
- package/dist/generated/sticky.js +4 -4
- package/dist/generated/sticky.js.map +1 -1
- package/dist/geometry.d.ts +43 -69
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +44 -76
- package/dist/geometry.js.map +1 -1
- package/dist/gradient.d.ts +15 -18
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +1 -2
- package/dist/graph.d.ts +4 -7
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +26 -19
- package/dist/graph.js.map +1 -1
- package/dist/group-bounds.d.ts +10 -12
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +5 -6
- package/dist/guides.d.ts +5 -8
- package/dist/guides.d.ts.map +1 -1
- package/dist/guides.js +2 -3
- package/dist/hit-test.d.ts +20 -12
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +51 -31
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/fit.d.ts +2 -4
- package/dist/icons/fit.d.ts.map +1 -1
- package/dist/icons/fit.js +1 -2
- package/dist/icons/glyph.d.ts +3 -5
- package/dist/icons/glyph.d.ts.map +1 -1
- package/dist/icons/glyph.js +3 -4
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +2 -2
- package/dist/icons/model.d.ts +8 -11
- package/dist/icons/model.d.ts.map +1 -1
- package/dist/icons/model.js +1 -2
- package/dist/icons/schema.d.ts +8 -11
- package/dist/icons/schema.d.ts.map +1 -1
- package/dist/icons/schema.js +1 -2
- package/dist/ids.d.ts +2 -5
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +3 -4
- package/dist/images.d.ts +20 -21
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js +7 -6
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/instances/assignments.js +1 -2
- package/dist/instances/content-marks.js +98 -0
- package/dist/instances/content-marks.js.map +1 -0
- package/dist/instances/content-size.js +3 -4
- package/dist/instances/copies.js +2 -3
- package/dist/instances/cycles.d.ts +3 -6
- package/dist/instances/cycles.d.ts.map +1 -1
- package/dist/instances/cycles.js +1 -2
- package/dist/instances/deleted.d.ts +23 -0
- package/dist/instances/deleted.d.ts.map +1 -0
- package/dist/instances/deleted.js +82 -0
- package/dist/instances/deleted.js.map +1 -0
- package/dist/instances/fields.d.ts +5 -8
- package/dist/instances/fields.d.ts.map +1 -1
- package/dist/instances/fields.js +9 -7
- package/dist/instances/fields.js.map +1 -1
- package/dist/instances/index.d.ts +21 -20
- package/dist/instances/index.d.ts.map +1 -1
- package/dist/instances/index.js +69 -12
- package/dist/instances/index.js.map +1 -1
- package/dist/instances/kept-overrides.js +4 -5
- package/dist/instances/lookup.d.ts +17 -0
- package/dist/instances/lookup.d.ts.map +1 -0
- package/dist/instances/lookup.js +48 -0
- package/dist/instances/lookup.js.map +1 -0
- package/dist/instances/main-component.d.ts +2 -5
- package/dist/instances/main-component.d.ts.map +1 -1
- package/dist/instances/main-component.js +1 -2
- package/dist/instances/matching.js +1 -2
- package/dist/instances/overrides.d.ts +23 -26
- package/dist/instances/overrides.d.ts.map +1 -1
- package/dist/instances/overrides.js +1 -2
- package/dist/instances/placement.js +3 -4
- package/dist/instances/protection.js +3 -4
- package/dist/instances/source-walk.js +1 -2
- package/dist/instances/swap.js +7 -8
- package/dist/instances/sync.js +27 -14
- package/dist/instances/sync.js.map +1 -1
- package/dist/instances/vector-geometry.js +2 -3
- package/dist/layout/aspect-ratio.d.ts +7 -9
- package/dist/layout/aspect-ratio.d.ts.map +1 -1
- package/dist/layout/aspect-ratio.js +1 -2
- package/dist/layout/flow.d.ts +3 -6
- package/dist/layout/flow.d.ts.map +1 -1
- package/dist/layout/flow.js +6 -5
- package/dist/layout/flow.js.map +1 -1
- package/dist/layout/guides.d.ts +13 -16
- package/dist/layout/guides.d.ts.map +1 -1
- package/dist/layout/guides.js +4 -5
- package/dist/layout/guides.js.map +1 -1
- package/dist/layout/index.d.ts +3 -2
- package/dist/layout/index.js +6 -5
- package/dist/layout/keywords.d.ts +7 -9
- package/dist/layout/keywords.d.ts.map +1 -1
- package/dist/layout/keywords.js +1 -2
- package/dist/layout/limits.d.ts +13 -16
- package/dist/layout/limits.d.ts.map +1 -1
- package/dist/layout/limits.js +1 -2
- package/dist/layout/sizing.d.ts +11 -13
- package/dist/layout/sizing.d.ts.map +1 -1
- package/dist/layout/sizing.js +1 -2
- package/dist/layout/spacing.d.ts +2 -5
- package/dist/layout/spacing.d.ts.map +1 -1
- package/dist/layout/spacing.js +1 -2
- package/dist/layout/stacking.d.ts +8 -0
- package/dist/layout/stacking.d.ts.map +1 -0
- package/dist/layout/stacking.js +12 -0
- package/dist/layout/stacking.js.map +1 -0
- package/dist/layout/strokes.d.ts +1 -4
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +1 -2
- package/dist/layout/writes.js +1 -2
- package/dist/layout/writes.js.map +1 -1
- package/dist/masks.d.ts +4 -7
- package/dist/masks.d.ts.map +1 -1
- package/dist/masks.js +1 -2
- package/dist/matrix.d.ts +3 -4
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +11 -3
- package/dist/matrix.js.map +1 -1
- package/dist/mesh/geometry.d.ts +21 -24
- package/dist/mesh/geometry.d.ts.map +1 -1
- package/dist/mesh/geometry.js +3 -14
- package/dist/mesh/geometry.js.map +1 -1
- package/dist/mesh/index.d.ts +1 -1
- package/dist/mesh/index.js +1 -1
- package/dist/mesh/model.d.ts +5 -8
- package/dist/mesh/model.d.ts.map +1 -1
- package/dist/mesh/model.js +2 -3
- package/dist/mesh/schema.d.ts +10 -13
- package/dist/mesh/schema.d.ts.map +1 -1
- package/dist/mesh/schema.js +3 -4
- package/dist/motion/apply.d.ts +42 -0
- package/dist/motion/apply.d.ts.map +1 -0
- package/dist/motion/apply.js +98 -0
- package/dist/motion/apply.js.map +1 -0
- package/dist/motion/edit.d.ts +53 -0
- package/dist/motion/edit.d.ts.map +1 -0
- package/dist/motion/edit.js +125 -0
- package/dist/motion/edit.js.map +1 -0
- package/dist/motion/effects.js +86 -0
- package/dist/motion/effects.js.map +1 -0
- package/dist/motion/evaluate.d.ts +33 -0
- package/dist/motion/evaluate.d.ts.map +1 -0
- package/dist/motion/evaluate.js +160 -0
- package/dist/motion/evaluate.js.map +1 -0
- package/dist/motion/fields.d.ts +69 -0
- package/dist/motion/fields.d.ts.map +1 -0
- package/dist/motion/fields.js +132 -0
- package/dist/motion/fields.js.map +1 -0
- package/dist/motion/index.d.ts +16 -0
- package/dist/motion/index.js +15 -0
- package/dist/motion/keyable.d.ts +32 -0
- package/dist/motion/keyable.d.ts.map +1 -0
- package/dist/motion/keyable.js +120 -0
- package/dist/motion/keyable.js.map +1 -0
- package/dist/motion/outline.d.ts +35 -0
- package/dist/motion/outline.d.ts.map +1 -0
- package/dist/motion/outline.js +59 -0
- package/dist/motion/outline.js.map +1 -0
- package/dist/motion/presets/index.d.ts +20 -0
- package/dist/motion/presets/index.d.ts.map +1 -0
- package/dist/motion/presets/index.js +166 -0
- package/dist/motion/presets/index.js.map +1 -0
- package/dist/motion/presets/settings.d.ts +43 -0
- package/dist/motion/presets/settings.d.ts.map +1 -0
- package/dist/motion/presets/settings.js +254 -0
- package/dist/motion/presets/settings.js.map +1 -0
- package/dist/motion/presets/stagger.d.ts +69 -0
- package/dist/motion/presets/stagger.d.ts.map +1 -0
- package/dist/motion/presets/stagger.js +185 -0
- package/dist/motion/presets/stagger.js.map +1 -0
- package/dist/motion/schema.d.ts +185 -0
- package/dist/motion/schema.d.ts.map +1 -0
- package/dist/motion/schema.js +62 -0
- package/dist/motion/schema.js.map +1 -0
- package/dist/motion/segment.d.ts +25 -0
- package/dist/motion/segment.d.ts.map +1 -0
- package/dist/motion/segment.js +73 -0
- package/dist/motion/segment.js.map +1 -0
- package/dist/motion/spec.d.ts +26 -0
- package/dist/motion/spec.d.ts.map +1 -0
- package/dist/motion/spec.js +175 -0
- package/dist/motion/spec.js.map +1 -0
- package/dist/motion/timeline.d.ts +16 -0
- package/dist/motion/timeline.d.ts.map +1 -0
- package/dist/motion/timeline.js +53 -0
- package/dist/motion/timeline.js.map +1 -0
- package/dist/motion/types.d.ts +49 -0
- package/dist/motion/types.d.ts.map +1 -0
- package/dist/motion/variables.d.ts +9 -0
- package/dist/motion/variables.d.ts.map +1 -0
- package/dist/motion/variables.js +25 -0
- package/dist/motion/variables.js.map +1 -0
- package/dist/mutation-impact.d.ts +7 -10
- package/dist/mutation-impact.d.ts.map +1 -1
- package/dist/mutation-impact.js +2 -3
- package/dist/node-defaults.d.ts +14 -15
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +133 -51
- package/dist/node-defaults.js.map +1 -1
- package/dist/order-keys.d.ts +8 -9
- package/dist/order-keys.d.ts.map +1 -1
- package/dist/order-keys.js +10 -2
- package/dist/order-keys.js.map +1 -1
- package/dist/outline/flatten.d.ts +3 -6
- package/dist/outline/flatten.d.ts.map +1 -1
- package/dist/outline/flatten.js +3 -4
- package/dist/outline/heads.js +1 -2
- package/dist/outline/hit.d.ts +2 -5
- package/dist/outline/hit.d.ts.map +1 -1
- package/dist/outline/hit.js +5 -6
- package/dist/outline/index.js +3 -3
- package/dist/outline/point.d.ts +4 -7
- package/dist/outline/point.d.ts.map +1 -1
- package/dist/outline/point.js +2 -3
- package/dist/outline/shapes.d.ts +4 -7
- package/dist/outline/shapes.d.ts.map +1 -1
- package/dist/outline/shapes.js +2 -3
- package/dist/paints/index.d.ts +2 -2
- package/dist/paints/index.js +4 -4
- package/dist/paints/pattern.d.ts +6 -9
- package/dist/paints/pattern.d.ts.map +1 -1
- package/dist/paints/pattern.js +1 -2
- package/dist/paints/schema.d.ts +4 -7
- package/dist/paints/schema.d.ts.map +1 -1
- package/dist/paints/schema.js +3 -4
- package/dist/paints/shows.d.ts +3 -6
- package/dist/paints/shows.d.ts.map +1 -1
- package/dist/paints/shows.js +1 -2
- package/dist/paints/solid.d.ts +1 -4
- package/dist/paints/solid.d.ts.map +1 -1
- package/dist/paints/solid.js +1 -2
- package/dist/paints/stills.d.ts +17 -17
- package/dist/paints/stills.d.ts.map +1 -1
- package/dist/paints/stills.js +22 -18
- package/dist/paints/stills.js.map +1 -1
- package/dist/parse-path.d.ts +12 -9
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +13 -3
- package/dist/parse-path.js.map +1 -1
- package/dist/paths/arc.d.ts +6 -9
- package/dist/paths/arc.d.ts.map +1 -1
- package/dist/paths/arc.js +1 -2
- package/dist/paths/index.d.ts +1 -1
- package/dist/paths/index.js +1 -1
- package/dist/paths/network.d.ts +13 -16
- package/dist/paths/network.d.ts.map +1 -1
- package/dist/paths/network.js +1 -2
- package/dist/paths/sink.d.ts +5 -8
- package/dist/paths/sink.d.ts.map +1 -1
- package/dist/paths/sink.js +1 -2
- package/dist/paths/smooth-corners.d.ts +3 -6
- package/dist/paths/smooth-corners.d.ts.map +1 -1
- package/dist/paths/smooth-corners.js +1 -2
- package/dist/plugin-data/field.d.ts +15 -18
- package/dist/plugin-data/field.d.ts.map +1 -1
- package/dist/plugin-data/field.js +1 -2
- package/dist/plugin-data/fields.d.ts +37 -11
- package/dist/plugin-data/fields.d.ts.map +1 -1
- package/dist/plugin-data/fields.js +35 -10
- package/dist/plugin-data/fields.js.map +1 -1
- package/dist/plugin-data/index.d.ts +2 -2
- package/dist/plugin-data/index.js +2 -2
- package/dist/polygon.d.ts +8 -8
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +7 -7
- package/dist/polygon.js.map +1 -1
- package/dist/preview.d.ts +3 -5
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +2 -3
- package/dist/primitives/index.d.ts +7 -9
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -2
- package/dist/primitives/schema.d.ts +3 -6
- package/dist/primitives/schema.d.ts.map +1 -1
- package/dist/primitives/schema.js +1 -2
- package/dist/resize.d.ts +13 -15
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +5 -6
- package/dist/scaling/node.d.ts +2 -5
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +4 -5
- package/dist/scaling/snapshot.d.ts +5 -8
- package/dist/scaling/snapshot.d.ts.map +1 -1
- package/dist/scaling/snapshot.js +1 -2
- package/dist/scaling/tree.d.ts +6 -9
- package/dist/scaling/tree.d.ts.map +1 -1
- package/dist/scaling/tree.js +2 -3
- package/dist/shaders/index.d.ts +2 -2
- package/dist/shaders/index.js +2 -2
- package/dist/shaders/model.d.ts +54 -13
- package/dist/shaders/model.d.ts.map +1 -1
- package/dist/shaders/model.js +98 -7
- package/dist/shaders/model.js.map +1 -1
- package/dist/shaders/schema.d.ts +15 -8
- package/dist/shaders/schema.d.ts.map +1 -1
- package/dist/shaders/schema.js +11 -2
- package/dist/shaders/schema.js.map +1 -1
- package/dist/shape-with-text/document.js +9 -21
- package/dist/shape-with-text/document.js.map +1 -1
- package/dist/shape-with-text/fit.d.ts +6 -9
- package/dist/shape-with-text/fit.d.ts.map +1 -1
- package/dist/shape-with-text/fit.js +1 -2
- package/dist/shape-with-text/geometry.d.ts +7 -10
- package/dist/shape-with-text/geometry.d.ts.map +1 -1
- package/dist/shape-with-text/geometry.js +4 -7
- package/dist/shape-with-text/geometry.js.map +1 -1
- package/dist/shape-with-text/index.js +1 -1
- package/dist/shape-with-text/kinds.d.ts +4 -7
- package/dist/shape-with-text/kinds.d.ts.map +1 -1
- package/dist/shape-with-text/kinds.js +1 -2
- package/dist/shared-style-index.d.ts +2 -4
- package/dist/shared-style-index.d.ts.map +1 -1
- package/dist/shared-style-index.js +1 -2
- package/dist/shared-style-index.js.map +1 -1
- package/dist/shared-styles.d.ts +17 -19
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +5 -6
- package/dist/slides/drop.d.ts +5 -8
- package/dist/slides/drop.d.ts.map +1 -1
- package/dist/slides/drop.js +1 -2
- package/dist/slides/index.d.ts +19 -19
- package/dist/slides/index.d.ts.map +1 -1
- package/dist/slides/index.js +8 -5
- package/dist/slides/index.js.map +1 -1
- package/dist/slides/motion.d.ts +32 -16
- package/dist/slides/motion.d.ts.map +1 -1
- package/dist/slides/motion.js +30 -5
- package/dist/slides/motion.js.map +1 -1
- package/dist/slides/playback.d.ts +24 -21
- package/dist/slides/playback.d.ts.map +1 -1
- package/dist/slides/playback.js +45 -13
- package/dist/slides/playback.js.map +1 -1
- package/dist/slides/types.d.ts +8 -11
- package/dist/slides/types.d.ts.map +1 -1
- package/dist/slides/types.js +1 -2
- package/dist/slots/authoring.d.ts +6 -9
- package/dist/slots/authoring.d.ts.map +1 -1
- package/dist/slots/authoring.js +2 -3
- package/dist/slots/content.d.ts +5 -8
- package/dist/slots/content.d.ts.map +1 -1
- package/dist/slots/content.js +4 -5
- package/dist/slots/frames.d.ts +7 -9
- package/dist/slots/frames.d.ts.map +1 -1
- package/dist/slots/frames.js +3 -4
- package/dist/slots/frames.js.map +1 -1
- package/dist/slots/index.js +1 -1
- package/dist/slots/limits.d.ts +4 -7
- package/dist/slots/limits.d.ts.map +1 -1
- package/dist/slots/limits.js +1 -2
- package/dist/snap.d.ts +4 -7
- package/dist/snap.d.ts.map +1 -1
- package/dist/snap.js +7 -8
- package/dist/source-metadata.d.ts +1 -4
- package/dist/source-metadata.d.ts.map +1 -1
- package/dist/source-metadata.js +1 -2
- package/dist/specs/index.d.ts +3 -0
- package/dist/specs/index.js +3 -0
- package/dist/specs/model.d.ts +20 -0
- package/dist/specs/model.d.ts.map +1 -0
- package/dist/specs/model.js +32 -0
- package/dist/specs/model.js.map +1 -0
- package/dist/specs/schema.d.ts +24 -0
- package/dist/specs/schema.d.ts.map +1 -0
- package/dist/specs/schema.js +32 -0
- package/dist/specs/schema.js.map +1 -0
- package/dist/statuses/impact.d.ts +2 -5
- package/dist/statuses/impact.d.ts.map +1 -1
- package/dist/statuses/impact.js +2 -3
- package/dist/statuses/index.d.ts +1 -1
- package/dist/statuses/index.js +2 -2
- package/dist/statuses/node.d.ts +4 -7
- package/dist/statuses/node.d.ts.map +1 -1
- package/dist/statuses/node.js +1 -2
- package/dist/statuses/schema.d.ts +7 -9
- package/dist/statuses/schema.d.ts.map +1 -1
- package/dist/statuses/schema.js +1 -2
- package/dist/statuses/workflow.d.ts +9 -12
- package/dist/statuses/workflow.d.ts.map +1 -1
- package/dist/statuses/workflow.js +1 -2
- package/dist/strokes.d.ts +8 -10
- package/dist/strokes.d.ts.map +1 -1
- package/dist/strokes.js +2 -3
- package/dist/text/auto-resize.d.ts +4 -6
- package/dist/text/auto-resize.d.ts.map +1 -1
- package/dist/text/auto-resize.js +1 -2
- package/dist/text/direction.d.ts +5 -8
- package/dist/text/direction.d.ts.map +1 -1
- package/dist/text/direction.js +1 -2
- package/dist/text/index.d.ts +2 -2
- package/dist/text/index.js +5 -5
- package/dist/text/lengths.d.ts +9 -12
- package/dist/text/lengths.d.ts.map +1 -1
- package/dist/text/lengths.js +1 -2
- package/dist/text/lists.d.ts +17 -13
- package/dist/text/lists.d.ts.map +1 -1
- package/dist/text/lists.js +15 -4
- package/dist/text/lists.js.map +1 -1
- package/dist/text/name.d.ts +4 -7
- package/dist/text/name.d.ts.map +1 -1
- package/dist/text/name.js +1 -2
- package/dist/text/overflow.d.ts +5 -7
- package/dist/text/overflow.d.ts.map +1 -1
- package/dist/text/overflow.js +1 -2
- package/dist/text/paragraphs.d.ts +20 -23
- package/dist/text/paragraphs.d.ts.map +1 -1
- package/dist/text/paragraphs.js +8 -5
- package/dist/text/paragraphs.js.map +1 -1
- package/dist/text/path.js +1 -2
- package/dist/text/picture.d.ts +3 -6
- package/dist/text/picture.d.ts.map +1 -1
- package/dist/text/picture.js +2 -3
- package/dist/text/references.d.ts +3 -6
- package/dist/text/references.d.ts.map +1 -1
- package/dist/text/references.js +1 -2
- package/dist/text/runs.d.ts +6 -9
- package/dist/text/runs.d.ts.map +1 -1
- package/dist/text/runs.js +1 -2
- package/dist/text/schema.d.ts +1 -4
- package/dist/text/schema.d.ts.map +1 -1
- package/dist/text/schema.js +1 -2
- package/dist/thumbnail.d.ts +4 -7
- package/dist/thumbnail.d.ts.map +1 -1
- package/dist/thumbnail.js +1 -2
- package/dist/transfer/apply.d.ts +2 -5
- package/dist/transfer/apply.d.ts.map +1 -1
- package/dist/transfer/apply.js +2 -3
- package/dist/transfer/copied.d.ts +5 -8
- package/dist/transfer/copied.d.ts.map +1 -1
- package/dist/transfer/copied.js +3 -4
- package/dist/transfer/dependencies.d.ts +6 -9
- package/dist/transfer/dependencies.d.ts.map +1 -1
- package/dist/transfer/dependencies.js +13 -11
- package/dist/transfer/dependencies.js.map +1 -1
- package/dist/transfer/history.d.ts +1 -4
- package/dist/transfer/history.d.ts.map +1 -1
- package/dist/transfer/history.js +1 -2
- package/dist/transfer/identity.js +1 -2
- package/dist/transfer/index.d.ts +3 -3
- package/dist/transfer/index.js +6 -6
- package/dist/transfer/library.d.ts +5 -7
- package/dist/transfer/library.d.ts.map +1 -1
- package/dist/transfer/library.js +32 -12
- package/dist/transfer/library.js.map +1 -1
- package/dist/transfer/nodes.d.ts +2 -5
- package/dist/transfer/nodes.d.ts.map +1 -1
- package/dist/transfer/nodes.js +8 -6
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/transfer/plan.d.ts +2 -5
- package/dist/transfer/plan.d.ts.map +1 -1
- package/dist/transfer/plan.js +2 -3
- package/dist/transfer/references.js +1 -2
- package/dist/transfer/remove.d.ts +1 -4
- package/dist/transfer/remove.d.ts.map +1 -1
- package/dist/transfer/remove.js +2 -3
- package/dist/transfer/resources.d.ts +2 -5
- package/dist/transfer/resources.d.ts.map +1 -1
- package/dist/transfer/resources.js +3 -4
- package/dist/transfer/validation.js +1 -2
- package/dist/transfer/variables.d.ts +3 -6
- package/dist/transfer/variables.d.ts.map +1 -1
- package/dist/transfer/variables.js +2 -3
- package/dist/types.d.ts +191 -142
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +15 -3
- package/dist/types.js.map +1 -1
- package/dist/undo.d.ts +5 -8
- package/dist/undo.d.ts.map +1 -1
- package/dist/undo.js +9 -3
- package/dist/undo.js.map +1 -1
- package/dist/variables/bindings.d.ts +24 -25
- package/dist/variables/bindings.d.ts.map +1 -1
- package/dist/variables/bindings.js +28 -23
- package/dist/variables/bindings.js.map +1 -1
- package/dist/variables/corners.d.ts +1 -4
- package/dist/variables/corners.d.ts.map +1 -1
- package/dist/variables/corners.js +1 -2
- package/dist/variables/easing.d.ts +24 -19
- package/dist/variables/easing.d.ts.map +1 -1
- package/dist/variables/easing.js +17 -17
- package/dist/variables/easing.js.map +1 -1
- package/dist/variables/fields.d.ts +21 -14
- package/dist/variables/fields.d.ts.map +1 -1
- package/dist/variables/fields.js +24 -6
- package/dist/variables/fields.js.map +1 -1
- package/dist/variables/formula/check.d.ts +2 -5
- package/dist/variables/formula/check.d.ts.map +1 -1
- package/dist/variables/formula/check.js +2 -3
- package/dist/variables/formula/evaluate.d.ts +1 -4
- package/dist/variables/formula/evaluate.d.ts.map +1 -1
- package/dist/variables/formula/evaluate.js +3 -4
- package/dist/variables/formula/index.d.ts +6 -8
- package/dist/variables/formula/index.d.ts.map +1 -1
- package/dist/variables/formula/index.js +4 -5
- package/dist/variables/formula/parse.js +5 -6
- package/dist/variables/formula/print.d.ts +2 -5
- package/dist/variables/formula/print.d.ts.map +1 -1
- package/dist/variables/formula/print.js +4 -5
- package/dist/variables/formula/schema.d.ts +2 -5
- package/dist/variables/formula/schema.d.ts.map +1 -1
- package/dist/variables/formula/schema.js +5 -6
- package/dist/variables/formula/signatures.d.ts +3 -6
- package/dist/variables/formula/signatures.d.ts.map +1 -1
- package/dist/variables/formula/signatures.js +1 -2
- package/dist/variables/formula/tokens.d.ts +5 -8
- package/dist/variables/formula/tokens.d.ts.map +1 -1
- package/dist/variables/formula/tokens.js +1 -2
- package/dist/variables/formula/tree.d.ts +6 -9
- package/dist/variables/formula/tree.d.ts.map +1 -1
- package/dist/variables/formula/tree.js +1 -2
- package/dist/variables/formula/tree.js.map +1 -1
- package/dist/variables/index.d.ts +30 -32
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js +17 -18
- package/dist/variables/lookup.d.ts +11 -7
- package/dist/variables/lookup.d.ts.map +1 -1
- package/dist/variables/lookup.js +24 -3
- package/dist/variables/lookup.js.map +1 -1
- package/dist/variables/motion.d.ts +9 -12
- package/dist/variables/motion.d.ts.map +1 -1
- package/dist/variables/motion.js +3 -4
- package/dist/variables/paints.d.ts +18 -20
- package/dist/variables/paints.d.ts.map +1 -1
- package/dist/variables/paints.js +4 -5
- package/dist/variables/resolution.d.ts +22 -19
- package/dist/variables/resolution.d.ts.map +1 -1
- package/dist/variables/resolution.js +13 -5
- package/dist/variables/resolution.js.map +1 -1
- package/dist/variables/schema.d.ts +9 -12
- package/dist/variables/schema.d.ts.map +1 -1
- package/dist/variables/schema.js +3 -4
- package/dist/variables/style-bindings.d.ts +11 -13
- package/dist/variables/style-bindings.d.ts.map +1 -1
- package/dist/variables/style-bindings.js +2 -3
- package/dist/variables/subtree.js +1 -2
- package/dist/variables/text.d.ts +2 -5
- package/dist/variables/text.d.ts.map +1 -1
- package/dist/variables/text.js +3 -4
- package/dist/variables/token.d.ts +5 -8
- package/dist/variables/token.d.ts.map +1 -1
- package/dist/variables/token.js +1 -2
- package/dist/variables/units.js +3 -5
- package/dist/variables/units.js.map +1 -1
- package/dist/variables/value.d.ts +4 -7
- package/dist/variables/value.d.ts.map +1 -1
- package/dist/variables/value.js +4 -5
- package/dist/variant-name.d.ts +2 -5
- package/dist/variant-name.d.ts.map +1 -1
- package/dist/variant-name.js +1 -2
- package/dist/variant-properties.d.ts +4 -7
- package/dist/variant-properties.d.ts.map +1 -1
- package/dist/variant-properties.js +2 -3
- package/dist/vector-network.d.ts +17 -20
- package/dist/vector-network.d.ts.map +1 -1
- package/dist/vector-network.js +4 -5
- package/package.json +23 -5
- package/src/behaviours/index.ts +1 -0
- package/src/behaviours/kinds.ts +103 -1
- package/src/behaviours/listing.ts +142 -0
- package/src/behaviours/model.ts +21 -0
- package/src/blur.ts +88 -0
- package/src/clipping.ts +3 -4
- package/src/comments/threads.ts +8 -1
- package/src/connectors/layout.ts +10 -3
- package/src/connectors/sublayers.ts +2 -1
- package/src/coordinate.ts +17 -25
- package/src/copy.ts +15 -6
- package/src/cubic.ts +57 -1
- package/src/export-format.ts +11 -1
- package/src/font-style.ts +12 -4
- package/src/generated/index.ts +43 -6
- package/src/generated/kind.ts +16 -2
- package/src/generated/shape-with-text.ts +1 -0
- package/src/generated/spec.ts +243 -0
- package/src/generated/sticky.ts +2 -1
- package/src/geometry.ts +39 -88
- package/src/graph.ts +21 -6
- package/src/hit-test.ts +66 -26
- package/src/images.ts +4 -1
- package/src/instances/content-marks.ts +124 -0
- package/src/instances/deleted.ts +115 -0
- package/src/instances/fields.ts +7 -3
- package/src/instances/index.ts +94 -5
- package/src/instances/lookup.ts +61 -0
- package/src/instances/sync.ts +15 -0
- package/src/layout/flow.ts +5 -3
- package/src/layout/index.ts +1 -0
- package/src/layout/stacking.ts +14 -0
- package/src/matrix.ts +11 -1
- package/src/mesh/geometry.ts +2 -13
- package/src/motion/apply.ts +156 -0
- package/src/motion/edit.ts +148 -0
- package/src/motion/effects.ts +166 -0
- package/src/motion/evaluate.ts +181 -0
- package/src/motion/fields.ts +136 -0
- package/src/motion/index.ts +13 -0
- package/src/motion/keyable.ts +141 -0
- package/src/motion/outline.ts +72 -0
- package/src/motion/presets/index.ts +257 -0
- package/src/motion/presets/settings.ts +221 -0
- package/src/motion/presets/stagger.ts +242 -0
- package/src/motion/schema.ts +66 -0
- package/src/motion/segment.ts +83 -0
- package/src/motion/spec.ts +225 -0
- package/src/motion/timeline.ts +48 -0
- package/src/motion/types.ts +45 -0
- package/src/motion/variables.ts +33 -0
- package/src/node-defaults.ts +131 -49
- package/src/order-keys.ts +16 -2
- package/src/paints/stills.ts +16 -12
- package/src/parse-path.ts +15 -0
- package/src/plugin-data/fields.ts +40 -3
- package/src/polygon.ts +6 -4
- package/src/shaders/model.ts +124 -6
- package/src/shaders/schema.ts +12 -0
- package/src/shape-with-text/document.ts +7 -12
- package/src/shape-with-text/geometry.ts +1 -4
- package/src/slides/index.ts +8 -0
- package/src/slides/motion.ts +35 -1
- package/src/slides/playback.ts +51 -9
- package/src/slots/frames.ts +2 -3
- package/src/specs/index.ts +2 -0
- package/src/specs/model.ts +40 -0
- package/src/specs/schema.ts +43 -0
- package/src/text/lists.ts +20 -7
- package/src/text/paragraphs.ts +10 -3
- package/src/transfer/dependencies.ts +17 -11
- package/src/transfer/library.ts +36 -12
- package/src/transfer/nodes.ts +8 -0
- package/src/types.ts +71 -8
- package/src/undo.ts +10 -1
- package/src/variables/bindings.ts +33 -16
- package/src/variables/easing.ts +16 -17
- package/src/variables/fields.ts +30 -3
- package/src/variables/lookup.ts +24 -1
- package/src/variables/resolution.ts +15 -1
- package/src/variables/units.ts +2 -3
package/dist/text/lists.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { paragraphStyleAt, textParagraphRanges } from "./paragraphs.js";
|
|
2
|
-
|
|
2
|
+
// src/text/lists.ts
|
|
3
3
|
/** The marker of an unordered item, at every level. */
|
|
4
4
|
const LIST_BULLET = "•";
|
|
5
|
+
/**
|
|
6
|
+
* The side of a checklist item's box, in ems of its list: about a capital's height, as the ▢
|
|
7
|
+
* FigJam types for `[ ] ` measures in Inter.
|
|
8
|
+
*/
|
|
9
|
+
const LIST_CHECKBOX_SIZE = .72;
|
|
5
10
|
const NUMBER_FORMATS = [
|
|
6
11
|
"DECIMAL",
|
|
7
12
|
"LOWER_ALPHA",
|
|
@@ -43,6 +48,12 @@ function formatListNumber(ordinal, format) {
|
|
|
43
48
|
if (format === "LOWER_ROMAN") return roman(ordinal);
|
|
44
49
|
return String(ordinal);
|
|
45
50
|
}
|
|
51
|
+
/** The marker text of an item: a bullet, its number and a period, or none for a drawn box. */
|
|
52
|
+
function listMarker(listType, count, level) {
|
|
53
|
+
if (listType === "CHECKLIST") return "";
|
|
54
|
+
if (listType === "UNORDERED") return "•";
|
|
55
|
+
return `${formatListNumber(count, listNumberFormat(level))}.`;
|
|
56
|
+
}
|
|
46
57
|
/**
|
|
47
58
|
* The list items of a text, numbered as Figma numbers them: each level counts its own items,
|
|
48
59
|
* a deeper item leaves the count above it running, a shallower one restarts the counts below
|
|
@@ -71,11 +82,12 @@ function textListItems(text, paragraphs) {
|
|
|
71
82
|
};
|
|
72
83
|
const shallower = counts.slice(0, level - 1).some((entry) => entry !== void 0);
|
|
73
84
|
if (groupStart === -1 || !continues && !shallower) groupStart = paragraph;
|
|
74
|
-
const marker = style.listType
|
|
85
|
+
const marker = listMarker(style.listType, count, level);
|
|
75
86
|
items.push({
|
|
76
87
|
...range,
|
|
77
88
|
paragraph,
|
|
78
89
|
listType: style.listType,
|
|
90
|
+
checked: style.listType === "CHECKLIST" && style.checked === true,
|
|
79
91
|
level,
|
|
80
92
|
ordinal: count,
|
|
81
93
|
marker,
|
|
@@ -94,7 +106,6 @@ function topLevelNumberDigits(items) {
|
|
|
94
106
|
for (const item of items) if (item.listType === "ORDERED" && item.level === 1) largest = Math.max(largest, item.ordinal);
|
|
95
107
|
return largest === 0 ? 0 : String(largest).length;
|
|
96
108
|
}
|
|
97
|
-
|
|
98
|
-
export { LIST_BULLET, formatListNumber, listNumberFormat, textListItems, topLevelNumberDigits };
|
|
109
|
+
export { LIST_BULLET, LIST_CHECKBOX_SIZE, formatListNumber, listNumberFormat, textListItems, topLevelNumberDigits };
|
|
99
110
|
|
|
100
111
|
//# sourceMappingURL=lists.js.map
|
package/dist/text/lists.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lists.js","names":[],"sources":["../../src/text/lists.ts"],"sourcesContent":["import type { TextParagraphStyle } from '../types'\nimport { paragraphStyleAt, textParagraphRanges, type TextParagraphRange } from './paragraphs'\n\n/** How an ordered item's number is written at its nesting level. */\nexport type ListNumberFormat = 'DECIMAL' | 'LOWER_ALPHA' | 'LOWER_ROMAN'\n\n/** A list item paragraph and what marks it. */\nexport interface TextListItem extends TextParagraphRange {\n paragraph: number\n listType: '
|
|
1
|
+
{"version":3,"file":"lists.js","names":[],"sources":["../../src/text/lists.ts"],"sourcesContent":["import type { TextListType, TextParagraphStyle } from '../types'\nimport { paragraphStyleAt, textParagraphRanges, type TextParagraphRange } from './paragraphs'\n\n/** How an ordered item's number is written at its nesting level. */\nexport type ListNumberFormat = 'DECIMAL' | 'LOWER_ALPHA' | 'LOWER_ROMAN'\n\n/** A list item paragraph and what marks it. */\nexport interface TextListItem extends TextParagraphRange {\n paragraph: number\n listType: Exclude<TextListType, 'NONE'>\n /** Whether a checklist item's box is ticked; false for other items. */\n checked: boolean\n /** Nesting level, from 1. */\n level: number\n /** The item's number among the items of its list at its level, from 1. */\n ordinal: number\n /** The marker drawn before the item: a bullet, or its number and a period; a box is drawn. */\n marker: string\n /** Whether the item starts a new count at its level. */\n startsList: boolean\n /**\n * The paragraph that starts the group of list items this item belongs to. A list group runs\n * from a list item that follows a plain paragraph, or that starts a top-level list, and its\n * first character styles every marker and indent in it.\n */\n groupStart: number\n}\n\n/** The marker of an unordered item, at every level. */\nexport const LIST_BULLET = '•'\n\n/**\n * The side of a checklist item's box, in ems of its list: about a capital's height, as the ▢\n * FigJam types for `[ ] ` measures in Inter.\n */\nexport const LIST_CHECKBOX_SIZE = 0.72\n\nconst NUMBER_FORMATS: readonly ListNumberFormat[] = ['DECIMAL', 'LOWER_ALPHA', 'LOWER_ROMAN']\n\n/** Ordered items count in decimal, then letters, then roman numerals, repeating as they nest. */\nexport function listNumberFormat(level: number): ListNumberFormat {\n return NUMBER_FORMATS[(Math.max(1, level) - 1) % NUMBER_FORMATS.length]\n}\n\nfunction alphabetic(value: number): string {\n let letters = ''\n for (let rest = value; rest > 0; rest = Math.floor((rest - 1) / 26)) {\n letters = String.fromCharCode(97 + ((rest - 1) % 26)) + letters\n }\n return letters\n}\n\nconst ROMAN_DIGITS: ReadonlyArray<readonly [number, string]> = [\n [1000, 'm'],\n [900, 'cm'],\n [500, 'd'],\n [400, 'cd'],\n [100, 'c'],\n [90, 'xc'],\n [50, 'l'],\n [40, 'xl'],\n [10, 'x'],\n [9, 'ix'],\n [5, 'v'],\n [4, 'iv'],\n [1, 'i']\n]\n\nfunction roman(value: number): string {\n let rest = value\n let numeral = ''\n for (const [amount, digits] of ROMAN_DIGITS) {\n for (; rest >= amount; rest -= amount) numeral += digits\n }\n return numeral\n}\n\n/** An ordered item's number as its level writes it, without the period. */\nexport function formatListNumber(ordinal: number, format: ListNumberFormat): string {\n if (format === 'LOWER_ALPHA') return alphabetic(ordinal)\n if (format === 'LOWER_ROMAN') return roman(ordinal)\n return String(ordinal)\n}\n\n/** The marker text of an item: a bullet, its number and a period, or none for a drawn box. */\nfunction listMarker(listType: Exclude<TextListType, 'NONE'>, count: number, level: number): string {\n if (listType === 'CHECKLIST') return ''\n if (listType === 'UNORDERED') return LIST_BULLET\n return `${formatListNumber(count, listNumberFormat(level))}.`\n}\n\ninterface LevelCount {\n listType: TextListItem['listType']\n count: number\n}\n\n/**\n * The list items of a text, numbered as Figma numbers them: each level counts its own items,\n * a deeper item leaves the count above it running, a shallower one restarts the counts below\n * it, and a plain paragraph or an item of the other list type restarts the count.\n */\nexport function textListItems(\n text: string,\n paragraphs: readonly TextParagraphStyle[]\n): TextListItem[] {\n if (!paragraphs.some((paragraph) => paragraph.listType !== 'NONE')) return []\n const items: TextListItem[] = []\n const counts: Array<LevelCount | undefined> = []\n let groupStart = -1\n for (const [paragraph, range] of textParagraphRanges(text).entries()) {\n const style = paragraphStyleAt(paragraphs, paragraph)\n if (style.listType === 'NONE') {\n counts.length = 0\n groupStart = -1\n continue\n }\n const level = Math.max(1, style.indentation)\n counts.length = Math.min(counts.length, level)\n const current = counts[level - 1]\n const continues = current?.listType === style.listType\n const count = continues ? current.count + 1 : 1\n counts[level - 1] = { listType: style.listType, count }\n const shallower = counts.slice(0, level - 1).some((entry) => entry !== undefined)\n if (groupStart === -1 || (!continues && !shallower)) groupStart = paragraph\n const marker = listMarker(style.listType, count, level)\n items.push({\n ...range,\n paragraph,\n listType: style.listType,\n checked: style.listType === 'CHECKLIST' && style.checked === true,\n level,\n ordinal: count,\n marker,\n startsList: !continues,\n groupStart\n })\n }\n return items\n}\n\n/**\n * Digits in the largest number of a top-level ordered item. Figma widens the indent of every\n * ordered item by the extra digits, so a list's numbers line up past nine.\n */\nexport function topLevelNumberDigits(items: readonly TextListItem[]): number {\n let largest = 0\n for (const item of items) {\n if (item.listType === 'ORDERED' && item.level === 1) largest = Math.max(largest, item.ordinal)\n }\n return largest === 0 ? 0 : String(largest).length\n}\n"],"mappings":"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"}
|
package/dist/text/name.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { SceneNode } from "../types.js";
|
|
2
|
-
//#region src/text/name.d.ts
|
|
3
2
|
/** The name a text layer that follows its text takes: its characters on one line, as Figma names it. */
|
|
4
|
-
declare function textLayerName(text: string): string;
|
|
3
|
+
export declare function textLayerName(text: string): string;
|
|
5
4
|
/**
|
|
6
5
|
* The name `changes` also sets on a text layer that follows its text (`autoRename`): its new text
|
|
7
6
|
* written, or following turned back on. A name the write gives itself wins, so a rename, or undo
|
|
8
7
|
* putting one back, is kept; setting the name alone does not stop the layer following its text,
|
|
9
8
|
* which a rename does by setting `autoRename` to false with it.
|
|
10
9
|
*/
|
|
11
|
-
declare function textNameChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
10
|
+
export declare function textNameChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
12
11
|
/** What renaming a layer writes: the name, and on a text layer an end to following its text. */
|
|
13
|
-
declare function renameChanges(node: SceneNode, name: string): Partial<SceneNode>;
|
|
12
|
+
export declare function renameChanges(node: SceneNode, name: string): Partial<SceneNode>;
|
|
14
13
|
/**
|
|
15
14
|
* What making a text layer from `overrides` also sets: the name of its text, as an edit sets it,
|
|
16
15
|
* or, given a name other than its text's, an end to following it, as a rename makes. A follow
|
|
17
16
|
* flag the overrides give, as a file or a copy gives, is kept.
|
|
18
17
|
*/
|
|
19
|
-
declare function newTextNameChanges(node: SceneNode, overrides: Partial<SceneNode>): Partial<SceneNode>;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { newTextNameChanges, renameChanges, textLayerName, textNameChanges };
|
|
18
|
+
export declare function newTextNameChanges(node: SceneNode, overrides: Partial<SceneNode>): Partial<SceneNode>;
|
|
22
19
|
//# sourceMappingURL=name.d.ts.map
|
package/dist/text/name.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.d.ts","names":[],"sources":["../../src/text/name.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"name.d.ts","names":[],"sources":["../../src/text/name.ts"],"mappings":";;wBAGgB,cAAc;;;;;;;wBAUd,gBAAgB,MAAM,WAAW,SAAS,QAAQ,aAAa,QAAQ;;wBASvE,cAAc,MAAM,WAAW,eAAe,QAAQ;;;;;;wBAStD,mBACd,MAAM,WACN,WAAW,QAAQ,aAClB,QAAQ"}
|
package/dist/text/name.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/text/name.ts
|
|
2
2
|
/** The name a text layer that follows its text takes: its characters on one line, as Figma names it. */
|
|
3
3
|
function textLayerName(text) {
|
|
4
4
|
return text.replace(/\s+/g, " ").trim() || "Text";
|
|
@@ -32,7 +32,6 @@ function newTextNameChanges(node, overrides) {
|
|
|
32
32
|
if (node.type !== "TEXT" || !("name" in overrides) || "autoRename" in overrides) return textNameChanges(node, overrides);
|
|
33
33
|
return node.name === textLayerName(node.text) ? {} : { autoRename: false };
|
|
34
34
|
}
|
|
35
|
-
//#endregion
|
|
36
35
|
export { newTextNameChanges, renameChanges, textLayerName, textNameChanges };
|
|
37
36
|
|
|
38
37
|
//# sourceMappingURL=name.js.map
|
package/dist/text/overflow.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { SceneNode } from "../types.js";
|
|
2
1
|
import { VisualBounds } from "../geometry.js";
|
|
3
|
-
|
|
2
|
+
import { SceneNode } from "../types.js";
|
|
4
3
|
type TextBoxNode = Pick<SceneNode, 'height' | 'textAlignVertical'>;
|
|
5
4
|
type TextBoundsNode = TextBoxNode & Pick<SceneNode, 'type' | 'derivedTextHeight'>;
|
|
6
|
-
type TextLinesReach = Pick<VisualBounds, 'minY' | 'maxY'>;
|
|
5
|
+
export type TextLinesReach = Pick<VisualBounds, 'minY' | 'maxY'>;
|
|
7
6
|
/**
|
|
8
7
|
* Where the top of laid-out lines `contentHeight` tall sits in a text's box, by its vertical
|
|
9
8
|
* alignment. Lines taller than the box overflow on the side away from the alignment, as Figma
|
|
10
9
|
* lays them out.
|
|
11
10
|
*/
|
|
12
|
-
declare function textVerticalOffset(node: TextBoxNode, contentHeight: number): number;
|
|
11
|
+
export declare function textVerticalOffset(node: TextBoxNode, contentHeight: number): number;
|
|
13
12
|
/**
|
|
14
13
|
* The rows a text draws its lines over, in its own axes: its box, grown by the lines a fixed-size
|
|
15
14
|
* box lets run past it above or below, as in Figma.
|
|
16
15
|
*/
|
|
17
|
-
declare function textLinesReach(node: TextBoundsNode): TextLinesReach;
|
|
18
|
-
|
|
19
|
-
export { TextLinesReach, textLinesReach, textVerticalOffset };
|
|
16
|
+
export declare function textLinesReach(node: TextBoundsNode): TextLinesReach;
|
|
17
|
+
export {};
|
|
20
18
|
//# sourceMappingURL=overflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overflow.d.ts","names":[],"sources":["../../src/text/overflow.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"overflow.d.ts","names":[],"sources":["../../src/text/overflow.ts"],"mappings":";;KAGK,cAAc,KAAK;KACnB,iBAAiB,cAAc,KAAK;YAE7B,iBAAiB,KAAK;;;;;;wBAOlB,mBAAmB,MAAM,aAAa;;;;;wBAetC,eAAe,MAAM,iBAAiB"}
|
package/dist/text/overflow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/text/overflow.ts
|
|
2
2
|
/**
|
|
3
3
|
* Where the top of laid-out lines `contentHeight` tall sits in a text's box, by its vertical
|
|
4
4
|
* alignment. Lines taller than the box overflow on the side away from the alignment, as Figma
|
|
@@ -25,7 +25,6 @@ function textLinesReach(node) {
|
|
|
25
25
|
maxY: Math.max(node.height, linesTop + node.derivedTextHeight)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
//#endregion
|
|
29
28
|
export { textLinesReach, textVerticalOffset };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=overflow.js.map
|
|
@@ -1,62 +1,59 @@
|
|
|
1
1
|
import { SceneNode, TextListType, TextParagraphSpacingField, TextParagraphStyle } from "../types.js";
|
|
2
|
-
//#region src/text/paragraphs.d.ts
|
|
3
2
|
/** The style of a paragraph with no entry: not in a list. */
|
|
4
|
-
declare const PLAIN_PARAGRAPH: Readonly<TextParagraphStyle>;
|
|
3
|
+
export declare const PLAIN_PARAGRAPH: Readonly<TextParagraphStyle>;
|
|
5
4
|
/** Figma nests list items at most this deep. */
|
|
6
|
-
declare const MAX_LIST_INDENTATION = 5;
|
|
5
|
+
export declare const MAX_LIST_INDENTATION = 5;
|
|
7
6
|
/** A paragraph's characters: `start` to `end`, not counting the newline that ends it. */
|
|
8
|
-
interface TextParagraphRange {
|
|
7
|
+
export interface TextParagraphRange {
|
|
9
8
|
start: number;
|
|
10
9
|
end: number;
|
|
11
10
|
}
|
|
12
11
|
/** The paragraphs of `text`: one per line ending at a newline, and one after the last. */
|
|
13
|
-
declare function textParagraphRanges(text: string): TextParagraphRange[];
|
|
12
|
+
export declare function textParagraphRanges(text: string): TextParagraphRange[];
|
|
14
13
|
/** The paragraph holding character `index`; a newline belongs to the paragraph it ends. */
|
|
15
|
-
declare function paragraphIndexAt(text: string, index: number): number;
|
|
16
|
-
declare function paragraphStyleAt(paragraphs: readonly TextParagraphStyle[], paragraph: number): TextParagraphStyle;
|
|
17
|
-
declare const TEXT_PARAGRAPH_SPACING_FIELDS: readonly TextParagraphSpacingField[];
|
|
14
|
+
export declare function paragraphIndexAt(text: string, index: number): number;
|
|
15
|
+
export declare function paragraphStyleAt(paragraphs: readonly TextParagraphStyle[], paragraph: number): TextParagraphStyle;
|
|
16
|
+
export declare const TEXT_PARAGRAPH_SPACING_FIELDS: readonly TextParagraphSpacingField[];
|
|
18
17
|
/** A paragraph's spacing: its own value, or the text's when it sets none. */
|
|
19
|
-
declare function paragraphSpacingAt(node: Pick<SceneNode, 'textParagraphs' | TextParagraphSpacingField>, paragraph: number, field: TextParagraphSpacingField): number;
|
|
18
|
+
export declare function paragraphSpacingAt(node: Pick<SceneNode, 'textParagraphs' | TextParagraphSpacingField>, paragraph: number, field: TextParagraphSpacingField): number;
|
|
20
19
|
/** Whether a paragraph sets any spacing of its own. */
|
|
21
|
-
declare function hasParagraphSpacing(style: TextParagraphStyle): boolean;
|
|
20
|
+
export declare function hasParagraphSpacing(style: TextParagraphStyle): boolean;
|
|
22
21
|
/** A paragraph style with its own `field` set, or following the text again for `undefined`. */
|
|
23
|
-
declare function withParagraphSpacing(style: TextParagraphStyle, field: TextParagraphSpacingField, value: number | undefined): TextParagraphStyle;
|
|
22
|
+
export declare function withParagraphSpacing(style: TextParagraphStyle, field: TextParagraphSpacingField, value: number | undefined): TextParagraphStyle;
|
|
24
23
|
/** Every paragraph's `field`, or `null` when they differ. */
|
|
25
|
-
declare function sharedParagraphSpacing(node: Pick<SceneNode, 'text' | 'textParagraphs' | TextParagraphSpacingField>, field: TextParagraphSpacingField, first?: number, last?: number): number | null;
|
|
24
|
+
export declare function sharedParagraphSpacing(node: Pick<SceneNode, 'text' | 'textParagraphs' | TextParagraphSpacingField>, field: TextParagraphSpacingField, first?: number, last?: number): number | null;
|
|
26
25
|
/** Paragraph styles with no paragraph setting its own `field`, as setting the text's does. */
|
|
27
|
-
declare function paragraphStylesWithoutSpacing(paragraphs: readonly TextParagraphStyle[], field: TextParagraphSpacingField): TextParagraphStyle[];
|
|
26
|
+
export declare function paragraphStylesWithoutSpacing(paragraphs: readonly TextParagraphStyle[], field: TextParagraphSpacingField): TextParagraphStyle[];
|
|
28
27
|
/** Whether any paragraph of the node is a list item. */
|
|
29
|
-
declare function hasTextList(node: Pick<SceneNode, 'textParagraphs'>): boolean;
|
|
28
|
+
export declare function hasTextList(node: Pick<SceneNode, 'textParagraphs'>): boolean;
|
|
30
29
|
/**
|
|
31
30
|
* Paragraph styles for `count` paragraphs, without the plain paragraphs at the end, so text
|
|
32
31
|
* without lists, indentation, or paragraph spacing of its own keeps none.
|
|
33
32
|
*/
|
|
34
|
-
declare function trimParagraphStyles(paragraphs: readonly TextParagraphStyle[], count: number): TextParagraphStyle[];
|
|
33
|
+
export declare function trimParagraphStyles(paragraphs: readonly TextParagraphStyle[], count: number): TextParagraphStyle[];
|
|
35
34
|
/** How many paragraphs `text` has: one more than its newlines. */
|
|
36
|
-
declare function paragraphCount(text: string): number;
|
|
35
|
+
export declare function paragraphCount(text: string): number;
|
|
37
36
|
/**
|
|
38
37
|
* Paragraph styles after replacing `text[start, end)` with `inserted`, as Figma keeps them: the
|
|
39
38
|
* paragraph the edit starts in keeps its style, paragraphs a deleted newline joins to it are
|
|
40
39
|
* dropped, and paragraphs an inserted newline starts take its style.
|
|
41
40
|
*/
|
|
42
|
-
declare function paragraphStylesAfterEdit(paragraphs: readonly TextParagraphStyle[], text: string, start: number, end: number, inserted: string): TextParagraphStyle[];
|
|
41
|
+
export declare function paragraphStylesAfterEdit(paragraphs: readonly TextParagraphStyle[], text: string, start: number, end: number, inserted: string): TextParagraphStyle[];
|
|
43
42
|
/**
|
|
44
43
|
* Paragraph styles with every paragraph that `text[start, end)` touches changed by `change`,
|
|
45
44
|
* as a range setter changes whole paragraphs.
|
|
46
45
|
*/
|
|
47
|
-
declare function paragraphStylesInRange(paragraphs: readonly TextParagraphStyle[], text: string, start: number, end: number, change: (style: TextParagraphStyle) => TextParagraphStyle): TextParagraphStyle[];
|
|
46
|
+
export declare function paragraphStylesInRange(paragraphs: readonly TextParagraphStyle[], text: string, start: number, end: number, change: (style: TextParagraphStyle) => TextParagraphStyle): TextParagraphStyle[];
|
|
48
47
|
/**
|
|
49
48
|
* A paragraph style with its list type set. A list item is nested at least one level, and a
|
|
50
49
|
* paragraph leaving a list keeps no indentation.
|
|
51
50
|
*/
|
|
52
|
-
declare function withListType(style: TextParagraphStyle, listType: TextListType): TextParagraphStyle;
|
|
51
|
+
export declare function withListType(style: TextParagraphStyle, listType: TextListType): TextParagraphStyle;
|
|
53
52
|
/** A paragraph style with its nesting set, kept in the range a list item allows. */
|
|
54
|
-
declare function withIndentation(style: TextParagraphStyle, indentation: number): TextParagraphStyle;
|
|
53
|
+
export declare function withIndentation(style: TextParagraphStyle, indentation: number): TextParagraphStyle;
|
|
55
54
|
/**
|
|
56
55
|
* Paragraph styles after `before` became `after` through one edit, found as the text between
|
|
57
56
|
* their common start and end, for editors that replace the text rather than report the edit.
|
|
58
57
|
*/
|
|
59
|
-
declare function paragraphStylesAfterTextChange(paragraphs: readonly TextParagraphStyle[], before: string, after: string): TextParagraphStyle[];
|
|
60
|
-
//#endregion
|
|
61
|
-
export { MAX_LIST_INDENTATION, PLAIN_PARAGRAPH, TEXT_PARAGRAPH_SPACING_FIELDS, TextParagraphRange, hasParagraphSpacing, hasTextList, paragraphCount, paragraphIndexAt, paragraphSpacingAt, paragraphStyleAt, paragraphStylesAfterEdit, paragraphStylesAfterTextChange, paragraphStylesInRange, paragraphStylesWithoutSpacing, sharedParagraphSpacing, textParagraphRanges, trimParagraphStyles, withIndentation, withListType, withParagraphSpacing };
|
|
58
|
+
export declare function paragraphStylesAfterTextChange(paragraphs: readonly TextParagraphStyle[], before: string, after: string): TextParagraphStyle[];
|
|
62
59
|
//# sourceMappingURL=paragraphs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraphs.d.ts","names":[],"sources":["../../src/text/paragraphs.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"paragraphs.d.ts","names":[],"sources":["../../src/text/paragraphs.ts"],"mappings":";;qBAUa,iBAAiB,SAAS;;qBAM1B;;iBAGI;EACf;EACA;;;wBAIc,oBAAoB,eAAe;;wBAYnC,iBAAiB,cAAc;wBAS/B,iBACd,qBAAqB,sBACrB,oBACC;qBAIU,wCAAwC;;wBAOrC,mBACd,MAAM,KAAK,8BAA8B,4BACzC,mBACA,OAAO;;wBAMO,oBAAoB,OAAO;;wBAK3B,qBACd,OAAO,oBACP,OAAO,2BACP,4BACC;;wBAMa,uBACd,MAAM,KAAK,uCAAuC,4BAClD,OAAO,2BACP,gBACA;;wBAUc,8BACd,qBAAqB,sBACrB,OAAO,4BACN;;wBAQa,YAAY,MAAM,KAAK;;;;;wBAQvB,oBACd,qBAAqB,sBACrB,gBACC;;wBAWa,eAAe;;;;;;wBAWf,yBACd,qBAAqB,sBACrB,cACA,eACA,aACA,mBACC;;;;;wBAqBa,uBACd,qBAAqB,sBACrB,cACA,eACA,aACA,SAAS,OAAO,uBAAuB,qBACtC;;;;;wBAiBa,aACd,OAAO,oBACP,UAAU,eACT;;wBAQa,gBACd,OAAO,oBACP,sBACC;;;;;wBAkBa,+BACd,qBAAqB,sBACrB,gBACA,gBACC"}
|
package/dist/text/paragraphs.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { omit } from "es-toolkit";
|
|
2
|
+
// src/text/paragraphs.ts
|
|
2
3
|
/** The style of a paragraph with no entry: not in a list. */
|
|
3
4
|
const PLAIN_PARAGRAPH = Object.freeze({
|
|
4
5
|
listType: "NONE",
|
|
@@ -98,9 +99,11 @@ function paragraphStylesAfterEdit(paragraphs, text, start, end, inserted) {
|
|
|
98
99
|
const last = paragraphIndexAt(text, end);
|
|
99
100
|
const style = paragraphStyleAt(paragraphs, first);
|
|
100
101
|
const added = paragraphCount(inserted) - 1;
|
|
102
|
+
const opened = omit(style, ["checked"]);
|
|
101
103
|
return trimParagraphStyles([
|
|
102
104
|
...Array.from({ length: first }, (_, index) => paragraphStyleAt(paragraphs, index)),
|
|
103
|
-
|
|
105
|
+
style,
|
|
106
|
+
...Array.from({ length: added }, () => opened),
|
|
104
107
|
...paragraphs.slice(last + 1)
|
|
105
108
|
], paragraphCount(text) - (last - first) + added);
|
|
106
109
|
}
|
|
@@ -122,13 +125,14 @@ function paragraphStylesInRange(paragraphs, text, start, end, change) {
|
|
|
122
125
|
* paragraph leaving a list keeps no indentation.
|
|
123
126
|
*/
|
|
124
127
|
function withListType(style, listType) {
|
|
128
|
+
const kept = listType === "CHECKLIST" ? style : omit(style, ["checked"]);
|
|
125
129
|
if (listType === "NONE") return {
|
|
126
|
-
...
|
|
130
|
+
...kept,
|
|
127
131
|
listType,
|
|
128
132
|
indentation: 0
|
|
129
133
|
};
|
|
130
134
|
return {
|
|
131
|
-
...
|
|
135
|
+
...kept,
|
|
132
136
|
listType,
|
|
133
137
|
indentation: clampListIndentation(style.indentation)
|
|
134
138
|
};
|
|
@@ -160,7 +164,6 @@ function paragraphStylesAfterTextChange(paragraphs, before, after) {
|
|
|
160
164
|
while (suffix < shorter - prefix && before[before.length - 1 - suffix] === after[after.length - 1 - suffix]) suffix++;
|
|
161
165
|
return paragraphStylesAfterEdit(paragraphs, before, prefix, before.length - suffix, after.slice(prefix, after.length - suffix));
|
|
162
166
|
}
|
|
163
|
-
//#endregion
|
|
164
167
|
export { MAX_LIST_INDENTATION, PLAIN_PARAGRAPH, TEXT_PARAGRAPH_SPACING_FIELDS, hasParagraphSpacing, hasTextList, paragraphCount, paragraphIndexAt, paragraphSpacingAt, paragraphStyleAt, paragraphStylesAfterEdit, paragraphStylesAfterTextChange, paragraphStylesInRange, paragraphStylesWithoutSpacing, sharedParagraphSpacing, textParagraphRanges, trimParagraphStyles, withIndentation, withListType, withParagraphSpacing };
|
|
165
168
|
|
|
166
169
|
//# sourceMappingURL=paragraphs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraphs.js","names":[],"sources":["../../src/text/paragraphs.ts"],"sourcesContent":["import type {\n SceneNode,\n TextListType,\n TextParagraphSpacingField,\n TextParagraphStyle\n} from '../types'\n\n/** The style of a paragraph with no entry: not in a list. */\nexport const PLAIN_PARAGRAPH: Readonly<TextParagraphStyle> = Object.freeze({\n listType: 'NONE',\n indentation: 0\n})\n\n/** Figma nests list items at most this deep. */\nexport const MAX_LIST_INDENTATION = 5\n\n/** A paragraph's characters: `start` to `end`, not counting the newline that ends it. */\nexport interface TextParagraphRange {\n start: number\n end: number\n}\n\n/** The paragraphs of `text`: one per line ending at a newline, and one after the last. */\nexport function textParagraphRanges(text: string): TextParagraphRange[] {\n const ranges: TextParagraphRange[] = []\n let start = 0\n for (let index = text.indexOf('\\n'); index !== -1; index = text.indexOf('\\n', start)) {\n ranges.push({ start, end: index })\n start = index + 1\n }\n ranges.push({ start, end: text.length })\n return ranges\n}\n\n/** The paragraph holding character `index`; a newline belongs to the paragraph it ends. */\nexport function paragraphIndexAt(text: string, index: number): number {\n let paragraph = 0\n const end = Math.min(index, text.length)\n for (let at = text.indexOf('\\n'); at !== -1 && at < end; at = text.indexOf('\\n', at + 1)) {\n paragraph++\n }\n return paragraph\n}\n\nexport function paragraphStyleAt(\n paragraphs: readonly TextParagraphStyle[],\n paragraph: number\n): TextParagraphStyle {\n return paragraphs[paragraph] ?? PLAIN_PARAGRAPH\n}\n\nexport const TEXT_PARAGRAPH_SPACING_FIELDS: readonly TextParagraphSpacingField[] = [\n 'listSpacing',\n 'paragraphSpacing',\n 'paragraphIndent'\n]\n\n/** A paragraph's spacing: its own value, or the text's when it sets none. */\nexport function paragraphSpacingAt(\n node: Pick<SceneNode, 'textParagraphs' | TextParagraphSpacingField>,\n paragraph: number,\n field: TextParagraphSpacingField\n): number {\n return paragraphStyleAt(node.textParagraphs, paragraph)[field] ?? node[field]\n}\n\n/** Whether a paragraph sets any spacing of its own. */\nexport function hasParagraphSpacing(style: TextParagraphStyle): boolean {\n return TEXT_PARAGRAPH_SPACING_FIELDS.some((field) => style[field] !== undefined)\n}\n\n/** A paragraph style with its own `field` set, or following the text again for `undefined`. */\nexport function withParagraphSpacing(\n style: TextParagraphStyle,\n field: TextParagraphSpacingField,\n value: number | undefined\n): TextParagraphStyle {\n const { [field]: _previous, ...rest } = style\n return value === undefined ? rest : { ...rest, [field]: value }\n}\n\n/** Every paragraph's `field`, or `null` when they differ. */\nexport function sharedParagraphSpacing(\n node: Pick<SceneNode, 'text' | 'textParagraphs' | TextParagraphSpacingField>,\n field: TextParagraphSpacingField,\n first = 0,\n last = paragraphCount(node.text) - 1\n): number | null {\n const value = paragraphSpacingAt(node, first, field)\n for (let index = first + 1; index <= last; index++) {\n if (paragraphSpacingAt(node, index, field) !== value) return null\n }\n return value\n}\n\n/** Paragraph styles with no paragraph setting its own `field`, as setting the text's does. */\nexport function paragraphStylesWithoutSpacing(\n paragraphs: readonly TextParagraphStyle[],\n field: TextParagraphSpacingField\n): TextParagraphStyle[] {\n return trimParagraphStyles(\n paragraphs.map((style) => withParagraphSpacing(style, field, undefined)),\n paragraphs.length\n )\n}\n\n/** Whether any paragraph of the node is a list item. */\nexport function hasTextList(node: Pick<SceneNode, 'textParagraphs'>): boolean {\n return node.textParagraphs.some((paragraph) => paragraph.listType !== 'NONE')\n}\n\n/**\n * Paragraph styles for `count` paragraphs, without the plain paragraphs at the end, so text\n * without lists, indentation, or paragraph spacing of its own keeps none.\n */\nexport function trimParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n count: number\n): TextParagraphStyle[] {\n const styles = paragraphs.slice(0, count).map((paragraph) => ({ ...paragraph }))\n while (styles.length > 0) {\n const last = styles[styles.length - 1]\n if (last.listType !== 'NONE' || last.indentation !== 0 || hasParagraphSpacing(last)) break\n styles.pop()\n }\n return styles\n}\n\n/** How many paragraphs `text` has: one more than its newlines. */\nexport function paragraphCount(text: string): number {\n let count = 1\n for (let at = text.indexOf('\\n'); at !== -1; at = text.indexOf('\\n', at + 1)) count++\n return count\n}\n\n/**\n * Paragraph styles after replacing `text[start, end)` with `inserted`, as Figma keeps them: the\n * paragraph the edit starts in keeps its style, paragraphs a deleted newline joins to it are\n * dropped, and paragraphs an inserted newline starts take its style.\n */\nexport function paragraphStylesAfterEdit(\n paragraphs: readonly TextParagraphStyle[],\n text: string,\n start: number,\n end: number,\n inserted: string\n): TextParagraphStyle[] {\n if (paragraphs.length === 0) return []\n const first = paragraphIndexAt(text, start)\n const last = paragraphIndexAt(text, end)\n const style = paragraphStyleAt(paragraphs, first)\n const added = paragraphCount(inserted) - 1\n const next = [\n ...Array.from({ length: first }, (_, index) => paragraphStyleAt(paragraphs, index)),\n ...Array.from({ length: added + 1 }, () => style),\n ...paragraphs.slice(last + 1)\n ]\n return trimParagraphStyles(next, paragraphCount(text) - (last - first) + added)\n}\n\n/**\n * Paragraph styles with every paragraph that `text[start, end)` touches changed by `change`,\n * as a range setter changes whole paragraphs.\n */\nexport function paragraphStylesInRange(\n paragraphs: readonly TextParagraphStyle[],\n text: string,\n start: number,\n end: number,\n change: (style: TextParagraphStyle) => TextParagraphStyle\n): TextParagraphStyle[] {\n const count = paragraphCount(text)\n const first = paragraphIndexAt(text, start)\n // An empty range still names the paragraph it sits in; a range ending right after a\n // newline does not reach into the next paragraph.\n const last = end > start ? paragraphIndexAt(text, end - 1) : first\n const next = Array.from({ length: count }, (_, index) => {\n const style = paragraphStyleAt(paragraphs, index)\n return index >= first && index <= last ? change(style) : style\n })\n return trimParagraphStyles(next, count)\n}\n\n/**\n * A paragraph style with its list type set. A list item is nested at least one level, and a\n * paragraph leaving a list keeps no indentation.\n */\nexport function withListType(\n style: TextParagraphStyle,\n listType: TextListType\n): TextParagraphStyle {\n if (listType === 'NONE') return { ...style, listType, indentation: 0 }\n return { ...style, listType, indentation: clampListIndentation(style.indentation) }\n}\n\n/** A paragraph style with its nesting set, kept in the range a list item allows. */\nexport function withIndentation(\n style: TextParagraphStyle,\n indentation: number\n): TextParagraphStyle {\n if (style.listType === 'NONE') {\n return {\n ...style,\n indentation: Math.max(0, Math.min(MAX_LIST_INDENTATION, Math.round(indentation)))\n }\n }\n return { ...style, indentation: clampListIndentation(indentation) }\n}\n\nfunction clampListIndentation(indentation: number): number {\n return Math.max(1, Math.min(MAX_LIST_INDENTATION, Math.round(indentation)))\n}\n\n/**\n * Paragraph styles after `before` became `after` through one edit, found as the text between\n * their common start and end, for editors that replace the text rather than report the edit.\n */\nexport function paragraphStylesAfterTextChange(\n paragraphs: readonly TextParagraphStyle[],\n before: string,\n after: string\n): TextParagraphStyle[] {\n if (paragraphs.length === 0 || before === after) return paragraphs.map((style) => ({ ...style }))\n let prefix = 0\n const shorter = Math.min(before.length, after.length)\n while (prefix < shorter && before[prefix] === after[prefix]) prefix++\n let suffix = 0\n while (\n suffix < shorter - prefix &&\n before[before.length - 1 - suffix] === after[after.length - 1 - suffix]\n ) {\n suffix++\n }\n return paragraphStylesAfterEdit(\n paragraphs,\n before,\n prefix,\n before.length - suffix,\n after.slice(prefix, after.length - suffix)\n )\n}\n"],"mappings":";;AAQA,MAAa,kBAAgD,OAAO,OAAO;CACzE,UAAU;CACV,aAAa;AACf,CAAC;;AAGD,MAAa,uBAAuB;;AASpC,SAAgB,oBAAoB,MAAoC;CACtE,MAAM,SAA+B,CAAC;CACtC,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,KAAK,QAAQ,IAAI,GAAG,UAAU,IAAI,QAAQ,KAAK,QAAQ,MAAM,KAAK,GAAG;EACpF,OAAO,KAAK;GAAE;GAAO,KAAK;EAAM,CAAC;EACjC,QAAQ,QAAQ;CAClB;CACA,OAAO,KAAK;EAAE;EAAO,KAAK,KAAK;CAAO,CAAC;CACvC,OAAO;AACT;;AAGA,SAAgB,iBAAiB,MAAc,OAAuB;CACpE,IAAI,YAAY;CAChB,MAAM,MAAM,KAAK,IAAI,OAAO,KAAK,MAAM;CACvC,KAAK,IAAI,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,MAAM,KAAK,KAAK,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC,GACrF;CAEF,OAAO;AACT;AAEA,SAAgB,iBACd,YACA,WACoB;CACpB,OAAO,WAAW,cAAc;AAClC;AAEA,MAAa,gCAAsE;CACjF;CACA;CACA;AACF;;AAGA,SAAgB,mBACd,MACA,WACA,OACQ;CACR,OAAO,iBAAiB,KAAK,gBAAgB,SAAS,CAAC,CAAC,UAAU,KAAK;AACzE;;AAGA,SAAgB,oBAAoB,OAAoC;CACtE,OAAO,8BAA8B,MAAM,UAAU,MAAM,WAAW,KAAA,CAAS;AACjF;;AAGA,SAAgB,qBACd,OACA,OACA,OACoB;CACpB,MAAM,GAAG,QAAQ,WAAW,GAAG,SAAS;CACxC,OAAO,UAAU,KAAA,IAAY,OAAO;EAAE,GAAG;GAAO,QAAQ;CAAM;AAChE;;AAGA,SAAgB,uBACd,MACA,OACA,QAAQ,GACR,OAAO,eAAe,KAAK,IAAI,IAAI,GACpB;CACf,MAAM,QAAQ,mBAAmB,MAAM,OAAO,KAAK;CACnD,KAAK,IAAI,QAAQ,QAAQ,GAAG,SAAS,MAAM,SACzC,IAAI,mBAAmB,MAAM,OAAO,KAAK,MAAM,OAAO,OAAO;CAE/D,OAAO;AACT;;AAGA,SAAgB,8BACd,YACA,OACsB;CACtB,OAAO,oBACL,WAAW,KAAK,UAAU,qBAAqB,OAAO,OAAO,KAAA,CAAS,CAAC,GACvE,WAAW,MACb;AACF;;AAGA,SAAgB,YAAY,MAAkD;CAC5E,OAAO,KAAK,eAAe,MAAM,cAAc,UAAU,aAAa,MAAM;AAC9E;;;;;AAMA,SAAgB,oBACd,YACA,OACsB;CACtB,MAAM,SAAS,WAAW,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,eAAe,EAAE,GAAG,UAAU,EAAE;CAC/E,OAAO,OAAO,SAAS,GAAG;EACxB,MAAM,OAAO,OAAO,OAAO,SAAS;EACpC,IAAI,KAAK,aAAa,UAAU,KAAK,gBAAgB,KAAK,oBAAoB,IAAI,GAAG;EACrF,OAAO,IAAI;CACb;CACA,OAAO;AACT;;AAGA,SAAgB,eAAe,MAAsB;CACnD,IAAI,QAAQ;CACZ,KAAK,IAAI,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,IAAI,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC,GAAG;CAC9E,OAAO;AACT;;;;;;AAOA,SAAgB,yBACd,YACA,MACA,OACA,KACA,UACsB;CACtB,IAAI,WAAW,WAAW,GAAG,OAAO,CAAC;CACrC,MAAM,QAAQ,iBAAiB,MAAM,KAAK;CAC1C,MAAM,OAAO,iBAAiB,MAAM,GAAG;CACvC,MAAM,QAAQ,iBAAiB,YAAY,KAAK;CAChD,MAAM,QAAQ,eAAe,QAAQ,IAAI;CAMzC,OAAO,oBAAoB;EAJzB,GAAG,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAAU,iBAAiB,YAAY,KAAK,CAAC;EAClF,GAAG,MAAM,KAAK,EAAE,QAAQ,QAAQ,EAAE,SAAS,KAAK;EAChD,GAAG,WAAW,MAAM,OAAO,CAAC;CAEA,GAAG,eAAe,IAAI,KAAK,OAAO,SAAS,KAAK;AAChF;;;;;AAMA,SAAgB,uBACd,YACA,MACA,OACA,KACA,QACsB;CACtB,MAAM,QAAQ,eAAe,IAAI;CACjC,MAAM,QAAQ,iBAAiB,MAAM,KAAK;CAG1C,MAAM,OAAO,MAAM,QAAQ,iBAAiB,MAAM,MAAM,CAAC,IAAI;CAK7D,OAAO,oBAJM,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAAU;EACvD,MAAM,QAAQ,iBAAiB,YAAY,KAAK;EAChD,OAAO,SAAS,SAAS,SAAS,OAAO,OAAO,KAAK,IAAI;CAC3D,CAC8B,GAAG,KAAK;AACxC;;;;;AAMA,SAAgB,aACd,OACA,UACoB;CACpB,IAAI,aAAa,QAAQ,OAAO;EAAE,GAAG;EAAO;EAAU,aAAa;CAAE;CACrE,OAAO;EAAE,GAAG;EAAO;EAAU,aAAa,qBAAqB,MAAM,WAAW;CAAE;AACpF;;AAGA,SAAgB,gBACd,OACA,aACoB;CACpB,IAAI,MAAM,aAAa,QACrB,OAAO;EACL,GAAG;EACH,aAAa,KAAK,IAAI,GAAG,KAAK,IAAA,GAA0B,KAAK,MAAM,WAAW,CAAC,CAAC;CAClF;CAEF,OAAO;EAAE,GAAG;EAAO,aAAa,qBAAqB,WAAW;CAAE;AACpE;AAEA,SAAS,qBAAqB,aAA6B;CACzD,OAAO,KAAK,IAAI,GAAG,KAAK,IAAA,GAA0B,KAAK,MAAM,WAAW,CAAC,CAAC;AAC5E;;;;;AAMA,SAAgB,+BACd,YACA,QACA,OACsB;CACtB,IAAI,WAAW,WAAW,KAAK,WAAW,OAAO,OAAO,WAAW,KAAK,WAAW,EAAE,GAAG,MAAM,EAAE;CAChG,IAAI,SAAS;CACb,MAAM,UAAU,KAAK,IAAI,OAAO,QAAQ,MAAM,MAAM;CACpD,OAAO,SAAS,WAAW,OAAO,YAAY,MAAM,SAAS;CAC7D,IAAI,SAAS;CACb,OACE,SAAS,UAAU,UACnB,OAAO,OAAO,SAAS,IAAI,YAAY,MAAM,MAAM,SAAS,IAAI,SAEhE;CAEF,OAAO,yBACL,YACA,QACA,QACA,OAAO,SAAS,QAChB,MAAM,MAAM,QAAQ,MAAM,SAAS,MAAM,CAC3C;AACF"}
|
|
1
|
+
{"version":3,"file":"paragraphs.js","names":[],"sources":["../../src/text/paragraphs.ts"],"sourcesContent":["import { omit } from 'es-toolkit'\n\nimport type {\n SceneNode,\n TextListType,\n TextParagraphSpacingField,\n TextParagraphStyle\n} from '../types'\n\n/** The style of a paragraph with no entry: not in a list. */\nexport const PLAIN_PARAGRAPH: Readonly<TextParagraphStyle> = Object.freeze({\n listType: 'NONE',\n indentation: 0\n})\n\n/** Figma nests list items at most this deep. */\nexport const MAX_LIST_INDENTATION = 5\n\n/** A paragraph's characters: `start` to `end`, not counting the newline that ends it. */\nexport interface TextParagraphRange {\n start: number\n end: number\n}\n\n/** The paragraphs of `text`: one per line ending at a newline, and one after the last. */\nexport function textParagraphRanges(text: string): TextParagraphRange[] {\n const ranges: TextParagraphRange[] = []\n let start = 0\n for (let index = text.indexOf('\\n'); index !== -1; index = text.indexOf('\\n', start)) {\n ranges.push({ start, end: index })\n start = index + 1\n }\n ranges.push({ start, end: text.length })\n return ranges\n}\n\n/** The paragraph holding character `index`; a newline belongs to the paragraph it ends. */\nexport function paragraphIndexAt(text: string, index: number): number {\n let paragraph = 0\n const end = Math.min(index, text.length)\n for (let at = text.indexOf('\\n'); at !== -1 && at < end; at = text.indexOf('\\n', at + 1)) {\n paragraph++\n }\n return paragraph\n}\n\nexport function paragraphStyleAt(\n paragraphs: readonly TextParagraphStyle[],\n paragraph: number\n): TextParagraphStyle {\n return paragraphs[paragraph] ?? PLAIN_PARAGRAPH\n}\n\nexport const TEXT_PARAGRAPH_SPACING_FIELDS: readonly TextParagraphSpacingField[] = [\n 'listSpacing',\n 'paragraphSpacing',\n 'paragraphIndent'\n]\n\n/** A paragraph's spacing: its own value, or the text's when it sets none. */\nexport function paragraphSpacingAt(\n node: Pick<SceneNode, 'textParagraphs' | TextParagraphSpacingField>,\n paragraph: number,\n field: TextParagraphSpacingField\n): number {\n return paragraphStyleAt(node.textParagraphs, paragraph)[field] ?? node[field]\n}\n\n/** Whether a paragraph sets any spacing of its own. */\nexport function hasParagraphSpacing(style: TextParagraphStyle): boolean {\n return TEXT_PARAGRAPH_SPACING_FIELDS.some((field) => style[field] !== undefined)\n}\n\n/** A paragraph style with its own `field` set, or following the text again for `undefined`. */\nexport function withParagraphSpacing(\n style: TextParagraphStyle,\n field: TextParagraphSpacingField,\n value: number | undefined\n): TextParagraphStyle {\n const { [field]: _previous, ...rest } = style\n return value === undefined ? rest : { ...rest, [field]: value }\n}\n\n/** Every paragraph's `field`, or `null` when they differ. */\nexport function sharedParagraphSpacing(\n node: Pick<SceneNode, 'text' | 'textParagraphs' | TextParagraphSpacingField>,\n field: TextParagraphSpacingField,\n first = 0,\n last = paragraphCount(node.text) - 1\n): number | null {\n const value = paragraphSpacingAt(node, first, field)\n for (let index = first + 1; index <= last; index++) {\n if (paragraphSpacingAt(node, index, field) !== value) return null\n }\n return value\n}\n\n/** Paragraph styles with no paragraph setting its own `field`, as setting the text's does. */\nexport function paragraphStylesWithoutSpacing(\n paragraphs: readonly TextParagraphStyle[],\n field: TextParagraphSpacingField\n): TextParagraphStyle[] {\n return trimParagraphStyles(\n paragraphs.map((style) => withParagraphSpacing(style, field, undefined)),\n paragraphs.length\n )\n}\n\n/** Whether any paragraph of the node is a list item. */\nexport function hasTextList(node: Pick<SceneNode, 'textParagraphs'>): boolean {\n return node.textParagraphs.some((paragraph) => paragraph.listType !== 'NONE')\n}\n\n/**\n * Paragraph styles for `count` paragraphs, without the plain paragraphs at the end, so text\n * without lists, indentation, or paragraph spacing of its own keeps none.\n */\nexport function trimParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n count: number\n): TextParagraphStyle[] {\n const styles = paragraphs.slice(0, count).map((paragraph) => ({ ...paragraph }))\n while (styles.length > 0) {\n const last = styles[styles.length - 1]\n if (last.listType !== 'NONE' || last.indentation !== 0 || hasParagraphSpacing(last)) break\n styles.pop()\n }\n return styles\n}\n\n/** How many paragraphs `text` has: one more than its newlines. */\nexport function paragraphCount(text: string): number {\n let count = 1\n for (let at = text.indexOf('\\n'); at !== -1; at = text.indexOf('\\n', at + 1)) count++\n return count\n}\n\n/**\n * Paragraph styles after replacing `text[start, end)` with `inserted`, as Figma keeps them: the\n * paragraph the edit starts in keeps its style, paragraphs a deleted newline joins to it are\n * dropped, and paragraphs an inserted newline starts take its style.\n */\nexport function paragraphStylesAfterEdit(\n paragraphs: readonly TextParagraphStyle[],\n text: string,\n start: number,\n end: number,\n inserted: string\n): TextParagraphStyle[] {\n if (paragraphs.length === 0) return []\n const first = paragraphIndexAt(text, start)\n const last = paragraphIndexAt(text, end)\n const style = paragraphStyleAt(paragraphs, first)\n const added = paragraphCount(inserted) - 1\n // A paragraph a newline starts is a new item: a checklist's starts with its box open.\n const opened = omit(style, ['checked'])\n const next = [\n ...Array.from({ length: first }, (_, index) => paragraphStyleAt(paragraphs, index)),\n style,\n ...Array.from({ length: added }, () => opened),\n ...paragraphs.slice(last + 1)\n ]\n return trimParagraphStyles(next, paragraphCount(text) - (last - first) + added)\n}\n\n/**\n * Paragraph styles with every paragraph that `text[start, end)` touches changed by `change`,\n * as a range setter changes whole paragraphs.\n */\nexport function paragraphStylesInRange(\n paragraphs: readonly TextParagraphStyle[],\n text: string,\n start: number,\n end: number,\n change: (style: TextParagraphStyle) => TextParagraphStyle\n): TextParagraphStyle[] {\n const count = paragraphCount(text)\n const first = paragraphIndexAt(text, start)\n // An empty range still names the paragraph it sits in; a range ending right after a\n // newline does not reach into the next paragraph.\n const last = end > start ? paragraphIndexAt(text, end - 1) : first\n const next = Array.from({ length: count }, (_, index) => {\n const style = paragraphStyleAt(paragraphs, index)\n return index >= first && index <= last ? change(style) : style\n })\n return trimParagraphStyles(next, count)\n}\n\n/**\n * A paragraph style with its list type set. A list item is nested at least one level, and a\n * paragraph leaving a list keeps no indentation.\n */\nexport function withListType(\n style: TextParagraphStyle,\n listType: TextListType\n): TextParagraphStyle {\n // Only a checklist item keeps its tick.\n const kept = listType === 'CHECKLIST' ? style : omit(style, ['checked'])\n if (listType === 'NONE') return { ...kept, listType, indentation: 0 }\n return { ...kept, listType, indentation: clampListIndentation(style.indentation) }\n}\n\n/** A paragraph style with its nesting set, kept in the range a list item allows. */\nexport function withIndentation(\n style: TextParagraphStyle,\n indentation: number\n): TextParagraphStyle {\n if (style.listType === 'NONE') {\n return {\n ...style,\n indentation: Math.max(0, Math.min(MAX_LIST_INDENTATION, Math.round(indentation)))\n }\n }\n return { ...style, indentation: clampListIndentation(indentation) }\n}\n\nfunction clampListIndentation(indentation: number): number {\n return Math.max(1, Math.min(MAX_LIST_INDENTATION, Math.round(indentation)))\n}\n\n/**\n * Paragraph styles after `before` became `after` through one edit, found as the text between\n * their common start and end, for editors that replace the text rather than report the edit.\n */\nexport function paragraphStylesAfterTextChange(\n paragraphs: readonly TextParagraphStyle[],\n before: string,\n after: string\n): TextParagraphStyle[] {\n if (paragraphs.length === 0 || before === after) return paragraphs.map((style) => ({ ...style }))\n let prefix = 0\n const shorter = Math.min(before.length, after.length)\n while (prefix < shorter && before[prefix] === after[prefix]) prefix++\n let suffix = 0\n while (\n suffix < shorter - prefix &&\n before[before.length - 1 - suffix] === after[after.length - 1 - suffix]\n ) {\n suffix++\n }\n return paragraphStylesAfterEdit(\n paragraphs,\n before,\n prefix,\n before.length - suffix,\n after.slice(prefix, after.length - suffix)\n )\n}\n"],"mappings":"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"}
|
package/dist/text/path.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// src/text/path.ts
|
|
2
2
|
function followsPath(node) {
|
|
3
3
|
const glyphs = node.derivedTextGlyphs ?? [];
|
|
4
4
|
if (glyphs.length === 0) return false;
|
|
5
5
|
return !!node.textPathData || !!node.textPathBox || glyphs.some((glyph) => (glyph.rotation ?? 0) !== 0);
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { followsPath };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=path.js.map
|
package/dist/text/picture.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { SceneNode } from "../types.js";
|
|
2
|
-
//#region src/text/picture.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Invalidate cached Skia textPicture (Paragraph snapshot). Includes width/height
|
|
5
4
|
* because wrapping/layout depends on the box.
|
|
6
5
|
*/
|
|
7
|
-
declare const TEXT_PICTURE_KEYS: ReadonlySet<string>;
|
|
8
|
-
declare const GLYPH_AFFECTING_KEYS: ReadonlySet<string>;
|
|
6
|
+
export declare const TEXT_PICTURE_KEYS: ReadonlySet<string>;
|
|
7
|
+
export declare const GLYPH_AFFECTING_KEYS: ReadonlySet<string>;
|
|
9
8
|
/**
|
|
10
9
|
* Shared by SceneGraph.updateNode and updateNodePreview (drag hot path) so the
|
|
11
10
|
* two invalidation rules cannot drift. Glyphs are kept when the caller
|
|
12
11
|
* replaces them in the same update (resize supplies scaled copies).
|
|
13
12
|
*/
|
|
14
|
-
declare function textCacheInvalidationChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { GLYPH_AFFECTING_KEYS, TEXT_PICTURE_KEYS, textCacheInvalidationChanges };
|
|
13
|
+
export declare function textCacheInvalidationChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
17
14
|
//# sourceMappingURL=picture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picture.d.ts","names":[],"sources":["../../src/text/picture.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"picture.d.ts","names":[],"sources":["../../src/text/picture.ts"],"mappings":";;;;;qBASa,mBAAmB;qBAQnB,sBAAsB;;;;;;wBAOnB,6BACd,MAAM,WACN,SAAS,QAAQ,aAChB,QAAQ"}
|
package/dist/text/picture.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TEXT_LAYOUT_FIELDS, TEXT_SHAPING_FIELDS } from "../fields/text.js";
|
|
2
1
|
import { isEqual } from "es-toolkit/predicate";
|
|
3
|
-
|
|
2
|
+
import { TEXT_LAYOUT_FIELDS, TEXT_SHAPING_FIELDS } from "../fields/text.js";
|
|
3
|
+
// src/text/picture.ts
|
|
4
4
|
/**
|
|
5
5
|
* Invalidate cached Skia textPicture (Paragraph snapshot). Includes width/height
|
|
6
6
|
* because wrapping/layout depends on the box.
|
|
@@ -32,7 +32,6 @@ function textCacheInvalidationChanges(node, changes) {
|
|
|
32
32
|
}
|
|
33
33
|
return invalidated;
|
|
34
34
|
}
|
|
35
|
-
//#endregion
|
|
36
35
|
export { GLYPH_AFFECTING_KEYS, TEXT_PICTURE_KEYS, textCacheInvalidationChanges };
|
|
37
36
|
|
|
38
37
|
//# sourceMappingURL=picture.js.map
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { StyleRun } from "../types.js";
|
|
2
|
-
//#region src/text/references.d.ts
|
|
3
2
|
/** What a text's runs refer to outside the text: the variables they bind and the styles they use. */
|
|
4
|
-
interface StyleRunReferences {
|
|
3
|
+
export interface StyleRunReferences {
|
|
5
4
|
variables: string[];
|
|
6
5
|
styles: string[];
|
|
7
6
|
}
|
|
8
7
|
/** The variables and styles a text's runs refer to, which copies and transfers carry with it. */
|
|
9
|
-
declare function styleRunReferences(runs: readonly StyleRun[]): StyleRunReferences;
|
|
8
|
+
export declare function styleRunReferences(runs: readonly StyleRun[]): StyleRunReferences;
|
|
10
9
|
/**
|
|
11
10
|
* Runs whose variables, styles, and linked layers are renamed, as a copy into another document
|
|
12
11
|
* renames them. Layers are renamed only when given, since a link may name a layer left behind.
|
|
13
12
|
*/
|
|
14
|
-
declare function remapStyleRunReferences(runs: readonly StyleRun[], rename: {
|
|
13
|
+
export declare function remapStyleRunReferences(runs: readonly StyleRun[], rename: {
|
|
15
14
|
variable: (id: string) => string;
|
|
16
15
|
style: (id: string) => string;
|
|
17
16
|
node?: (id: string) => string;
|
|
18
17
|
}): StyleRun[];
|
|
19
|
-
//#endregion
|
|
20
|
-
export { StyleRunReferences, remapStyleRunReferences, styleRunReferences };
|
|
21
18
|
//# sourceMappingURL=references.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","names":[],"sources":["../../src/text/references.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"references.d.ts","names":[],"sources":["../../src/text/references.ts"],"mappings":";;iBAGiB;EACf;EACA;;;wBAIc,mBAAmB,eAAe,aAAa;;;;;wBAe/C,wBACd,eAAe,YACf;EACE,WAAW;EACX,QAAQ;EACR,QAAQ;IAET"}
|
package/dist/text/references.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/text/references.ts
|
|
2
2
|
/** The variables and styles a text's runs refer to, which copies and transfers carry with it. */
|
|
3
3
|
function styleRunReferences(runs) {
|
|
4
4
|
const variables = /* @__PURE__ */ new Set();
|
|
@@ -36,7 +36,6 @@ function remapStyleRunReferences(runs, rename) {
|
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
//#endregion
|
|
40
39
|
export { remapStyleRunReferences, styleRunReferences };
|
|
41
40
|
|
|
42
41
|
//# sourceMappingURL=references.js.map
|
package/dist/text/runs.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { CharacterStyleOverride, SceneNode, StyleRun } from "../types.js";
|
|
2
|
-
//#region src/text/runs.d.ts
|
|
3
2
|
/** The run that styles `text[index]`, if one does. */
|
|
4
|
-
declare function styleRunAt(runs: readonly StyleRun[], index: number): StyleRun | undefined;
|
|
3
|
+
export declare function styleRunAt(runs: readonly StyleRun[], index: number): StyleRun | undefined;
|
|
5
4
|
/** The language `text[index]` is shaped in: its run's, or the text's own. */
|
|
6
|
-
declare function textLanguageAt(node: Pick<SceneNode, 'styleRuns' | 'textLanguage'>, index: number): string | null;
|
|
5
|
+
export declare function textLanguageAt(node: Pick<SceneNode, 'styleRuns' | 'textLanguage'>, index: number): string | null;
|
|
7
6
|
/**
|
|
8
7
|
* Adds `style` over `[start, start + length)` to runs built in text order, extending the last
|
|
9
8
|
* run instead when it ends at `start` with an equal style. An empty style or range adds nothing,
|
|
10
9
|
* since those characters keep the text's own style.
|
|
11
10
|
*/
|
|
12
|
-
declare function appendStyleRun(runs: StyleRun[], start: number, length: number, style: CharacterStyleOverride): void;
|
|
11
|
+
export declare function appendStyleRun(runs: StyleRun[], start: number, length: number, style: CharacterStyleOverride): void;
|
|
13
12
|
/** A stretch of text in one style: a run's, or the text's own where `style` is null. */
|
|
14
|
-
interface StyleRunPiece {
|
|
13
|
+
export interface StyleRunPiece {
|
|
15
14
|
start: number;
|
|
16
15
|
end: number;
|
|
17
16
|
style: CharacterStyleOverride | null;
|
|
@@ -21,9 +20,7 @@ interface StyleRunPiece {
|
|
|
21
20
|
* a run's part that an earlier run already covers, or that lies past the text, is left out.
|
|
22
21
|
* `boundary` moves each cut to where the text may be cut, such as out of a surrogate pair.
|
|
23
22
|
*/
|
|
24
|
-
declare function styleRunPieces(runs: readonly StyleRun[], length: number, boundary?: (index: number) => number): StyleRunPiece[];
|
|
23
|
+
export declare function styleRunPieces(runs: readonly StyleRun[], length: number, boundary?: (index: number) => number): StyleRunPiece[];
|
|
25
24
|
/** Each of the first `length` characters' overrides, merged from the runs over it in order. */
|
|
26
|
-
declare function characterOverrides(runs: readonly StyleRun[], length: number): CharacterStyleOverride[];
|
|
27
|
-
//#endregion
|
|
28
|
-
export { StyleRunPiece, appendStyleRun, characterOverrides, styleRunAt, styleRunPieces, textLanguageAt };
|
|
25
|
+
export declare function characterOverrides(runs: readonly StyleRun[], length: number): CharacterStyleOverride[];
|
|
29
26
|
//# sourceMappingURL=runs.d.ts.map
|
package/dist/text/runs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.d.ts","names":[],"sources":["../../src/text/runs.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runs.d.ts","names":[],"sources":["../../src/text/runs.ts"],"mappings":";;wBAKgB,WAAW,eAAe,YAAY,gBAAgB;;wBAKtD,eACd,MAAM,KAAK,0CACX;;;;;;wBAWc,eACd,MAAM,YACN,eACA,gBACA,OAAO;;iBAUQ;EACf;EACA;EACA,OAAO;;;;;;;wBAQO,eACd,eAAe,YACf,gBACA,YAAW,2BACV;;wBAea,mBACd,eAAe,YACf,iBACC"}
|
package/dist/text/runs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEqual } from "es-toolkit/predicate";
|
|
2
|
-
|
|
2
|
+
// src/text/runs.ts
|
|
3
3
|
/** The run that styles `text[index]`, if one does. */
|
|
4
4
|
function styleRunAt(runs, index) {
|
|
5
5
|
return runs.find((run) => index >= run.start && index < run.start + run.length);
|
|
@@ -66,7 +66,6 @@ function characterOverrides(runs, length) {
|
|
|
66
66
|
}
|
|
67
67
|
return styles;
|
|
68
68
|
}
|
|
69
|
-
//#endregion
|
|
70
69
|
export { appendStyleRun, characterOverrides, styleRunAt, styleRunPieces, textLanguageAt };
|
|
71
70
|
|
|
72
71
|
//# sourceMappingURL=runs.js.map
|
package/dist/text/schema.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
//#region src/text/schema.d.ts
|
|
3
2
|
/** A line height or letter spacing as files carry it: pixels, or a percent of the font size. */
|
|
4
|
-
declare const textLengthSchema: v.ObjectSchema<{
|
|
3
|
+
export declare const textLengthSchema: v.ObjectSchema<{
|
|
5
4
|
readonly value: v.NumberSchema<undefined>;
|
|
6
5
|
readonly unit: v.PicklistSchema<["PIXELS", "PERCENT"], undefined>;
|
|
7
6
|
}, undefined>;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { textLengthSchema };
|
|
10
7
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/text/schema.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/text/schema.ts"],"mappings":";;qBAGa,kBAAgB,EAAA"}
|
package/dist/text/schema.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
|
|
2
|
+
// src/text/schema.ts
|
|
3
3
|
/** A line height or letter spacing as files carry it: pixels, or a percent of the font size. */
|
|
4
4
|
const textLengthSchema = v.object({
|
|
5
5
|
value: v.number(),
|
|
6
6
|
unit: v.picklist(["PIXELS", "PERCENT"])
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export { textLengthSchema };
|
|
10
9
|
|
|
11
10
|
//# sourceMappingURL=schema.js.map
|
package/dist/thumbnail.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { SceneGraph } from "./graph.js";
|
|
2
2
|
import { SceneNode } from "./types.js";
|
|
3
|
-
//#region src/thumbnail.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Whether `node` can be the document's thumbnail: a frame, section, or component placed straight
|
|
6
5
|
* on a page people see, or a slide.
|
|
7
6
|
*/
|
|
8
|
-
declare function canBeDocumentThumbnail(graph: SceneGraph, node: SceneNode): boolean;
|
|
7
|
+
export declare function canBeDocumentThumbnail(graph: SceneGraph, node: SceneNode): boolean;
|
|
9
8
|
/**
|
|
10
9
|
* The id stored as the document's thumbnail, whether or not that layer is loaded or can still be
|
|
11
10
|
* one: what undo restores.
|
|
12
11
|
*/
|
|
13
|
-
declare function documentThumbnailId(graph: SceneGraph): string | null;
|
|
12
|
+
export declare function documentThumbnailId(graph: SceneGraph): string | null;
|
|
14
13
|
/**
|
|
15
14
|
* The layer chosen as the document's thumbnail, or null when there is none or it can no longer
|
|
16
15
|
* be one, such as after it was deleted or moved into another frame.
|
|
17
16
|
*/
|
|
18
|
-
declare function documentThumbnail(graph: SceneGraph): SceneNode | null;
|
|
17
|
+
export declare function documentThumbnail(graph: SceneGraph): SceneNode | null;
|
|
19
18
|
/** Chooses `nodeId` as the document's thumbnail, or goes back to the default with null. */
|
|
20
|
-
declare function setDocumentThumbnail(graph: SceneGraph, nodeId: string | null): void;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { canBeDocumentThumbnail, documentThumbnail, documentThumbnailId, setDocumentThumbnail };
|
|
19
|
+
export declare function setDocumentThumbnail(graph: SceneGraph, nodeId: string | null): void;
|
|
23
20
|
//# sourceMappingURL=thumbnail.d.ts.map
|
package/dist/thumbnail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thumbnail.d.ts","names":[],"sources":["../src/thumbnail.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"thumbnail.d.ts","names":[],"sources":["../src/thumbnail.ts"],"mappings":";;;;;;wBAmBgB,uBAAuB,OAAO,YAAY,MAAM;;;;;wBAWhD,oBAAoB,OAAO;;;;;wBAQ3B,kBAAkB,OAAO,aAAa;;wBAOtC,qBAAqB,OAAO,YAAY"}
|