Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
import { describe, test, expect } from 'bun:test'
|
|
|
|
|
|
2026-08-17 16:32:40 +00:00
|
|
|
import type { CanvasKit, Paragraph, RectWithDirection } from 'canvaskit-wasm'
|
2026-05-05 21:42:45 +00:00
|
|
|
|
2026-05-05 23:22:08 +00:00
|
|
|
import { TextEditor, type SceneNode } from '@open-pencil/core'
|
2026-08-17 16:32:40 +00:00
|
|
|
import { createDefaultNode } from '@open-pencil/scene-graph/node-defaults'
|
2026-05-05 23:22:08 +00:00
|
|
|
|
2026-05-06 08:44:18 +00:00
|
|
|
import { expectDefined } from '#tests/helpers/assert'
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
import { asDouble } from '#tests/helpers/doubles'
|
2026-05-06 08:44:18 +00:00
|
|
|
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
const mockCk = asDouble<CanvasKit>({
|
2026-08-17 16:32:40 +00:00
|
|
|
RectHeightStyle: { Max: 0 },
|
|
|
|
|
RectWidthStyle: { Tight: 0 }
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
})
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
|
|
|
|
|
function createEditor(text = 'Hello World') {
|
|
|
|
|
const editor = new TextEditor(mockCk)
|
|
|
|
|
const node = { id: 'test-node', text } as SceneNode
|
|
|
|
|
editor.start(node)
|
|
|
|
|
return { editor, node }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-06 08:44:18 +00:00
|
|
|
function editorState(editor: TextEditor) {
|
|
|
|
|
return expectDefined(editor.state, 'text editor state')
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-17 16:32:40 +00:00
|
|
|
function createParagraphEditor(textAlignVertical: SceneNode['textAlignVertical']) {
|
|
|
|
|
const hitTestYs: number[] = []
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
const rects = [asDouble<RectWithDirection>({ rect: [4, 2, 14, 12] })]
|
2026-08-17 16:32:40 +00:00
|
|
|
const lineMetrics = {
|
|
|
|
|
endExcludingWhitespaces: 5,
|
|
|
|
|
height: 10,
|
|
|
|
|
left: 3,
|
|
|
|
|
startIndex: 0
|
|
|
|
|
}
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
const paragraph = asDouble<Paragraph>({
|
2026-08-17 16:32:40 +00:00
|
|
|
delete: () => undefined,
|
|
|
|
|
getGlyphPositionAtCoordinate: (_x: number, y: number) => {
|
|
|
|
|
hitTestYs.push(y)
|
|
|
|
|
return { pos: Math.round(y) }
|
|
|
|
|
},
|
|
|
|
|
getHeight: () => 20,
|
|
|
|
|
getLineMetrics: () => [lineMetrics],
|
|
|
|
|
getLineMetricsAt: () => lineMetrics,
|
|
|
|
|
getLineNumberAt: () => 0,
|
|
|
|
|
getRectsForRange: () => rects
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
})
|
|
|
|
|
const renderer = asDouble<Parameters<TextEditor['setRenderer']>[0]>({
|
2026-08-17 16:32:40 +00:00
|
|
|
buildParagraph: () => paragraph,
|
|
|
|
|
fontGeneration: 1
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
})
|
2026-08-17 16:32:40 +00:00
|
|
|
const editor = new TextEditor(mockCk)
|
test: typecheck the test suites and fix what that found (#896)
* build: typecheck the test suites
Tests were in no TypeScript program: no tsconfig included tests/** or
packages/*/tests/**, and bun strips types without checking them, so a
fixture could drop a required field and keep passing until something
read it.
@types/bun moves to the root because it was installed per package only,
and #cli-tests/* joins the paths the root config already carries.
* test: fix the type errors the test suites were hiding
Typechecking the tests turned up 1123 errors. Most were ordinary
strictness, but some were real: `NodeChange` bound to Figma's plugin
typings rather than the Kiwi codec in thirteen .fig tests,
materializeInstance was called with six arguments against five so the
blobs and source children were dropped, CanvasKit pixels were written
to a plain object that never reached WASM, and assertions were made
through accessors that do not exist, so they asserted nothing.
Fixtures that had quietly lost a required field now carry it, nullable
results are narrowed through the existing expectDefined helper rather
than assumed, and stand-ins for CanvasKit and the editor go through one
named helper instead of an unexplained cast at each site.
No test was deleted, skipped, or weakened, and no `any`, non-null
assertion, or ts-expect-error was introduced.
* docs: record what typechecking the tests established
Pins the app program's global types with an assertion rather than a
note, since an unpinned types list lets any root @types package decide
which platform src/** is judged against.
The two environment faults that look like code regressions — Vite's
dependency pre-bundle outliving a package rebuild, and heavy .fig
suites failing under load — go to the development docs, where an
explanation belongs.
* fix: align @types/bun and keep node types resolvable when extended
The root manifest declared a newer @types/bun than every package, which
check:monorepo rejects, and pinning the app program's types left them
unresolvable from a config that extends this one out of tree.
* fix: fail the test typecheck when the compiler itself fails
The gate matched diagnostics by substring, so a compiler or config
failure that named no test file printed a pass while having checked
nothing. Diagnostics are now split by whether they name a file: an
unscoped one is the run failing and stops the gate, a test file's is a
finding, and a source file's stays out by design.
Also drops the parameter planComponentConstruction never read, and
makes the inner-shadow verification script exit non-zero when it
renders no image instead of logging and succeeding.
* chore: merge master into tests-typecheck
2026-10-05 12:42:38 +00:00
|
|
|
editor.setRenderer(renderer)
|
2026-08-17 16:32:40 +00:00
|
|
|
const node = createDefaultNode(() => 'aligned-text', 'TEXT', {
|
|
|
|
|
height: 100,
|
|
|
|
|
text: 'Hello',
|
|
|
|
|
textAlignVertical
|
|
|
|
|
})
|
|
|
|
|
editor.start(node)
|
|
|
|
|
return { editor, hitTestYs }
|
|
|
|
|
}
|
|
|
|
|
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
describe('TextEditor', () => {
|
|
|
|
|
test('start initializes state', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
expect(editor.isActive).toBe(true)
|
|
|
|
|
expect(editor.nodeId).toBe('test-node')
|
|
|
|
|
expect(editor.state?.text).toBe('Hello World')
|
|
|
|
|
expect(editor.state?.cursor).toBe(11)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('stop returns result and clears state', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
const result = editor.stop()
|
|
|
|
|
expect(result?.nodeId).toBe('test-node')
|
|
|
|
|
expect(result?.text).toBe('Hello World')
|
|
|
|
|
expect(editor.isActive).toBe(false)
|
|
|
|
|
expect(editor.nodeId).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('stop on inactive returns null', () => {
|
|
|
|
|
const editor = new TextEditor(mockCk)
|
|
|
|
|
expect(editor.stop()).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('insert at end', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
|
|
|
|
editor.insert('!', node)
|
|
|
|
|
expect(editor.state?.text).toBe('Hello World!')
|
|
|
|
|
expect(editor.state?.cursor).toBe(12)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('insert at cursor position', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).cursor = 5
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.insert(' Beautiful', node)
|
|
|
|
|
expect(editor.state?.text).toBe('Hello Beautiful World')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('insert replaces selection', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 0
|
|
|
|
|
editorState(editor).cursor = 5
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.insert('Goodbye', node)
|
|
|
|
|
expect(editor.state?.text).toBe('Goodbye World')
|
|
|
|
|
expect(editor.state?.cursor).toBe(7)
|
|
|
|
|
expect(editor.state?.selectionAnchor).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('backspace deletes char before cursor', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
|
|
|
|
editor.backspace(node)
|
|
|
|
|
expect(editor.state?.text).toBe('Hello Worl')
|
|
|
|
|
expect(editor.state?.cursor).toBe(10)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('backspace at start does nothing', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).cursor = 0
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.backspace(node)
|
|
|
|
|
expect(editor.state?.text).toBe('Hello World')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('backspace deletes selection', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 6
|
|
|
|
|
editorState(editor).cursor = 11
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.backspace(node)
|
|
|
|
|
expect(editor.state?.text).toBe('Hello ')
|
|
|
|
|
expect(editor.state?.cursor).toBe(6)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('delete removes char after cursor', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).cursor = 0
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.delete(node)
|
|
|
|
|
expect(editor.state?.text).toBe('ello World')
|
|
|
|
|
expect(editor.state?.cursor).toBe(0)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('delete at end does nothing', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
|
|
|
|
editor.delete(node)
|
|
|
|
|
expect(editor.state?.text).toBe('Hello World')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('delete removes selection', () => {
|
|
|
|
|
const { editor, node } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 0
|
|
|
|
|
editorState(editor).cursor = 5
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.delete(node)
|
|
|
|
|
expect(editor.state?.text).toBe(' World')
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-17 16:32:40 +00:00
|
|
|
test('offsets hit testing, caret, and selection for vertical alignment', () => {
|
|
|
|
|
for (const [alignment, offset] of [
|
|
|
|
|
['TOP', 0],
|
|
|
|
|
['CENTER', 40],
|
|
|
|
|
['BOTTOM', 80]
|
|
|
|
|
] as const) {
|
|
|
|
|
const { editor, hitTestYs } = createParagraphEditor(alignment)
|
|
|
|
|
editorState(editor).selectionAnchor = 0
|
|
|
|
|
editorState(editor).cursor = 5
|
|
|
|
|
|
|
|
|
|
expect(editor.getSelectionRects()).toEqual([{ x: 4, y: 2 + offset, width: 10, height: 10 }])
|
|
|
|
|
editorState(editor).selectionAnchor = null
|
|
|
|
|
expect(editor.getCaretRect()).toEqual({ x: 14, y0: 2 + offset, y1: 12 + offset })
|
|
|
|
|
|
|
|
|
|
editor.setCursorAt(4, offset + 3)
|
|
|
|
|
expect(hitTestYs.at(-1)).toBe(3)
|
|
|
|
|
expect(editorState(editor).cursor).toBe(3)
|
|
|
|
|
|
|
|
|
|
editor.selectWordAt(4, offset + 2)
|
|
|
|
|
expect(hitTestYs.at(-1)).toBe(2)
|
|
|
|
|
expect(editor.getSelectionRange()).toEqual([0, 5])
|
|
|
|
|
|
|
|
|
|
editor.selectLineAt(4, offset + 4)
|
|
|
|
|
expect(hitTestYs.at(-1)).toBe(4)
|
|
|
|
|
expect(editor.getSelectionRange()).toEqual([0, 5])
|
|
|
|
|
|
|
|
|
|
editorState(editor).selectionAnchor = null
|
|
|
|
|
editorState(editor).cursor = 1
|
|
|
|
|
editor.moveUp()
|
|
|
|
|
expect(hitTestYs.at(-1)).toBe(-3)
|
|
|
|
|
|
|
|
|
|
editorState(editor).cursor = 1
|
|
|
|
|
editor.moveDown()
|
|
|
|
|
expect(hitTestYs.at(-1)).toBe(17)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2026-10-06 12:33:49 +00:00
|
|
|
test('places the caret of empty text, which CanvasKit lays out no line for', () => {
|
|
|
|
|
const empty = asDouble<Paragraph>({
|
|
|
|
|
delete: () => undefined,
|
|
|
|
|
getHeight: () => 0,
|
|
|
|
|
getLineMetrics: () => []
|
|
|
|
|
})
|
|
|
|
|
const space = asDouble<Paragraph>({
|
|
|
|
|
delete: () => undefined,
|
|
|
|
|
getHeight: () => 17,
|
|
|
|
|
getLineMetrics: () => [{ height: 17, left: 0 }]
|
|
|
|
|
})
|
|
|
|
|
const editor = new TextEditor(mockCk)
|
|
|
|
|
editor.setRenderer(
|
|
|
|
|
asDouble<Parameters<TextEditor['setRenderer']>[0]>({
|
|
|
|
|
buildParagraph: (node: SceneNode) => (node.text === '' ? empty : space),
|
|
|
|
|
fontGeneration: 1
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
editor.start(
|
|
|
|
|
createDefaultNode(() => 'new-text', 'TEXT', {
|
|
|
|
|
text: '',
|
|
|
|
|
width: 120,
|
|
|
|
|
height: 57,
|
|
|
|
|
textAlignHorizontal: 'CENTER',
|
|
|
|
|
textAlignVertical: 'BOTTOM'
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
expect(editor.getCaretRect()).toEqual({ x: 60, y0: 40, y1: 57 })
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-17 16:32:40 +00:00
|
|
|
test('offsets the empty-text caret for vertical alignment', () => {
|
|
|
|
|
const { editor } = createParagraphEditor('BOTTOM')
|
|
|
|
|
editorState(editor).text = ''
|
|
|
|
|
editorState(editor).cursor = 0
|
|
|
|
|
|
|
|
|
|
expect(editor.getCaretRect()).toEqual({ x: 3, y0: 80, y1: 90 })
|
|
|
|
|
})
|
|
|
|
|
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
test('moveLeft', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
editor.moveLeft()
|
|
|
|
|
expect(editor.state?.cursor).toBe(10)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('moveRight at end stays', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
editor.moveRight()
|
|
|
|
|
expect(editor.state?.cursor).toBe(11)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('moveLeft collapses selection to start', () => {
|
|
|
|
|
const { editor } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 3
|
|
|
|
|
editorState(editor).cursor = 8
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.moveLeft()
|
|
|
|
|
expect(editor.state?.cursor).toBe(3)
|
|
|
|
|
expect(editor.state?.selectionAnchor).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('moveRight collapses selection to end', () => {
|
|
|
|
|
const { editor } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 3
|
|
|
|
|
editorState(editor).cursor = 8
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.moveRight()
|
|
|
|
|
expect(editor.state?.cursor).toBe(8)
|
|
|
|
|
expect(editor.state?.selectionAnchor).toBeNull()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('selectAll', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
editor.selectAll()
|
|
|
|
|
expect(editor.state?.selectionAnchor).toBe(0)
|
|
|
|
|
expect(editor.state?.cursor).toBe(11)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('hasSelection', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
expect(editor.hasSelection()).toBe(false)
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 0
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
expect(editor.hasSelection()).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('hasSelection false when anchor equals cursor', () => {
|
|
|
|
|
const { editor } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = editorState(editor).cursor
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
expect(editor.hasSelection()).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('getSelectionRange', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
expect(editor.getSelectionRange()).toBeNull()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 8
|
|
|
|
|
editorState(editor).cursor = 3
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
expect(editor.getSelectionRange()).toEqual([3, 8])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('getSelectedText', () => {
|
|
|
|
|
const { editor } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).selectionAnchor = 0
|
|
|
|
|
editorState(editor).cursor = 5
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
expect(editor.getSelectedText()).toBe('Hello')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('selectWord', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
editor.selectWord(2)
|
|
|
|
|
expect(editor.state?.selectionAnchor).toBe(0)
|
|
|
|
|
expect(editor.state?.cursor).toBe(5)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('selectWord on second word', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
editor.selectWord(8)
|
|
|
|
|
expect(editor.state?.selectionAnchor).toBe(6)
|
|
|
|
|
expect(editor.state?.cursor).toBe(11)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('moveWordLeft', () => {
|
|
|
|
|
const { editor } = createEditor()
|
|
|
|
|
editor.moveWordLeft()
|
|
|
|
|
expect(editor.state?.cursor).toBe(6)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('moveWordRight from start', () => {
|
|
|
|
|
const { editor } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).cursor = 0
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.moveWordRight()
|
|
|
|
|
expect(editor.state?.cursor).toBe(6)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('moveLeft with extend creates selection', () => {
|
|
|
|
|
const { editor } = createEditor()
|
2026-05-06 08:44:18 +00:00
|
|
|
editorState(editor).cursor = 5
|
Clean up tools/schema, add geometry.ts, isMixed helper, fix imports, add tests
- Strip tools/schema.ts from 1831 to 65 lines (remove duplicate tool defs)
- Fix tools/index.ts to export ALL_TOOLS from registry instead of schema
- Fix renderJsx → renderJSX typo in tools/create.ts and structure.ts
- Add geometry.ts with shared rotation/coordinate math utilities
- Add isArrayMixed() helper to use-multi-props.ts, deduplicate FillSection/StrokeSection/EffectsSection
- Fix broken test imports: use @open-pencil/core instead of relative paths into packages/core/src/
- Merge duplicate import statements across all test files
- Export profiler internals and style-run helpers from core index.ts
- Add 6 new test files: color, undo, snap, vector, style-runs, text-editor (98 new tests)
- Update renderer-effects test for renderer/ directory split
2026-03-06 19:33:10 +00:00
|
|
|
editor.moveLeft(true)
|
|
|
|
|
expect(editor.state?.selectionAnchor).toBe(5)
|
|
|
|
|
expect(editor.state?.cursor).toBe(4)
|
|
|
|
|
})
|
|
|
|
|
})
|