@sofereditor/react 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RefObject, JSX, ReactNode } from 'react';
2
- import { EditorDocument, EditorHistory, SerializedDocument, Selection, MarkName, MarkAttrs, BlockType, BlockAttrs, AlignValue, TableBorderPreset, ListKind, PageSettings, TableLocation, AnswerLineSpacing, TableRect, ImageEmbed, EmbedLoc, SerializedBlock, DeltaOp, Position } from '@sofereditor/core';
2
+ import { EditorDocument, EditorHistory, SerializedDocument, Selection, MarkName, MarkAttrs, BlockType, BlockAttrs, AlignValue, TableBorderPreset, ListKind, PageSettings, TableLocation, AnswerLineSpacing, TableRect, ImageEmbed, EmbedLoc, SerializedBlock, DeltaOp, Position, ClipboardSlice } from '@sofereditor/core';
3
3
 
4
4
  /**
5
5
  * Subconjunto mínimo da Awareness do y-protocols que o overlay usa. Tipar assim
@@ -184,6 +184,10 @@ interface UseEditorResult {
184
184
  setTableBorderPreset: (preset: TableBorderPreset) => void;
185
185
  /** Preset da tabela focada; "all" fora de tabela ou quando ausente. */
186
186
  getTableBorderPreset: () => TableBorderPreset;
187
+ /** Cor das linhas da grade da tabela focada. `null` restaura o padrão. No-op fora de tabela. */
188
+ setTableBorderColor: (color: string | null) => void;
189
+ /** Cor da tabela focada; undefined fora de tabela ou quando usa o padrão. */
190
+ getTableBorderColor: () => string | undefined;
187
191
  isListActive: (kind: ListKind) => boolean;
188
192
  toggleList: (kind: ListKind) => void;
189
193
  indentList: () => void;
@@ -436,4 +440,38 @@ declare function selectionsEqual(a: Selection, b: Selection): boolean;
436
440
  declare function isTableRectSelection(sel: Selection): boolean;
437
441
  declare function applyDomSelection(root: HTMLElement, modelSel: Selection): void;
438
442
 
439
- export { A4_PAGE, type BlockFragment, type CaptionAlign, Editor, type EditorProps, EditorProvider, type EditorProviderProps, ImageCaptionDialog, type ImageCaptionRequest, type ImageCaptionResult, LinkDialog, type LinkRequest, NodeView, type NodeViewFragment, PageConfigDialog, type PageConfigRequest, type PageEntry, type PageGeometry, type PageLayout, type PageLayoutResult, type PageRenderContext, type PageRenderProp, type PageSlot, type PaginationPhase, type PendingMarks, RemoteCursorsOverlay, type TableRowFragment, Toolbar, type ToolbarProps, type UseEditorOptions, type UseEditorResult, applyDomSelection, contentHeight, contentWidth, defaultPageLayout, deltaLength, findBlockIndex, getBlockElement, getCellElement, getFragmentForOffset, isTableRectSelection, locatePoint, readDomSelection, renderInline, selectionsEqual, sliceDelta, textOffsetWithin, useEditor, useEditorContext, usePageLayout, usePageSettings };
443
+ /**
444
+ * Converte o HTML do clipboard (Word / Google Docs / navegador) num
445
+ * `ClipboardSlice` que o editor já sabe inserir via `insertSlice`.
446
+ *
447
+ * Sempre bloco-inteiro: `openStart`/`openEnd` são `false` e `blockLevel` é
448
+ * `true` — o conteúdo colado de fora não é um fragmento de um dos blocos do
449
+ * editor, é uma sequência de blocos novos. `blockLevel: true` é o que diz a
450
+ * `insertSlice` (em `@sofereditor/core`) para adotar type/attrs do bloco
451
+ * colado em vez de tratá-lo como fragmento de seleção — ver o comentário em
452
+ * `ClipboardSlice.blockLevel`.
453
+ *
454
+ * Retorna `null` quando não sobra nada aproveitável, para o chamador (`Editor.tsx`)
455
+ * cair no ramo de texto puro em vez de engolir a colagem.
456
+ *
457
+ * Duas armadilhas reais que este módulo trata explicitamente (ver testes):
458
+ * - Google Docs embrulha o documento inteiro num `<b style="font-weight:normal"
459
+ * id="docs-internal-guid-...">` — uma tag inline por fora de blocos inteiros.
460
+ * `hasBlockDescendant` detecta isso e trata o wrapper como transparente
461
+ * (propaga as marcas resolvidas, mas não achata os blocos internos).
462
+ * - Word não usa `<ul>/<ol>/<li>` — usa `<p style="mso-list:l0 level1 ...">`
463
+ * com o marcador (número/símbolo) como texto literal dentro de um span
464
+ * `mso-list:Ignore`. `parseWordListLevel` + a exclusão desse span tratam isso.
465
+ *
466
+ * fontFamily é deliberadamente NUNCA emitida: a escola padroniza Arial e cada
467
+ * documento tem sua própria tipografia (mesma decisão de `import-docx`, que
468
+ * descarta `w:rFonts`). fontSize É preservado (ver `parseFontSizePt`): o
469
+ * modelo já suporta a mark, a barra já tem controle de tamanho, e descartar o
470
+ * tamanho perdia informação real (título de 37.5pt colado do Google Docs saía
471
+ * do tamanho do corpo). Unidades que dependem do contexto de herança do
472
+ * documento de origem (em/rem/%/larger/smaller/medium) não são resolvíveis
473
+ * aqui e por isso não emitem marca — sem tamanho é melhor que tamanho errado.
474
+ */
475
+ declare function htmlToSlice(html: string): ClipboardSlice | null;
476
+
477
+ export { A4_PAGE, type BlockFragment, type CaptionAlign, Editor, type EditorProps, EditorProvider, type EditorProviderProps, ImageCaptionDialog, type ImageCaptionRequest, type ImageCaptionResult, LinkDialog, type LinkRequest, NodeView, type NodeViewFragment, PageConfigDialog, type PageConfigRequest, type PageEntry, type PageGeometry, type PageLayout, type PageLayoutResult, type PageRenderContext, type PageRenderProp, type PageSlot, type PaginationPhase, type PendingMarks, RemoteCursorsOverlay, type TableRowFragment, Toolbar, type ToolbarProps, type UseEditorOptions, type UseEditorResult, applyDomSelection, contentHeight, contentWidth, defaultPageLayout, deltaLength, findBlockIndex, getBlockElement, getCellElement, getFragmentForOffset, htmlToSlice, isTableRectSelection, locatePoint, readDomSelection, renderInline, selectionsEqual, sliceDelta, textOffsetWithin, useEditor, useEditorContext, usePageLayout, usePageSettings };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RefObject, JSX, ReactNode } from 'react';
2
- import { EditorDocument, EditorHistory, SerializedDocument, Selection, MarkName, MarkAttrs, BlockType, BlockAttrs, AlignValue, TableBorderPreset, ListKind, PageSettings, TableLocation, AnswerLineSpacing, TableRect, ImageEmbed, EmbedLoc, SerializedBlock, DeltaOp, Position } from '@sofereditor/core';
2
+ import { EditorDocument, EditorHistory, SerializedDocument, Selection, MarkName, MarkAttrs, BlockType, BlockAttrs, AlignValue, TableBorderPreset, ListKind, PageSettings, TableLocation, AnswerLineSpacing, TableRect, ImageEmbed, EmbedLoc, SerializedBlock, DeltaOp, Position, ClipboardSlice } from '@sofereditor/core';
3
3
 
4
4
  /**
5
5
  * Subconjunto mínimo da Awareness do y-protocols que o overlay usa. Tipar assim
@@ -184,6 +184,10 @@ interface UseEditorResult {
184
184
  setTableBorderPreset: (preset: TableBorderPreset) => void;
185
185
  /** Preset da tabela focada; "all" fora de tabela ou quando ausente. */
186
186
  getTableBorderPreset: () => TableBorderPreset;
187
+ /** Cor das linhas da grade da tabela focada. `null` restaura o padrão. No-op fora de tabela. */
188
+ setTableBorderColor: (color: string | null) => void;
189
+ /** Cor da tabela focada; undefined fora de tabela ou quando usa o padrão. */
190
+ getTableBorderColor: () => string | undefined;
187
191
  isListActive: (kind: ListKind) => boolean;
188
192
  toggleList: (kind: ListKind) => void;
189
193
  indentList: () => void;
@@ -436,4 +440,38 @@ declare function selectionsEqual(a: Selection, b: Selection): boolean;
436
440
  declare function isTableRectSelection(sel: Selection): boolean;
437
441
  declare function applyDomSelection(root: HTMLElement, modelSel: Selection): void;
438
442
 
439
- export { A4_PAGE, type BlockFragment, type CaptionAlign, Editor, type EditorProps, EditorProvider, type EditorProviderProps, ImageCaptionDialog, type ImageCaptionRequest, type ImageCaptionResult, LinkDialog, type LinkRequest, NodeView, type NodeViewFragment, PageConfigDialog, type PageConfigRequest, type PageEntry, type PageGeometry, type PageLayout, type PageLayoutResult, type PageRenderContext, type PageRenderProp, type PageSlot, type PaginationPhase, type PendingMarks, RemoteCursorsOverlay, type TableRowFragment, Toolbar, type ToolbarProps, type UseEditorOptions, type UseEditorResult, applyDomSelection, contentHeight, contentWidth, defaultPageLayout, deltaLength, findBlockIndex, getBlockElement, getCellElement, getFragmentForOffset, isTableRectSelection, locatePoint, readDomSelection, renderInline, selectionsEqual, sliceDelta, textOffsetWithin, useEditor, useEditorContext, usePageLayout, usePageSettings };
443
+ /**
444
+ * Converte o HTML do clipboard (Word / Google Docs / navegador) num
445
+ * `ClipboardSlice` que o editor já sabe inserir via `insertSlice`.
446
+ *
447
+ * Sempre bloco-inteiro: `openStart`/`openEnd` são `false` e `blockLevel` é
448
+ * `true` — o conteúdo colado de fora não é um fragmento de um dos blocos do
449
+ * editor, é uma sequência de blocos novos. `blockLevel: true` é o que diz a
450
+ * `insertSlice` (em `@sofereditor/core`) para adotar type/attrs do bloco
451
+ * colado em vez de tratá-lo como fragmento de seleção — ver o comentário em
452
+ * `ClipboardSlice.blockLevel`.
453
+ *
454
+ * Retorna `null` quando não sobra nada aproveitável, para o chamador (`Editor.tsx`)
455
+ * cair no ramo de texto puro em vez de engolir a colagem.
456
+ *
457
+ * Duas armadilhas reais que este módulo trata explicitamente (ver testes):
458
+ * - Google Docs embrulha o documento inteiro num `<b style="font-weight:normal"
459
+ * id="docs-internal-guid-...">` — uma tag inline por fora de blocos inteiros.
460
+ * `hasBlockDescendant` detecta isso e trata o wrapper como transparente
461
+ * (propaga as marcas resolvidas, mas não achata os blocos internos).
462
+ * - Word não usa `<ul>/<ol>/<li>` — usa `<p style="mso-list:l0 level1 ...">`
463
+ * com o marcador (número/símbolo) como texto literal dentro de um span
464
+ * `mso-list:Ignore`. `parseWordListLevel` + a exclusão desse span tratam isso.
465
+ *
466
+ * fontFamily é deliberadamente NUNCA emitida: a escola padroniza Arial e cada
467
+ * documento tem sua própria tipografia (mesma decisão de `import-docx`, que
468
+ * descarta `w:rFonts`). fontSize É preservado (ver `parseFontSizePt`): o
469
+ * modelo já suporta a mark, a barra já tem controle de tamanho, e descartar o
470
+ * tamanho perdia informação real (título de 37.5pt colado do Google Docs saía
471
+ * do tamanho do corpo). Unidades que dependem do contexto de herança do
472
+ * documento de origem (em/rem/%/larger/smaller/medium) não são resolvíveis
473
+ * aqui e por isso não emitem marca — sem tamanho é melhor que tamanho errado.
474
+ */
475
+ declare function htmlToSlice(html: string): ClipboardSlice | null;
476
+
477
+ export { A4_PAGE, type BlockFragment, type CaptionAlign, Editor, type EditorProps, EditorProvider, type EditorProviderProps, ImageCaptionDialog, type ImageCaptionRequest, type ImageCaptionResult, LinkDialog, type LinkRequest, NodeView, type NodeViewFragment, PageConfigDialog, type PageConfigRequest, type PageEntry, type PageGeometry, type PageLayout, type PageLayoutResult, type PageRenderContext, type PageRenderProp, type PageSlot, type PaginationPhase, type PendingMarks, RemoteCursorsOverlay, type TableRowFragment, Toolbar, type ToolbarProps, type UseEditorOptions, type UseEditorResult, applyDomSelection, contentHeight, contentWidth, defaultPageLayout, deltaLength, findBlockIndex, getBlockElement, getCellElement, getFragmentForOffset, htmlToSlice, isTableRectSelection, locatePoint, readDomSelection, renderInline, selectionsEqual, sliceDelta, textOffsetWithin, useEditor, useEditorContext, usePageLayout, usePageSettings };