@graphysdk/react-renderer 1.9.0-beta.1795707432298 → 1.9.0-beta.1795708068076
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/ar-DRJfF3kx.cjs +1 -0
- package/dist/ar-DhjH4ZbY.js +883 -0
- package/dist/editable.cjs +1 -1
- package/dist/editable.d.ts +3 -2
- package/dist/editable.mjs +3552 -6165
- package/dist/en-gb-Bj-PFdWU.js +886 -0
- package/dist/en-gb-wV0MmZLj.cjs +1 -0
- package/dist/en-us-CNHaFu8A.js +11 -0
- package/dist/en-us-CfL-X7mL.cjs +1 -0
- package/dist/{history-chords-DsyzK0E1.js → history-chords-Buxa3waC.js} +92 -91
- package/dist/{history-chords-DaTCFopa.cjs → history-chords-DDZ_6FBc.cjs} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +152 -152
- package/dist/pt-pt-1KAFquYm.js +884 -0
- package/dist/pt-pt-Dl-e1WyP.cjs +1 -0
- package/dist/{rich-text-editor-module-Gwyekzd_.js → rich-text-editor-module-BjO3665Z.js} +8 -8
- package/dist/{rich-text-editor-module-E-39Qvp9.cjs → rich-text-editor-module-DiUIhnGd.cjs} +1 -1
- package/dist/{start-arrow-button-CqFgBJ0s.js → start-arrow-button-CGhJeFr2.js} +79 -79
- package/dist/{start-arrow-button-DlSXTrKp.cjs → start-arrow-button-DjGnXDVD.cjs} +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={save:"Guardar",cancel:"Cancelar",confirm:"Confirmar",delete:"Eliminar",confirmDelete:e=>`Tem a certeza que deseja eliminar ${e.item}?`,abbreviations:{thousands:"mil",millions:"M",billions:"MM"}},t={title:"Editor Graphy",description:"Edite o seu conteúdo aqui",graphTypes:{column:"Colunas",columnStacked:"Colunas sobrepostas",columnStackedFill:"100% Colunas sobrepostas",bar:"Barras",barStacked:"Barras sobrepostas",barStackedFill:"100% Barras sobrepostas",line:"Linha",area:"Área",areaStacked:"Área sobreposta",pie:"Circular",donut:"Donut",radialBar:"Barras radiais",radar:"Radar",radarFilled:"Radar preenchido",scatter:"Dispersão",bubble:"Bolhas",funnel:"Funil",combo:"Combinado",heatmap:"Mapa de Calor",waterfall:"Cascata",mekko:"Mekko",table:"Tabela"},sizePanel:{toolbarButton:"Tamanho",presetsSection:{title:"Predefinições"},customSizeSection:{title:"Tamanho personalizado"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"Publicação LinkedIn",instagram:"Publicação Instagram",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Móvel"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Gráfico",graphTypeSection:{title:"Tipo de gráfico"},mappingSection:{title:"Dados",x:"Eixo X",y:"Valor",color:"Cor",size:"Tamanho",label:"Etiqueta",none:"Nenhum"},comboSection:{title:"Aspeto do gráfico combinado",types:{groupedBars:"Barras agrupadas",stackedBars:"Barras empilhadas",lines:"Apenas linhas"}},polarSection:{title:"Polar",innerRadius:"Raio interno",startAngle:"Ângulo inicial"},barSection:{title:"Barras",thickness:"Espessura da barra",widths:{narrow:"Estreita",regular:"Normal",wide:"Larga"},baseRadius:"Base",tipRadius:"Ponta",radiusOptions:{none:"Reto",md:"Arredondado",full:"Redondo"}},graphOptionsSection:{title:"Opções do gráfico"},gridSection:{title:"Grelha",horizontalGridLines:"Linhas horizontais",verticalGridLines:"Linhas verticais",rings:"Anéis",spokes:"Raios",gridStyle:"Estilo da grelha",gridThickness:"Espessura da grelha",lineStyles:{solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},lineWidths:{thin:"Fina",medium:"Média",thick:"Espessa"}},graphOptions:{sortBars:"Ordenar maior → menor",showPoints:"Mostrar pontos",lineFill:"Preencher sob a linha",smoothLines:"Linhas suaves",curves:{smooth:"Suave",linear:"Reta"},stackTotals:"Totais sobrepostos",dataLabels:"Etiquetas de dados",labelPosition:"Posição das etiquetas",labelPositions:{auto:"Automático",inside:"Dentro",outside:"Fora"},showPercentages:"Mostrar percentagens",categoryLabels:"Etiquetas de categorias"},legendSection:{title:"Legenda",auto:"Automático",top:"Topo",bottom:"Fundo",left:"Esquerda",right:"Direita",none:"Nenhuma",alignLabel:"Alinhamento",align:{auto:"Automático",center:"Centro"},displayLabel:"Estilo",display:{auto:"Automático",pill:"Etiquetas",direct:"No gráfico"}},numberFormatSection:{title:"Formato numérico"},numberFormat:{abbreviationLabel:"Abreviação",valueLabel:"Valor",decimalPlacesLabel:"Casas decimais",options:{auto:"Automático",custom:"Personalizado",none:"Nenhum"}},headlineNumberSize:{sizeLabel:"Tamanho",valueLabel:"Valor",sizes:{small:"P",medium:"M",large:"G"}},lineThickness:{label:"Espessura da linha"},pointSize:{label:"Tamanho do ponto",options:{auto:"Automático",custom:"Personalizado"},sizes:{small:"Pequeno",medium:"Médio",large:"Grande"}},pointSymbol:{label:"Forma do ponto",symbols:{circle:"Círculo",square:"Quadrado",diamond:"Losango",triangle:"Triângulo",cross:"Cruz",star:"Estrela",wye:"Y"},custom:"Forma personalizada",oversized:"Esta imagem é demasiado grande. Escolha uma com menos de 512 KB.",undecodable:"Não foi possível ler este ficheiro como imagem."},headlineNumberSection:{title:"Número destaque",toggle:"Visível",metricLabel:"Métrica",compareWithLabel:"Comparar com",metrics:{total:"Total",average:"Média",current:"Último",conversion:"Conversão",left:"Esquerda"},comparison:{first:"Primeiro",previous:"Anterior"},position:{above:"Acima",center:"Centro"}},treatEmptyValues:{leaveGap:{label:"Deixar espaço no gráfico",description:"Deixa uma quebra visível na linha onde faltam dados"},fillZero:{label:"Preencher com zero",description:"Exibe pontos de dados em falta como zero"},connectGaps:{label:"Ligar através dos espaços",description:"Une a linha entre pontos disponíveis, ignorando o espaço"}}},axesPanel:{toolbarButton:"Eixos",mainAxisSection:{yAxis:"Eixo Y",xAxis:"Eixo X",ySecondaryAxis:"Segundo eixo Y"},crossAxisSection:{xAxis:"Eixo X",yAxis:"Eixo Y"},controls:{title:"Título",titlePlaceholder:"Adicionar título",visible:"Visível",ticks:"Marcas",labels:"Etiquetas",position:"Posição",scale:"Escala",startFrom:"Iniciar de",endAt:"Terminar em",value:"Valor",numberOfAxes:"Número de eixos"},labelMode:{auto:"Automático",edges:"Extremos"},scale:{auto:"Automático",log:"Logarítmico"},startFrom:{auto:"Automático",zero:"Zero",custom:"Personalizado"},endAt:{auto:"Automático",custom:"Personalizado"},axisCount:{single:"Único",double:"Duplo"},position:{left:"Esquerda",right:"Direita",top:"Topo",bottom:"Fundo"}},canvasColors:{canvasBlack:"Preto",canvasBlue:"Azul",canvasCyan:"Ciano",canvasGreen:"Verde",canvasYellow:"Amarelo",canvasOrange:"Laranja",canvasRed:"Vermelho",canvasPink:"Rosa",canvasPurple:"Roxo",canvasGray:"Cinzento",canvasWhite:"Branco",canvasDefault:"Predefinida",canvasInverse:"Inversa"},colorPanel:{toolbarButton:"Cor",themeSection:{title:"Tema"},appearanceSection:{title:"Aparência",highlightStyle:"Destaque"},backgroundSection:{title:"Fundo",black:"Preto",white:"Branco",gray:"Cinzento",tint:"Tonalidade",custom:"Personalizado",none:"Nenhum"},borderSection:{title:"Contorno",borderColor:"Cor do contorno",thickness:"Espessura",cornerRadius:"Raio dos cantos"},borderType:{solid:"Sólido",gradient:"Gradiente",gray:"Cinzento",preset:"Predefinido",custom:"Personalizado",none:"Nenhum"},presetGradients:{lilac:"Lilás",neonPink:"Rosa Néon",blackberry:"Amora",sun:"Sol",iceland:"Islândia",sunset:"Pôr do Sol",ultraviolet:"Ultravioleta",purple:"Roxo",iceCream:"Gelado",mint:"Menta",cool:"Frio",fresh:"Fresco"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Paleta"},annotatePanel:{toolbarButton:"Anotar",callOutSection:{title:"Destaques",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},highlightSection:{title:"Realce",button:"Realçar",colorLabel:"Cor do realce"}},annotationsPanel:{toolbarButton:"Anotar",freeformSection:{title:"Forma livre",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},goalSection:{title:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",valueAriaLabel:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:"(opcional)"},trendsAndAveragesSection:{title:"Tendências e Médias",trend:"Tendência",average:"Média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},averageLineSeries:{label:"Série da linha de média",placeholder:"Selecionar série",ariaLabel:"Dropdown de séries para linha de média"},highlightSection:{title:"Realce",button:"Realçar",fadeColorLabel:"Cor de esmaecimento"},titleAndSubtitleSection:{title:"Título e Subtítulo",toggleTitle:"Título",subtitle:"Subtítulo"},captionAndSourceSection:{title:"Legenda e Fonte",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"}},elementsPanel:{contentVisible:"Visível",contentValue:"Valor",toolbarButton:"Elementos",headerSection:{title:"Cabeçalho",toggleTitle:"Título",subtitle:"Subtítulo"},footerSection:{title:"Rodapé",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"},textSizeSection:{title:"Tamanho do texto",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Tipo de letra"},sourceSection:{title:"Fonte",url:"URL",name:"Nome"}},powerUpPanel:{toolbarButton:"Extras",goalSection:{title:"Objetivo",toggle:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:" (opcional)",xAxisReferenceAriaLabel:"Valor de referência do eixo X",anyXAxisValue:"Qualquer valor do eixo X",selectValuePlaceholder:"Selecionar valor"},trendSection:{title:"Tendência",toggle:"Tendência"},averageSection:{title:"Média",toggle:"Média",seriesLabel:"Série da linha de média",seriesPlaceholder:"Selecionar série",seriesAriaLabel:"Dropdown de séries para linha de média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentagem",numberPlaceholder:"Número",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Modo de realce",hover:"Passe",toHighlight:"para realçar",anyElement:"qualquer elemento",escToExit:"para sair",esc:"ESC"},emptyState:"Sem opções de realce disponíveis",deleteAriaLabel:"Eliminar realce",highlightStyle:{tint:"Tonalidade",gray:"Cinzento"}},fineTunePanel:{toolbarButton:"Ajuste fino",detailSection:{title:"Detalhe",missingValues:"Valores em falta"},lineStyleSection:{title:"Estilo de linha",lineCurve:"Curva da linha",sharp:"Angulosa",smooth:"Suave"}},customThemeEditor:{patternDropdownAriaLabel:"Dropdown de padrões para série",patterns:{solid:"Sólido",pattern:"Padrão",dotted:"Pontilhado",dashed:"Tracejado",hatched:"Hachurado"},heatmapColorLabel:"Cor"},overlayMenu:{observation:"Observação",group:"Grupo",band:"Banda",axis:"Eixo",legend:"Legenda",gridLines:"Linhas de grelha",chart:"Gráfico",selection:"Seleção",thisBar:"Esta barra",thisPoint:"Este ponto",thisBubble:"Esta bolha",thisSlice:"Esta fatia",allOf:e=>`Tudo em ${e.name}`,all:"Tudo",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Ocultar",show:"Mostrar",legendPlaces:{topStart:"Topo à esquerda",topCenter:"Topo ao centro",topEnd:"Topo à direita",left:"Esquerda",right:"Direita",bottomStart:"Fundo à esquerda",bottomCenter:"Fundo ao centro",bottomEnd:"Fundo à direita"},fillColor:"Cor de preenchimento",lowColor:"Cor dos valores baixos",highColor:"Cor dos valores altos",lineColor:"Cor da linha",palette:"Paleta",themePalette:"Tema",chartType:"Tipo",customChartType:"Personalizado",arrange:"Disposição",arrangements:{grouped:"Agrupado",stacked:"Sobreposto",filled:"100%",lines:"Apenas linhas"}},accessibility:{toggleSection:e=>`Alternar secção ${e.title}`,decrease:"Diminuir",increase:"Aumentar"},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},i={titleEditor:{titlePlaceholder:"Sem título",subtitlePlaceholder:"Adicionar subtítulo"},toolbar:{formatting:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",link:"Ligação"},link:{ariaLabel:"Criar ligação",placeholder:"Escreva ou cole uma ligação...",submit:"Submeter",urlLabel:"URL da ligação",apply:"Aplicar ligação"},font:{label:"Tipo de letra",ariaLabel:"Família do tipo de letra"},heading:{label:"Nível de título",ariaLabel:"Estilo de texto",text:"Texto",caption:"Legenda",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3"},textAlign:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},color:{label:"Cor do texto"}},colorDropdown:{colors:"Cores",chartColors:"Cores do gráfico",custom:"Personalizado",opacity:"Opacidade",transparent:"Transparente",automatic:"Automático",pickCustom:"Escolher cor personalizada",pickColor:"Escolher cor"},annotations:{differenceArrowToolbar:{label:"Opções da seta de diferença",labelKind:{ariaLabel:"Tipo de etiqueta",absoluteDifference:"Variação absoluta",relativeDifference:"Variação percentual",asPercent:"Diferença em %",asNumber:"Diferença como número",proportion:"Proporção",suspectValue:"Este valor divide por uma base igual a zero.",incomparableEnds:"As duas pontas medem quantidades diferentes, pelo que a diferença entre elas não tem significado."},color:"Cor da seta",size:{ariaLabel:"Tamanho da seta",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor de preenchimento",border:{ariaLabel:"Contorno",none:"Nenhum",thin:"Fino (2px)",medium:"Médio (8px)",thick:"Espesso (16px)"},remove:"Remover forma",resize:{"top-left":"Redimensionar a partir do canto superior esquerdo","top-right":"Redimensionar a partir do canto superior direito","bottom-right":"Redimensionar a partir do canto inferior direito","bottom-left":"Redimensionar a partir do canto inferior esquerdo"}},imageToolbar:{label:"Opções da imagem",remove:"Remover imagem"},attachment:{tether:"Afastar a anotação fixada do seu alvo"},stickerToolbar:{label:"Opções do autocolante",remove:"Remover autocolante",swap:"Trocar autocolante"},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura da seta",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Ponta inicial da seta",endArrowhead:"Ponta final da seta",arrowhead:{lineArrow:"Ponta de seta",none:"Nenhuma"},lineStyle:{ariaLabel:"Estilo da linha",solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},sticker:"Efeito autocolante",remove:"Remover seta",moveEndpoint:{start:"Mover o início da seta",end:"Mover o fim da seta"}},textToolbar:{label:"Opções do texto",background:"Cor de fundo",color:"Cor do texto",font:{ariaLabel:"Tipo de letra",modern:"Moderno",fresh:"Fresco",timeless:"Intemporal",technical:"Técnico",fineliner:"Caneta fina",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Tamanho da letra",small:"Pequeno",medium:"Médio",large:"Grande",extraLarge:"Muito grande",huge:"Enorme"},align:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},remove:"Remover texto",resize:{left:"Redimensionar a partir da esquerda",right:"Redimensionar a partir da direita"}},text:{editLabel:"Editar texto",placeholder:"Adicionar texto"},baseMenu:{pinNumber:"Fixar número",unpinNumber:"Desafixar número",annotate:"Anotar",addNote:"Adicionar nota",removeAnnotation:"Remover anotação",highlight:"Realçar",highlightWithLabel:e=>`Realçar ${e.label}`,removeHighlight:"Remover realce",differenceArrow:"Adicionar seta de diferença",addSticker:"Adicionar autocolante",removeSticker:"Remover autocolante",text:"Adicionar texto",stickyNote:"Adicionar nota adesiva",arrow:"Adicionar seta",arrowFromHere:"Desenhar seta a partir daqui",box:"Adicionar caixa",arrowOneWay:"Um sentido",arrowTwoWay:"Dois sentidos",arrowLine:"Linha"},textMenu:{title:"Anotar",placeholder:"Diga o que aconteceu…",addButton:"Adicionar"},highlights:{menuTitle:"Realçar",labels:{bar:"Barra",barGroup:"Grupo",barStack:"Pilha",barSeries:"Série",line:"Linha",linePoint:"Ponto",lineSeries:"Série",scatterPoint:"Ponto",scatterSeries:"Série",pieSlice:"Fatia",pointOrBar:"Ponto / barra",lineOrSeries:"Linha / série"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:a})=>`Realçar cada ${e} em ${a} ou mais`,onward:({label:e})=>`${e} em diante`,onwardDescription:({label:e})=>`Realçar ${e} e tudo a seguir`,justThis:({noun:e})=>`Realçar apenas esta ${e}`,justValue:({label:e})=>`Realçar apenas ${e}`,everyNamed:({name:e,noun:a})=>`Realçar cada ${e} ${a}`,everyIn:({noun:e,name:a})=>`Realçar cada ${e} em ${a}`,wholeGroup:"Realçar o grupo inteiro",wholeStack:"Realçar a pilha inteira",wholeSeries:"Realçar a série inteira",nouns:{bubble:"bolha"}},stickerMenu:{title:"Adicionar autocolante"},delete:"Eliminar",arrow:{thickness:{label:"Espessura",thin:"Fina",medium:"Média",thick:"Grossa"},arrowhead:{startPoint:"Ponto inicial",endPoint:"Ponto final",lineArrow:"Seta de linha",none:"Nenhuma"},lineStyle:{label:"Estilo de linha",solid:"Sólida",dotted:"Pontilhada"},stickerEffect:"Efeito de autocolante",toolbarAriaLabel:"Barra de ferramentas de seta livre",editorAriaLabel:"Editor de seta"},differenceArrow:{type:{proportion:"Proporção",difference:({absoluteDifference:e})=>`Diferença (${e})`,increase:({absoluteDifference:e})=>`Aumento (${e})`,decrease:({absoluteDifference:e})=>`Diminuição (${e})`,percentageChange:({percentageChange:e})=>`Variação percentual (${e})`,percentIncrease:({percentageChange:e})=>`Aumento percentual (${e})`,percentDecrease:({percentageChange:e})=>`Diminuição percentual (${e})`},size:{label:"Tamanho",small:"Pequeno",medium:"Médio",large:"Grande"},flipArrow:"Inverter seta",color:"Cor",toolbarAriaLabel:"Barra de ferramentas de seta de diferença",editorAriaLabel:"Editor de seta de diferença"},shape:{color:"Cor",border:{label:"Contorno",none:"Nenhum",thin:({value:e})=>`Fino (${e})`,medium:({value:e})=>`Médio (${e})`,thick:({value:e})=>`Grosso (${e})`}}}},r={common:o,editor:t,graph:i};exports.EDITOR_PT_PT=r;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bt as ve,
|
|
2
|
-
import { H as ft, _t as be, a as ht, b as mt, c as ye, d as g, f as m, h as gt, ht as K, i as vt, l as Tt, m as bt, mt as yt, o as B, ot as ke, p as kt, pt as St, r as xt, s as Se, t as At, u as Ct, w as Ft } from "./start-arrow-button-
|
|
1
|
+
import { Bt as ve, En as Qe, Er as et, Fr as tt, Ht as ee, J as P, Or as se, Qt as C, Rt as nt, Un as E, Vt as W, Z as rt, _ as ot, at, ct as ce, ft as it, h as lt, in as st, n as te, nt as ct, ot as dt, pt as G, st as ut, tt as pt, zn as Te } from "./history-chords-Buxa3waC.js";
|
|
2
|
+
import { H as ft, _t as be, a as ht, b as mt, c as ye, d as g, f as m, h as gt, ht as K, i as vt, l as Tt, m as bt, mt as yt, o as B, ot as ke, p as kt, pt as St, r as xt, s as Se, t as At, u as Ct, w as Ft } from "./start-arrow-button-CGhJeFr2.js";
|
|
3
3
|
import { AUTO_COLOR as de, SetContentCaptionCommand as Et, SetContentSubtitleCommand as Nt, SetContentTitleCommand as Pt, SetStyleRuleCommand as Lt, TEXT_ANNOTATION_FADE_ALPHA as Ot, UpdateAnnotationCommand as xe, alignUnitFractions as It, findStyleRule as Mt, readStyleCoord as zt, resolveTextAnnotationStyle as wt, toPaintColor as ue } from "@graphysdk/viz-engine";
|
|
4
4
|
import { useCallback as Dt, useEffect as A, useLayoutEffect as Ae, useMemo as z, useRef as U, useState as q } from "react";
|
|
5
5
|
import { Fragment as Ce, jsx as t, jsxs as p } from "react/jsx-runtime";
|
|
@@ -104,7 +104,7 @@ var Me = [
|
|
|
104
104
|
].map(({ id: e, key: n }) => ({
|
|
105
105
|
id: e,
|
|
106
106
|
key: n,
|
|
107
|
-
fontFamily:
|
|
107
|
+
fontFamily: nt[e] ?? e
|
|
108
108
|
})), nn = (e) => Me.find((n) => n.id === (e ?? "modern")) ?? null;
|
|
109
109
|
var ze = [
|
|
110
110
|
{
|
|
@@ -141,7 +141,7 @@ var ze = [
|
|
|
141
141
|
Icon: Oe
|
|
142
142
|
}
|
|
143
143
|
], kr = ({ annotation: e, textBox: n, panelRect: r, frameWidth: c, frameHeight: o, frameElement: l }) => {
|
|
144
|
-
const a = C(), { commands: s } =
|
|
144
|
+
const a = C(), { commands: s } = tt(), d = Ft(r), f = se((i) => i.spec.styles.overrides), k = se((i) => zt(i.spec)), h = G(), y = Ct(), u = mt(), T = wt(et(), e.id), F = Tt(e.content), S = it((i) => i.caret?.editor ?? null), L = w({
|
|
145
145
|
editor: S,
|
|
146
146
|
selector: () => ye(S)
|
|
147
147
|
}), D = w({
|
|
@@ -792,7 +792,7 @@ var ze = [
|
|
|
792
792
|
"aria-label": n
|
|
793
793
|
})]
|
|
794
794
|
}), Wn = 200, oe = ({ content: e, extensions: n, editable: r, onUpdate: c, updateDebounceMs: o = Wn }) => {
|
|
795
|
-
const l = U(me(e)), a = U(l.current), s =
|
|
795
|
+
const l = U(me(e)), a = U(l.current), s = st((f) => {
|
|
796
796
|
a.current = f, c?.(f);
|
|
797
797
|
}, o), d = $t({
|
|
798
798
|
extensions: n,
|
|
@@ -850,7 +850,7 @@ var ze = [
|
|
|
850
850
|
o !== null && De(o, c.getState().takePendingTextCaret("caption"));
|
|
851
851
|
}, [o, c]), /* @__PURE__ */ t("div", {
|
|
852
852
|
"data-testid": "caption-editor",
|
|
853
|
-
style:
|
|
853
|
+
style: Qe(n),
|
|
854
854
|
children: o === null ? /* @__PURE__ */ t(pt, { caption: e }) : /* @__PURE__ */ t(je, {
|
|
855
855
|
editor: o,
|
|
856
856
|
ariaLabel: "Chart caption"
|
|
@@ -946,7 +946,7 @@ var ze = [
|
|
|
946
946
|
extensions: a,
|
|
947
947
|
editable: !0,
|
|
948
948
|
onUpdate: (d) => {
|
|
949
|
-
const f =
|
|
949
|
+
const f = dt(d, n);
|
|
950
950
|
n && o(new Pt({ title: f.title })), r && o(new Nt({ subtitle: f.subtitle }));
|
|
951
951
|
}
|
|
952
952
|
});
|
|
@@ -955,7 +955,7 @@ var ze = [
|
|
|
955
955
|
}, [s, l]), /* @__PURE__ */ t("div", {
|
|
956
956
|
className: rt,
|
|
957
957
|
"data-testid": "title-editor",
|
|
958
|
-
children: s === null ? /* @__PURE__ */ t(
|
|
958
|
+
children: s === null ? /* @__PURE__ */ t(ct, {
|
|
959
959
|
title: e,
|
|
960
960
|
showTitle: n,
|
|
961
961
|
showSubtitle: r,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require('./rich-text-editor-module.css');const o=require("./history-chords-DaTCFopa.cjs"),a=require("./start-arrow-button-DlSXTrKp.cjs");let m=require("@graphysdk/viz-engine"),h=require("react"),t=require("react/jsx-runtime"),P=require("@floating-ui/react-dom"),N=require("@base-ui/react/tooltip"),L=require("@base-ui/react/popover"),T=require("@base-ui/react/menu"),H=require("@base-ui/react/toolbar"),_=require("@tiptap/react"),re=require("@tiptap/core"),Ae=require("@tiptap/extension-bold"),D=require("@tiptap/extension-document"),Ee=require("@tiptap/extension-hard-break"),Pe=require("@tiptap/extension-heading"),Ne=require("@tiptap/extension-italic"),Le=require("@tiptap/extension-link"),Me=require("@tiptap/extension-text"),Ie=require("@tiptap/extension-text-align"),w=require("@tiptap/extension-text-style"),Oe=require("@tiptap/extension-underline"),B=require("@tiptap/extensions"),oe=require("@tiptap/extension-paragraph"),ze=require("@base-ui/react/toggle");var ae=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M17 12H7"}),(0,t.jsx)("path",{d:"M19 19H5"})]})}),ie=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M21 12H9"}),(0,t.jsx)("path",{d:"M21 19H7"})]})}),le=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M15 12H3"}),(0,t.jsx)("path",{d:"M17 19H3"})]})}),De=({textColor:e,...n})=>(0,t.jsxs)(o.Icon,{...n,children:[(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,t.jsx)("path",{d:"M6 4h12"}),(0,t.jsx)("path",{d:"M12 4v12"})]}),(0,t.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var se=[{id:"modern",key:"graph.annotations.textToolbar.font.modern"},{id:"fresh",key:"graph.annotations.textToolbar.font.fresh"},{id:"timeless",key:"graph.annotations.textToolbar.font.timeless"},{id:"technical",key:"graph.annotations.textToolbar.font.technical"},{id:"fineliner",key:"graph.annotations.textToolbar.font.fineliner"},{id:"handwritten",key:"graph.annotations.textToolbar.font.handwritten"}].map(({id:e,key:n})=>({id:e,key:n,fontFamily:o.RICH_TEXT_FONT_FAMILIES[e]??e})),we=e=>se.find(n=>n.id===(e??"modern"))??null;var ce=[{size:12,key:"graph.annotations.textToolbar.fontSize.small"},{size:15,key:"graph.annotations.textToolbar.fontSize.medium"},{size:18,key:"graph.annotations.textToolbar.fontSize.large"},{size:24,key:"graph.annotations.textToolbar.fontSize.extraLarge"},{size:30,key:"graph.annotations.textToolbar.fontSize.huge"}],Re=e=>ce.find(n=>n.size===(e??15))??null,He=e=>`${e}px`,Be=[{alignment:"left",Icon:le},{alignment:"center",Icon:ae},{alignment:"right",Icon:ie}],qe=({annotation:e,textBox:n,panelRect:r,frameWidth:u,frameHeight:i,frameElement:c})=>{const l=o.useI18n(),{commands:d}=o.useGraphContext(),p=a.useRemoveAnnotation(r),x=o.useSceneSelector(s=>s.spec.styles.overrides),y=o.useSceneSelector(s=>(0,m.readStyleCoord)(s.spec)),g=o.useEditorStore(),j=a.useToolbarPopups(),f=a.usePlaceholderWidthFit(),v=(0,m.resolveTextAnnotationStyle)(o.useStyleReaderTree(),e.id),C=a.readTextAnnotationStyle(e.content),S=o.useEditorState(s=>s.caret?.editor??null),A=(0,_.useEditorState)({editor:S,selector:()=>a.readPickedFontSize(S)}),M=(0,_.useEditorState)({editor:S,selector:()=>a.readPickedFont(S)}),I=we(C.font??M),q=Re(C.fontSize??A),ve=o.useTextAnnotationTextColor(v),be=C.color??ve,V=(0,h.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),J=(s,b)=>{const k=(0,m.findStyleRule)(x,{select:V},y)?.declarations??{};d.dispatch(new m.SetStyleRuleCommand({list:"overrides",rule:{select:V,declarations:{...k,...s}}}),b)},U=(s,b)=>{d.dispatch(new m.UpdateAnnotationCommand({kind:"text",id:e.id,patch:s}),b)},E=()=>g.getState().caret?.editor?.getJSON()??e.content,W=(s,b)=>{const k=E(),z=g.getState().caret?.editor??null;if(z!==null&&!a.hasStyleableText(k)){z.chain().focus().setMark(a.TEXT_STYLE_MARK,s).run();return}U({content:a.applyTextStyle(k,s)},b)},je=()=>{p(e.id),c.focus({preventScroll:!0})},ye=s=>J(Ue(s),{transient:!0}),Se=s=>J({fillAlpha:s},{transient:!0}),O=v.fill!==a.TRANSPARENT_COLOR,ke=s=>W({color:s===m.AUTO_COLOR?void 0:s},{transient:!0}),_e=s=>()=>{a.hasStyleableText(E())||Y({font:s}),W({font:s}),j.close()},Ce=s=>()=>{a.hasStyleableText(E())||Y({fontSize:s}),W({fontSize:s}),j.close()},Y=s=>{const b=(n.x+(0,m.alignUnitFractions)(e.align).x*n.width)/r.width,k=f({annotationId:e.id,anchorX:b,align:e.align,panelWidth:r.width,minWidth:e.width,pickedFontSize:s.fontSize??A,pickedFont:s.font??M});k>e.width&&U({width:k})},Fe=s=>{const b=g.getState().caret?.editor??null;if(b===null||a.hasStyleableText(E())){U({content:a.applyTextAlignment(E(),s)});return}const k=b.state.storedMarks;b.chain().focus().setTextAlign(s).command(({tr:z})=>(z.setStoredMarks(k),!0)).run()};return(0,t.jsxs)(a.SelectionToolbar.Root,{anchorBox:n,panelRect:r,frameWidth:u,frameHeight:i,label:l("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,t.jsx)(a.SelectionToolbar.ColorPicker,{color:(0,m.toPaintColor)(v.fill),label:l("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:ye,opacity:O?v.fillAlpha:void 0,onOpacityChange:O?Se:void 0,...j.bind("background"),children:(0,t.jsx)(a.SelectionToolbar.Swatch,{color:O?(0,m.toPaintColor)(v.fill):a.TRANSPARENT_SWATCH_FILL,opacity:O?v.fillAlpha:void 0})}),(0,t.jsx)(a.SelectionToolbar.ColorPicker,{color:C.color??m.AUTO_COLOR,label:l("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:ke,...j.bind("color"),children:(0,t.jsx)(De,{size:"sm",textColor:be,title:""})}),(0,t.jsx)(a.SelectionToolbar.Dropdown,{label:l("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,t.jsx)("span",{style:{fontFamily:I?.fontFamily},children:"Aa"}),...j.bind("font"),children:se.map(s=>(0,t.jsx)(a.SelectionToolbar.MenuItem,{selected:s.id===I?.id,onClick:_e(s.id),children:(0,t.jsx)("span",{style:{fontFamily:s.fontFamily},children:l(s.key)})},s.id))}),(0,t.jsx)(a.SelectionToolbar.Dropdown,{label:l("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:q===null?"":l(q.key),...j.bind("fontSize"),children:ce.map(s=>(0,t.jsx)(a.SelectionToolbar.MenuItem,{selected:s.size===q?.size,onClick:Ce(s.size),children:(0,t.jsx)("span",{style:{fontSize:He(s.size)},children:l(s.key)})},s.size))}),(0,t.jsx)(a.SelectionToolbar.Separator,{}),(0,t.jsx)(We,{current:C.alignment??"center",onPick:Fe}),(0,t.jsx)(a.SelectionToolbar.Separator,{}),(0,t.jsx)(a.StartArrowButton,{annotationId:e.id}),(0,t.jsx)(a.SelectionToolbar.IconButton,{label:l("graph.annotations.textToolbar.remove"),onClick:je,children:(0,t.jsx)(a.TrashIcon,{size:"sm",title:""})})]})},Ue=e=>e==="transparent"?{fill:a.TRANSPARENT_COLOR}:{fill:e,fillAlpha:a.isCanvasColor(e)?m.TEXT_ANNOTATION_FADE_ALPHA:1},We=({current:e,onPick:n})=>{const r=o.useI18n(),u=i=>()=>n(i);return(0,t.jsx)(t.Fragment,{children:Be.map(i=>(0,t.jsx)(a.SelectionToolbar.ToggleButton,{label:r(`graph.annotations.textToolbar.align.${i.alignment}`),pressed:i.alignment===e,onClick:u(i.alignment),children:(0,t.jsx)(i.Icon,{size:"sm",title:""})},i.alignment))})},$e="data-variant",de=oe.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[$e]:e.variant}:{}}}}}),Ge=re.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:n}=e.state;if(!n.empty)return!1;const{$from:r}=n;return r.depth!==1||r.parentOffset!==0?!1:r.index(0)===1}}}}),K=()=>[Me.Text,B.UndoRedo,Pe.Heading.configure({levels:[1,2,3]}),Ae.Bold,Ne.Italic,Oe.Underline,Ie.TextAlign.configure({types:["heading","paragraph"]}),Le.Link.configure({openOnClick:!1,autolink:!0}),w.TextStyle,w.Color,Ee.HardBreak],Ke=({titlePlaceholder:e,subtitlePlaceholder:n,showTitle:r,showSubtitle:u})=>[Ve({showTitle:r,showSubtitle:u}),de,...K(),w.FontFamily,Ge.configure({showTitle:r}),B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:i,editor:c})=>{if(r&&i===0)return e;const l=r?c.state.doc.firstChild?.nodeSize??-1:0;return u&&i===l?n:""}})],Xe=({placeholder:e})=>[D.Document,de,...K(),w.FontFamily,B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],Ve=({showTitle:e,showSubtitle:n})=>e&&n?D.Document.extend({content:"block{2,}"}):D.Document,ue=(e,n)=>{if(n===null)return;let r=null;try{r=e.view.posAtCoords({left:n.x,top:n.y})}catch{r=null}e.commands.focus(r===null?"end":r.pos,{scrollIntoView:!1})},Je="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Ye=`'Aeonik', 'Aeonik Fallback', ${o.DEFAULT_FONT_FAMILY}`,Ze="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Qe="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",G=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:o.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Ye},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:Je},{id:"technical",label:"Technical",preview:"00",fontFamily:Ze},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Qe}],et=e=>e?G.find(n=>n.fontFamily===e)??null:null,pe="_70l3rt0",he="_70l3rt1",fe="_70l3rt3",xe="_70l3rt4",ge="_70l3rt5",tt=({editor:e,currentFontFamily:n,open:r,onOpenChange:u})=>{const i=o.useI18n(),c=et(n)??G[0],l=d=>{e.chain().focus().setFontFamily(d.fontFamily).run()};return(0,t.jsxs)(T.Menu.Root,{open:r,onOpenChange:u,children:[(0,t.jsxs)(T.Menu.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":i("graph.toolbar.font.ariaLabel"),className:pe,onMouseDown:d=>d.preventDefault(),children:[(0,t.jsx)("span",{className:he,style:{fontFamily:c?.fontFamily},children:c?.preview}),(0,t.jsx)(a.ChevronDownIcon,{size:"sm"})]}),(0,t.jsx)(T.Menu.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(T.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:fe,children:(0,t.jsx)(T.Menu.Popup,{className:xe,onMouseDown:d=>d.preventDefault(),children:G.map(d=>(0,t.jsx)(T.Menu.Item,{className:ge,"data-selected":d.id===c?.id,onClick:()=>l(d),children:(0,t.jsx)("span",{style:{fontFamily:d.fontFamily},children:d.label})},d.id))})})})})]})},me={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:o.vars.fontTextEditorBody},Z=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:o.vars.fontTextEditorH6},me,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:o.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:o.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:o.vars.fontTextEditorH1}],nt=({editor:e,activeStyle:n,open:r,onOpenChange:u})=>{const i=o.useI18n(),c=Z.find(l=>l.id===n)??me;return(0,t.jsxs)(T.Menu.Root,{open:r,onOpenChange:u,children:[(0,t.jsxs)(T.Menu.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":i("graph.toolbar.heading.ariaLabel"),className:pe,onMouseDown:l=>l.preventDefault(),children:[(0,t.jsx)("span",{className:he,children:i(c.translationKey)}),(0,t.jsx)(a.ChevronDownIcon,{size:"sm"})]}),(0,t.jsx)(T.Menu.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(T.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:fe,children:(0,t.jsx)(T.Menu.Popup,{className:xe,onMouseDown:l=>l.preventDefault(),children:Z.map(l=>(0,t.jsx)(T.Menu.Item,{className:ge,"data-selected":l.id===c.id,onClick:()=>rt(e,l.id),children:(0,t.jsx)(ot,{font:l.previewFont,children:i(l.translationKey)})},l.id))})})})})]})},rt=(e,n)=>{switch(n){case"caption":e.chain().focus().setNode("paragraph",{variant:"caption"}).run();return;case"text":e.chain().focus().setNode("paragraph",{variant:null}).run();return;case"h1":e.chain().focus().setHeading({level:1}).run();return;case"h2":e.chain().focus().setHeading({level:2}).run();return;case"h3":e.chain().focus().setHeading({level:3}).run()}},ot=({font:e,children:n})=>(0,t.jsx)("span",{style:{font:e,margin:0},children:n}),at=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,t.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),it=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M18 6 6 18"}),(0,t.jsx)("path",{d:"m6 6 12 12"})]})}),lt=e=>!e.content||e.content.length===0?!0:e.content.every(n=>!n.content||n.content.length===0),st=e=>{const{$from:n}=e.state.selection,r=n.parent.textContent,u=n.parentOffset,i=n.start();let c=u;for(;c>0&&Q(r[c-1]);)c-=1;let l=u;for(;l<r.length&&Q(r[l]);)l+=1;return{from:i+c,to:i+l}},Q=e=>e!==void 0&&/\S/.test(e),ct="fop13s0",dt="fop13s1",ut="fop13s2",pt="fop13s3",ee="fop13s4",ht=({editor:e,currentUrl:n,active:r,open:u,onOpenChange:i})=>{const c=o.useI18n(),[l,d]=(0,h.useState)(""),p=(0,h.useRef)(null);(0,h.useEffect)(()=>{u&&d(n??"")},[u,n]);const x=()=>{ft(e,l),i(!1)},y=()=>{d(""),i(!1)},g=f=>{d(f.target.value)},j=f=>{f.key==="Enter"&&(f.preventDefault(),x())};return(0,t.jsxs)(L.Popover.Root,{open:u,onOpenChange:i,children:[(0,t.jsx)(L.Popover.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":c("graph.toolbar.formatting.link"),"data-active":r,className:ct,onMouseDown:f=>f.preventDefault(),children:(0,t.jsx)(at,{})}),(0,t.jsx)(L.Popover.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(L.Popover.Positioner,{sideOffset:6,align:"end",className:dt,children:(0,t.jsxs)(L.Popover.Popup,{className:ut,initialFocus:p,onMouseDown:f=>f.preventDefault(),children:[(0,t.jsx)("input",{ref:p,type:"url",value:l,placeholder:c("graph.toolbar.link.placeholder"),"aria-label":c("graph.toolbar.link.urlLabel"),className:pt,onMouseDown:f=>f.stopPropagation(),onChange:g,onKeyDown:j}),(0,t.jsx)("button",{type:"button","aria-label":c("common.cancel"),className:ee,onClick:y,children:(0,t.jsx)(it,{})}),(0,t.jsx)("button",{type:"button","aria-label":c("graph.toolbar.link.apply"),className:ee,onClick:x,children:(0,t.jsx)(a.CheckIcon,{})})]})})})})]})},ft=(e,n)=>{const r=n.trim(),{selection:u}=e.state;if(!r){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!u.empty){e.chain().focus().setLink({href:r}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:r}).run();return}const i=st(e);e.chain().focus().setTextSelection(i).setLink({href:r}).run()},xt="_1d66w570",gt="_1d66w571",F=({label:e,active:n,onToggle:r,children:u})=>{const i=c=>c.preventDefault();return(0,t.jsxs)(N.Tooltip.Root,{children:[(0,t.jsx)(N.Tooltip.Trigger,{render:(0,t.jsx)(ze.Toggle,{render:(0,t.jsx)(H.Toolbar.Button,{}),pressed:n,onPressedChange:()=>r()}),"aria-label":e,className:xt,onMouseDown:i,children:u}),(0,t.jsx)(N.Tooltip.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(a.EditorPortalThemeProvider,{children:(0,t.jsx)(N.Tooltip.Positioner,{sideOffset:6,className:gt,children:(0,t.jsx)(N.Tooltip.Popup,{className:a.popup,children:e})})})})]})},mt=({editor:e,activeAlignment:n="left"})=>{const r=o.useI18n();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.left"),active:n==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,t.jsx)(le,{})}),(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.center"),active:n==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,t.jsx)(ae,{})}),(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.right"),active:n==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,t.jsx)(ie,{})})]})},Tt="_1u34vl40",vt=({editor:e})=>({bold:e?.isActive("bold")??!1,italic:e?.isActive("italic")??!1,underlined:e?.isActive("underline")??!1,linked:e?.isActive("link")??!1,linkUrl:e?.getAttributes("link").href??null,color:e?.getAttributes("textStyle").color??null,fontFamily:e?.getAttributes("textStyle").fontFamily??null,fontSize:bt(e),textAlign:jt(e)}),bt=e=>e?e.isActive("heading",{level:1})?"h1":e.isActive("heading",{level:2})?"h2":e.isActive("heading",{level:3})?"h3":e.isActive("paragraph",{variant:"caption"})?"caption":"text":"text",jt=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",yt=8,St=8,kt=({editor:e})=>{const n=o.useI18n(),[r,u]=(0,h.useState)(!1),[i,c]=(0,h.useState)(null),l=i!==null,d=f=>v=>{c(v?f:null)},{refs:p,floatingStyles:x}=(0,P.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,P.offset)(yt),(0,P.flip)(),(0,P.shift)({padding:St})],whileElementsMounted:P.autoUpdate}),y=(0,h.useRef)(null),g=(0,_.useEditorState)({editor:e,selector:vt}),j=(0,h.useCallback)(f=>{y.current=f,p.setFloating(f)},[p]);return(0,h.useEffect)(()=>{e&&p.setReference(e.view.dom)},[e,p]),(0,h.useEffect)(()=>{if(!e)return;const f=()=>u(!0),v=({event:C})=>{const{relatedTarget:S,currentTarget:A}=C,M=S instanceof Node&&y.current?.contains(S),I=S instanceof Node&&A instanceof Node&&A.contains(S);!M&&!I&&u(!1)};return e.on("focus",f),e.on("blur",v),()=>{e.off("focus",f),e.off("blur",v)}},[e]),!e||!r&&!l?null:(0,t.jsx)(a.FloatingToolbar.Portal,{children:(0,t.jsxs)(a.FloatingToolbar.Root,{ref:j,className:Tt,style:x,children:[(0,t.jsxs)(a.FloatingToolbar.Group,{children:[(0,t.jsx)(a.FloatingToolbar.ColorPicker,{color:g?.color??null,onChange:f=>e.chain().setColor(f).run(),open:i==="color",onOpenChange:d("color")}),(0,t.jsx)(tt,{editor:e,currentFontFamily:g?.fontFamily??null,open:i==="fontFamily",onOpenChange:d("fontFamily")})]}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(nt,{editor:e,activeStyle:g?.fontSize??"text",open:i==="fontSize",onOpenChange:d("fontSize")})}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsxs)(a.FloatingToolbar.Group,{children:[(0,t.jsx)(F,{label:n("graph.toolbar.formatting.bold"),active:g?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,t.jsx)("strong",{children:"B"})}),(0,t.jsx)(F,{label:n("graph.toolbar.formatting.italic"),active:g?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,t.jsx)("em",{children:"I"})}),(0,t.jsx)(F,{label:n("graph.toolbar.formatting.underline"),active:g?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,t.jsx)("u",{children:"U"})})]}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(mt,{editor:e,activeAlignment:g?.textAlign})}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(ht,{editor:e,currentUrl:g?.linkUrl??null,active:g?.linked??!1,open:i==="link",onOpenChange:d("link")})})]})})},_t="_1uy50v30",Te=({editor:e,ariaLabel:n})=>(0,t.jsxs)("div",{className:_t,children:[(0,t.jsx)(kt,{editor:e}),(0,t.jsx)(_.EditorContent,{editor:e,"aria-label":n})]}),Ct=200,X=({content:e,extensions:n,editable:r,onUpdate:u,updateDebounceMs:i=Ct})=>{const c=(0,h.useRef)(te(e)),l=(0,h.useRef)(c.current),d=o.useDebouncedCallback(x=>{l.current=x,u?.(x)},i),p=(0,_.useEditor)({extensions:n,content:c.current,editable:r,immediatelyRender:!1,onUpdate:({editor:x})=>{const y=x.getJSON();if($(l.current,y))return d.cancel();d.run(y)}});return(0,h.useEffect)(()=>{p?.setEditable(r)},[p,r]),(0,h.useEffect)(()=>{if(!p)return;const x=te(e);$(l.current,x)||(l.current=x,!$(p.getJSON(),x)&&(d.cancel(),Ft(p,x)))},[p,e,d]),(0,h.useEffect)(()=>()=>d.flush(),[d]),p},te=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,Ft=(e,n)=>{const{from:r,to:u}=e.state.selection;e.commands.setContent(n,{emitUpdate:!1});const i=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(r,i),to:Math.min(u,i)})},$=(e,n)=>JSON.stringify(R(e))===JSON.stringify(R(n)),R=e=>Array.isArray(e)?e.map(R):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([n,r])=>[n,R(r)]).filter(([,n])=>!At(n)).sort(([n],[r])=>String(n).localeCompare(String(r)))),At=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,Et=({caption:e,captionStyle:n})=>{const{dispatch:r}=o.useGraphCommands(),u=o.useEditorStore(),i=X({content:e,extensions:(0,h.useMemo)(()=>Xe({placeholder:o.CAPTION_PLACEHOLDER}),[]),editable:!0,onUpdate:c=>{const l=lt(c)?null:c;r(new m.SetContentCaptionCommand({caption:l}))}});return(0,h.useLayoutEffect)(()=>{i!==null&&ue(i,u.getState().takePendingTextCaret("caption"))},[i,u]),(0,t.jsx)("div",{"data-testid":"caption-editor",style:o.toHtmlTextCss(n),children:i===null?(0,t.jsx)(o.CaptionTextSurface,{caption:e}):(0,t.jsx)(Te,{editor:i,ariaLabel:"Chart caption"})})},Pt=e=>[D.Document,oe.Paragraph,...K(),Lt,B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],Nt=({annotation:e})=>{const n=o.useI18n(),{dispatch:r}=o.useGraphCommands(),u=o.useEditorStore(),i=(0,h.useMemo)(()=>Pt(n("graph.annotations.text.placeholder")),[n]),c=X({content:e.content,extensions:i,editable:!0,onUpdate:p=>{r(new m.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:p}}))}});(0,h.useEffect)(()=>{const{setCaretEditor:p}=u.getState();return p(c),()=>p(null)},[c,u]),(0,h.useEffect)(()=>{c?.commands.focus("end",{scrollIntoView:!1})},[c]);const l=(0,_.useEditorState)({editor:c,selector:({editor:p})=>a.readPickedFontSize(p)}),d=(0,_.useEditorState)({editor:c,selector:({editor:p})=>a.readPickedFont(p)});return(0,t.jsx)(_.EditorContent,{"aria-label":n("graph.annotations.text.editLabel"),className:o.editor,editor:c,style:{...l===null?{}:{fontSize:`calc(${l}px * ${o.vars.textScale})`},...d===null?{}:{fontFamily:o.resolveRichTextFontFamily(d)}},"data-testid":"text-annotation-editor"})},ne=e=>{const n=o.resolveRichTextFontFamily(e);return n===void 0?{}:{style:`font-family: ${n}`}},Lt=re.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>ne(e.fontFamily)},font:{default:null,renderHTML:e=>ne(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${o.vars.textScale})`}:{}}}}]}}),Mt=({title:e,showTitle:n,showSubtitle:r,subtitle:u})=>{const{dispatch:i}=o.useGraphCommands(),c=o.useEditorStore(),l=(0,h.useMemo)(()=>Ke({titlePlaceholder:o.TITLE_PLACEHOLDER,subtitlePlaceholder:o.TITLE_PLACEHOLDER,showTitle:n,showSubtitle:r}),[n,r]),d=X({content:(0,h.useMemo)(()=>o.buildTitleEditorDoc({title:e,showTitle:n,subtitle:u,showSubtitle:r}),[e,n,u,r]),extensions:l,editable:!0,onUpdate:p=>{const x=o.splitTitleEditorDoc(p,n);n&&i(new m.SetContentTitleCommand({title:x.title})),r&&i(new m.SetContentSubtitleCommand({subtitle:x.subtitle}))}});return(0,h.useLayoutEffect)(()=>{d!==null&&ue(d,c.getState().takePendingTextCaret("header"))},[d,c]),(0,t.jsx)("div",{className:o.textStyleEditor,"data-testid":"title-editor",children:d===null?(0,t.jsx)(o.HeaderTextSurface,{title:e,showTitle:n,showSubtitle:r,subtitle:u}):(0,t.jsx)(Te,{editor:d,ariaLabel:"Chart title and subtitle"})})};exports.CaptionEditor=Et;exports.TextAnnotationEditor=Nt;exports.TextToolbar=qe;exports.TitleEditor=Mt;
|
|
1
|
+
require('./rich-text-editor-module.css');const o=require("./history-chords-DDZ_6FBc.cjs"),a=require("./start-arrow-button-DjGnXDVD.cjs");let m=require("@graphysdk/viz-engine"),h=require("react"),t=require("react/jsx-runtime"),P=require("@floating-ui/react-dom"),N=require("@base-ui/react/tooltip"),L=require("@base-ui/react/popover"),T=require("@base-ui/react/menu"),H=require("@base-ui/react/toolbar"),_=require("@tiptap/react"),re=require("@tiptap/core"),Ae=require("@tiptap/extension-bold"),D=require("@tiptap/extension-document"),Ee=require("@tiptap/extension-hard-break"),Pe=require("@tiptap/extension-heading"),Ne=require("@tiptap/extension-italic"),Le=require("@tiptap/extension-link"),Me=require("@tiptap/extension-text"),Ie=require("@tiptap/extension-text-align"),w=require("@tiptap/extension-text-style"),Oe=require("@tiptap/extension-underline"),B=require("@tiptap/extensions"),oe=require("@tiptap/extension-paragraph"),ze=require("@base-ui/react/toggle");var ae=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M17 12H7"}),(0,t.jsx)("path",{d:"M19 19H5"})]})}),ie=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M21 12H9"}),(0,t.jsx)("path",{d:"M21 19H7"})]})}),le=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M15 12H3"}),(0,t.jsx)("path",{d:"M17 19H3"})]})}),De=({textColor:e,...n})=>(0,t.jsxs)(o.Icon,{...n,children:[(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,t.jsx)("path",{d:"M6 4h12"}),(0,t.jsx)("path",{d:"M12 4v12"})]}),(0,t.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var se=[{id:"modern",key:"graph.annotations.textToolbar.font.modern"},{id:"fresh",key:"graph.annotations.textToolbar.font.fresh"},{id:"timeless",key:"graph.annotations.textToolbar.font.timeless"},{id:"technical",key:"graph.annotations.textToolbar.font.technical"},{id:"fineliner",key:"graph.annotations.textToolbar.font.fineliner"},{id:"handwritten",key:"graph.annotations.textToolbar.font.handwritten"}].map(({id:e,key:n})=>({id:e,key:n,fontFamily:o.RICH_TEXT_FONT_FAMILIES[e]??e})),we=e=>se.find(n=>n.id===(e??"modern"))??null;var ce=[{size:12,key:"graph.annotations.textToolbar.fontSize.small"},{size:15,key:"graph.annotations.textToolbar.fontSize.medium"},{size:18,key:"graph.annotations.textToolbar.fontSize.large"},{size:24,key:"graph.annotations.textToolbar.fontSize.extraLarge"},{size:30,key:"graph.annotations.textToolbar.fontSize.huge"}],Re=e=>ce.find(n=>n.size===(e??15))??null,He=e=>`${e}px`,Be=[{alignment:"left",Icon:le},{alignment:"center",Icon:ae},{alignment:"right",Icon:ie}],qe=({annotation:e,textBox:n,panelRect:r,frameWidth:u,frameHeight:i,frameElement:c})=>{const l=o.useI18n(),{commands:d}=o.useGraphContext(),p=a.useRemoveAnnotation(r),x=o.useSceneSelector(s=>s.spec.styles.overrides),y=o.useSceneSelector(s=>(0,m.readStyleCoord)(s.spec)),g=o.useEditorStore(),j=a.useToolbarPopups(),f=a.usePlaceholderWidthFit(),v=(0,m.resolveTextAnnotationStyle)(o.useStyleReaderTree(),e.id),C=a.readTextAnnotationStyle(e.content),S=o.useEditorState(s=>s.caret?.editor??null),A=(0,_.useEditorState)({editor:S,selector:()=>a.readPickedFontSize(S)}),M=(0,_.useEditorState)({editor:S,selector:()=>a.readPickedFont(S)}),I=we(C.font??M),q=Re(C.fontSize??A),ve=o.useTextAnnotationTextColor(v),be=C.color??ve,V=(0,h.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),J=(s,b)=>{const k=(0,m.findStyleRule)(x,{select:V},y)?.declarations??{};d.dispatch(new m.SetStyleRuleCommand({list:"overrides",rule:{select:V,declarations:{...k,...s}}}),b)},U=(s,b)=>{d.dispatch(new m.UpdateAnnotationCommand({kind:"text",id:e.id,patch:s}),b)},E=()=>g.getState().caret?.editor?.getJSON()??e.content,W=(s,b)=>{const k=E(),z=g.getState().caret?.editor??null;if(z!==null&&!a.hasStyleableText(k)){z.chain().focus().setMark(a.TEXT_STYLE_MARK,s).run();return}U({content:a.applyTextStyle(k,s)},b)},je=()=>{p(e.id),c.focus({preventScroll:!0})},ye=s=>J(Ue(s),{transient:!0}),Se=s=>J({fillAlpha:s},{transient:!0}),O=v.fill!==a.TRANSPARENT_COLOR,ke=s=>W({color:s===m.AUTO_COLOR?void 0:s},{transient:!0}),_e=s=>()=>{a.hasStyleableText(E())||Y({font:s}),W({font:s}),j.close()},Ce=s=>()=>{a.hasStyleableText(E())||Y({fontSize:s}),W({fontSize:s}),j.close()},Y=s=>{const b=(n.x+(0,m.alignUnitFractions)(e.align).x*n.width)/r.width,k=f({annotationId:e.id,anchorX:b,align:e.align,panelWidth:r.width,minWidth:e.width,pickedFontSize:s.fontSize??A,pickedFont:s.font??M});k>e.width&&U({width:k})},Fe=s=>{const b=g.getState().caret?.editor??null;if(b===null||a.hasStyleableText(E())){U({content:a.applyTextAlignment(E(),s)});return}const k=b.state.storedMarks;b.chain().focus().setTextAlign(s).command(({tr:z})=>(z.setStoredMarks(k),!0)).run()};return(0,t.jsxs)(a.SelectionToolbar.Root,{anchorBox:n,panelRect:r,frameWidth:u,frameHeight:i,label:l("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,t.jsx)(a.SelectionToolbar.ColorPicker,{color:(0,m.toPaintColor)(v.fill),label:l("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:ye,opacity:O?v.fillAlpha:void 0,onOpacityChange:O?Se:void 0,...j.bind("background"),children:(0,t.jsx)(a.SelectionToolbar.Swatch,{color:O?(0,m.toPaintColor)(v.fill):a.TRANSPARENT_SWATCH_FILL,opacity:O?v.fillAlpha:void 0})}),(0,t.jsx)(a.SelectionToolbar.ColorPicker,{color:C.color??m.AUTO_COLOR,label:l("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:ke,...j.bind("color"),children:(0,t.jsx)(De,{size:"sm",textColor:be,title:""})}),(0,t.jsx)(a.SelectionToolbar.Dropdown,{label:l("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,t.jsx)("span",{style:{fontFamily:I?.fontFamily},children:"Aa"}),...j.bind("font"),children:se.map(s=>(0,t.jsx)(a.SelectionToolbar.MenuItem,{selected:s.id===I?.id,onClick:_e(s.id),children:(0,t.jsx)("span",{style:{fontFamily:s.fontFamily},children:l(s.key)})},s.id))}),(0,t.jsx)(a.SelectionToolbar.Dropdown,{label:l("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:q===null?"":l(q.key),...j.bind("fontSize"),children:ce.map(s=>(0,t.jsx)(a.SelectionToolbar.MenuItem,{selected:s.size===q?.size,onClick:Ce(s.size),children:(0,t.jsx)("span",{style:{fontSize:He(s.size)},children:l(s.key)})},s.size))}),(0,t.jsx)(a.SelectionToolbar.Separator,{}),(0,t.jsx)(We,{current:C.alignment??"center",onPick:Fe}),(0,t.jsx)(a.SelectionToolbar.Separator,{}),(0,t.jsx)(a.StartArrowButton,{annotationId:e.id}),(0,t.jsx)(a.SelectionToolbar.IconButton,{label:l("graph.annotations.textToolbar.remove"),onClick:je,children:(0,t.jsx)(a.TrashIcon,{size:"sm",title:""})})]})},Ue=e=>e==="transparent"?{fill:a.TRANSPARENT_COLOR}:{fill:e,fillAlpha:a.isCanvasColor(e)?m.TEXT_ANNOTATION_FADE_ALPHA:1},We=({current:e,onPick:n})=>{const r=o.useI18n(),u=i=>()=>n(i);return(0,t.jsx)(t.Fragment,{children:Be.map(i=>(0,t.jsx)(a.SelectionToolbar.ToggleButton,{label:r(`graph.annotations.textToolbar.align.${i.alignment}`),pressed:i.alignment===e,onClick:u(i.alignment),children:(0,t.jsx)(i.Icon,{size:"sm",title:""})},i.alignment))})},$e="data-variant",de=oe.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[$e]:e.variant}:{}}}}}),Ge=re.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:n}=e.state;if(!n.empty)return!1;const{$from:r}=n;return r.depth!==1||r.parentOffset!==0?!1:r.index(0)===1}}}}),K=()=>[Me.Text,B.UndoRedo,Pe.Heading.configure({levels:[1,2,3]}),Ae.Bold,Ne.Italic,Oe.Underline,Ie.TextAlign.configure({types:["heading","paragraph"]}),Le.Link.configure({openOnClick:!1,autolink:!0}),w.TextStyle,w.Color,Ee.HardBreak],Ke=({titlePlaceholder:e,subtitlePlaceholder:n,showTitle:r,showSubtitle:u})=>[Ve({showTitle:r,showSubtitle:u}),de,...K(),w.FontFamily,Ge.configure({showTitle:r}),B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:i,editor:c})=>{if(r&&i===0)return e;const l=r?c.state.doc.firstChild?.nodeSize??-1:0;return u&&i===l?n:""}})],Xe=({placeholder:e})=>[D.Document,de,...K(),w.FontFamily,B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],Ve=({showTitle:e,showSubtitle:n})=>e&&n?D.Document.extend({content:"block{2,}"}):D.Document,ue=(e,n)=>{if(n===null)return;let r=null;try{r=e.view.posAtCoords({left:n.x,top:n.y})}catch{r=null}e.commands.focus(r===null?"end":r.pos,{scrollIntoView:!1})},Je="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Ye=`'Aeonik', 'Aeonik Fallback', ${o.DEFAULT_FONT_FAMILY}`,Ze="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Qe="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",G=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:o.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Ye},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:Je},{id:"technical",label:"Technical",preview:"00",fontFamily:Ze},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Qe}],et=e=>e?G.find(n=>n.fontFamily===e)??null:null,pe="_70l3rt0",he="_70l3rt1",fe="_70l3rt3",xe="_70l3rt4",ge="_70l3rt5",tt=({editor:e,currentFontFamily:n,open:r,onOpenChange:u})=>{const i=o.useI18n(),c=et(n)??G[0],l=d=>{e.chain().focus().setFontFamily(d.fontFamily).run()};return(0,t.jsxs)(T.Menu.Root,{open:r,onOpenChange:u,children:[(0,t.jsxs)(T.Menu.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":i("graph.toolbar.font.ariaLabel"),className:pe,onMouseDown:d=>d.preventDefault(),children:[(0,t.jsx)("span",{className:he,style:{fontFamily:c?.fontFamily},children:c?.preview}),(0,t.jsx)(a.ChevronDownIcon,{size:"sm"})]}),(0,t.jsx)(T.Menu.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(T.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:fe,children:(0,t.jsx)(T.Menu.Popup,{className:xe,onMouseDown:d=>d.preventDefault(),children:G.map(d=>(0,t.jsx)(T.Menu.Item,{className:ge,"data-selected":d.id===c?.id,onClick:()=>l(d),children:(0,t.jsx)("span",{style:{fontFamily:d.fontFamily},children:d.label})},d.id))})})})})]})},me={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:o.vars.fontTextEditorBody},Z=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:o.vars.fontTextEditorH6},me,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:o.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:o.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:o.vars.fontTextEditorH1}],nt=({editor:e,activeStyle:n,open:r,onOpenChange:u})=>{const i=o.useI18n(),c=Z.find(l=>l.id===n)??me;return(0,t.jsxs)(T.Menu.Root,{open:r,onOpenChange:u,children:[(0,t.jsxs)(T.Menu.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":i("graph.toolbar.heading.ariaLabel"),className:pe,onMouseDown:l=>l.preventDefault(),children:[(0,t.jsx)("span",{className:he,children:i(c.translationKey)}),(0,t.jsx)(a.ChevronDownIcon,{size:"sm"})]}),(0,t.jsx)(T.Menu.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(T.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:fe,children:(0,t.jsx)(T.Menu.Popup,{className:xe,onMouseDown:l=>l.preventDefault(),children:Z.map(l=>(0,t.jsx)(T.Menu.Item,{className:ge,"data-selected":l.id===c.id,onClick:()=>rt(e,l.id),children:(0,t.jsx)(ot,{font:l.previewFont,children:i(l.translationKey)})},l.id))})})})})]})},rt=(e,n)=>{switch(n){case"caption":e.chain().focus().setNode("paragraph",{variant:"caption"}).run();return;case"text":e.chain().focus().setNode("paragraph",{variant:null}).run();return;case"h1":e.chain().focus().setHeading({level:1}).run();return;case"h2":e.chain().focus().setHeading({level:2}).run();return;case"h3":e.chain().focus().setHeading({level:3}).run()}},ot=({font:e,children:n})=>(0,t.jsx)("span",{style:{font:e,margin:0},children:n}),at=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,t.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),it=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M18 6 6 18"}),(0,t.jsx)("path",{d:"m6 6 12 12"})]})}),lt=e=>!e.content||e.content.length===0?!0:e.content.every(n=>!n.content||n.content.length===0),st=e=>{const{$from:n}=e.state.selection,r=n.parent.textContent,u=n.parentOffset,i=n.start();let c=u;for(;c>0&&Q(r[c-1]);)c-=1;let l=u;for(;l<r.length&&Q(r[l]);)l+=1;return{from:i+c,to:i+l}},Q=e=>e!==void 0&&/\S/.test(e),ct="fop13s0",dt="fop13s1",ut="fop13s2",pt="fop13s3",ee="fop13s4",ht=({editor:e,currentUrl:n,active:r,open:u,onOpenChange:i})=>{const c=o.useI18n(),[l,d]=(0,h.useState)(""),p=(0,h.useRef)(null);(0,h.useEffect)(()=>{u&&d(n??"")},[u,n]);const x=()=>{ft(e,l),i(!1)},y=()=>{d(""),i(!1)},g=f=>{d(f.target.value)},j=f=>{f.key==="Enter"&&(f.preventDefault(),x())};return(0,t.jsxs)(L.Popover.Root,{open:u,onOpenChange:i,children:[(0,t.jsx)(L.Popover.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":c("graph.toolbar.formatting.link"),"data-active":r,className:ct,onMouseDown:f=>f.preventDefault(),children:(0,t.jsx)(at,{})}),(0,t.jsx)(L.Popover.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(L.Popover.Positioner,{sideOffset:6,align:"end",className:dt,children:(0,t.jsxs)(L.Popover.Popup,{className:ut,initialFocus:p,onMouseDown:f=>f.preventDefault(),children:[(0,t.jsx)("input",{ref:p,type:"url",value:l,placeholder:c("graph.toolbar.link.placeholder"),"aria-label":c("graph.toolbar.link.urlLabel"),className:pt,onMouseDown:f=>f.stopPropagation(),onChange:g,onKeyDown:j}),(0,t.jsx)("button",{type:"button","aria-label":c("common.cancel"),className:ee,onClick:y,children:(0,t.jsx)(it,{})}),(0,t.jsx)("button",{type:"button","aria-label":c("graph.toolbar.link.apply"),className:ee,onClick:x,children:(0,t.jsx)(a.CheckIcon,{})})]})})})})]})},ft=(e,n)=>{const r=n.trim(),{selection:u}=e.state;if(!r){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!u.empty){e.chain().focus().setLink({href:r}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:r}).run();return}const i=st(e);e.chain().focus().setTextSelection(i).setLink({href:r}).run()},xt="_1d66w570",gt="_1d66w571",F=({label:e,active:n,onToggle:r,children:u})=>{const i=c=>c.preventDefault();return(0,t.jsxs)(N.Tooltip.Root,{children:[(0,t.jsx)(N.Tooltip.Trigger,{render:(0,t.jsx)(ze.Toggle,{render:(0,t.jsx)(H.Toolbar.Button,{}),pressed:n,onPressedChange:()=>r()}),"aria-label":e,className:xt,onMouseDown:i,children:u}),(0,t.jsx)(N.Tooltip.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(a.EditorPortalThemeProvider,{children:(0,t.jsx)(N.Tooltip.Positioner,{sideOffset:6,className:gt,children:(0,t.jsx)(N.Tooltip.Popup,{className:a.popup,children:e})})})})]})},mt=({editor:e,activeAlignment:n="left"})=>{const r=o.useI18n();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.left"),active:n==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,t.jsx)(le,{})}),(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.center"),active:n==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,t.jsx)(ae,{})}),(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.right"),active:n==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,t.jsx)(ie,{})})]})},Tt="_1u34vl40",vt=({editor:e})=>({bold:e?.isActive("bold")??!1,italic:e?.isActive("italic")??!1,underlined:e?.isActive("underline")??!1,linked:e?.isActive("link")??!1,linkUrl:e?.getAttributes("link").href??null,color:e?.getAttributes("textStyle").color??null,fontFamily:e?.getAttributes("textStyle").fontFamily??null,fontSize:bt(e),textAlign:jt(e)}),bt=e=>e?e.isActive("heading",{level:1})?"h1":e.isActive("heading",{level:2})?"h2":e.isActive("heading",{level:3})?"h3":e.isActive("paragraph",{variant:"caption"})?"caption":"text":"text",jt=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",yt=8,St=8,kt=({editor:e})=>{const n=o.useI18n(),[r,u]=(0,h.useState)(!1),[i,c]=(0,h.useState)(null),l=i!==null,d=f=>v=>{c(v?f:null)},{refs:p,floatingStyles:x}=(0,P.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,P.offset)(yt),(0,P.flip)(),(0,P.shift)({padding:St})],whileElementsMounted:P.autoUpdate}),y=(0,h.useRef)(null),g=(0,_.useEditorState)({editor:e,selector:vt}),j=(0,h.useCallback)(f=>{y.current=f,p.setFloating(f)},[p]);return(0,h.useEffect)(()=>{e&&p.setReference(e.view.dom)},[e,p]),(0,h.useEffect)(()=>{if(!e)return;const f=()=>u(!0),v=({event:C})=>{const{relatedTarget:S,currentTarget:A}=C,M=S instanceof Node&&y.current?.contains(S),I=S instanceof Node&&A instanceof Node&&A.contains(S);!M&&!I&&u(!1)};return e.on("focus",f),e.on("blur",v),()=>{e.off("focus",f),e.off("blur",v)}},[e]),!e||!r&&!l?null:(0,t.jsx)(a.FloatingToolbar.Portal,{children:(0,t.jsxs)(a.FloatingToolbar.Root,{ref:j,className:Tt,style:x,children:[(0,t.jsxs)(a.FloatingToolbar.Group,{children:[(0,t.jsx)(a.FloatingToolbar.ColorPicker,{color:g?.color??null,onChange:f=>e.chain().setColor(f).run(),open:i==="color",onOpenChange:d("color")}),(0,t.jsx)(tt,{editor:e,currentFontFamily:g?.fontFamily??null,open:i==="fontFamily",onOpenChange:d("fontFamily")})]}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(nt,{editor:e,activeStyle:g?.fontSize??"text",open:i==="fontSize",onOpenChange:d("fontSize")})}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsxs)(a.FloatingToolbar.Group,{children:[(0,t.jsx)(F,{label:n("graph.toolbar.formatting.bold"),active:g?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,t.jsx)("strong",{children:"B"})}),(0,t.jsx)(F,{label:n("graph.toolbar.formatting.italic"),active:g?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,t.jsx)("em",{children:"I"})}),(0,t.jsx)(F,{label:n("graph.toolbar.formatting.underline"),active:g?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,t.jsx)("u",{children:"U"})})]}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(mt,{editor:e,activeAlignment:g?.textAlign})}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(ht,{editor:e,currentUrl:g?.linkUrl??null,active:g?.linked??!1,open:i==="link",onOpenChange:d("link")})})]})})},_t="_1uy50v30",Te=({editor:e,ariaLabel:n})=>(0,t.jsxs)("div",{className:_t,children:[(0,t.jsx)(kt,{editor:e}),(0,t.jsx)(_.EditorContent,{editor:e,"aria-label":n})]}),Ct=200,X=({content:e,extensions:n,editable:r,onUpdate:u,updateDebounceMs:i=Ct})=>{const c=(0,h.useRef)(te(e)),l=(0,h.useRef)(c.current),d=o.useDebouncedCallback(x=>{l.current=x,u?.(x)},i),p=(0,_.useEditor)({extensions:n,content:c.current,editable:r,immediatelyRender:!1,onUpdate:({editor:x})=>{const y=x.getJSON();if($(l.current,y))return d.cancel();d.run(y)}});return(0,h.useEffect)(()=>{p?.setEditable(r)},[p,r]),(0,h.useEffect)(()=>{if(!p)return;const x=te(e);$(l.current,x)||(l.current=x,!$(p.getJSON(),x)&&(d.cancel(),Ft(p,x)))},[p,e,d]),(0,h.useEffect)(()=>()=>d.flush(),[d]),p},te=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,Ft=(e,n)=>{const{from:r,to:u}=e.state.selection;e.commands.setContent(n,{emitUpdate:!1});const i=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(r,i),to:Math.min(u,i)})},$=(e,n)=>JSON.stringify(R(e))===JSON.stringify(R(n)),R=e=>Array.isArray(e)?e.map(R):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([n,r])=>[n,R(r)]).filter(([,n])=>!At(n)).sort(([n],[r])=>String(n).localeCompare(String(r)))),At=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,Et=({caption:e,captionStyle:n})=>{const{dispatch:r}=o.useGraphCommands(),u=o.useEditorStore(),i=X({content:e,extensions:(0,h.useMemo)(()=>Xe({placeholder:o.CAPTION_PLACEHOLDER}),[]),editable:!0,onUpdate:c=>{const l=lt(c)?null:c;r(new m.SetContentCaptionCommand({caption:l}))}});return(0,h.useLayoutEffect)(()=>{i!==null&&ue(i,u.getState().takePendingTextCaret("caption"))},[i,u]),(0,t.jsx)("div",{"data-testid":"caption-editor",style:o.toHtmlTextCss(n),children:i===null?(0,t.jsx)(o.CaptionTextSurface,{caption:e}):(0,t.jsx)(Te,{editor:i,ariaLabel:"Chart caption"})})},Pt=e=>[D.Document,oe.Paragraph,...K(),Lt,B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],Nt=({annotation:e})=>{const n=o.useI18n(),{dispatch:r}=o.useGraphCommands(),u=o.useEditorStore(),i=(0,h.useMemo)(()=>Pt(n("graph.annotations.text.placeholder")),[n]),c=X({content:e.content,extensions:i,editable:!0,onUpdate:p=>{r(new m.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:p}}))}});(0,h.useEffect)(()=>{const{setCaretEditor:p}=u.getState();return p(c),()=>p(null)},[c,u]),(0,h.useEffect)(()=>{c?.commands.focus("end",{scrollIntoView:!1})},[c]);const l=(0,_.useEditorState)({editor:c,selector:({editor:p})=>a.readPickedFontSize(p)}),d=(0,_.useEditorState)({editor:c,selector:({editor:p})=>a.readPickedFont(p)});return(0,t.jsx)(_.EditorContent,{"aria-label":n("graph.annotations.text.editLabel"),className:o.editor,editor:c,style:{...l===null?{}:{fontSize:`calc(${l}px * ${o.vars.textScale})`},...d===null?{}:{fontFamily:o.resolveRichTextFontFamily(d)}},"data-testid":"text-annotation-editor"})},ne=e=>{const n=o.resolveRichTextFontFamily(e);return n===void 0?{}:{style:`font-family: ${n}`}},Lt=re.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>ne(e.fontFamily)},font:{default:null,renderHTML:e=>ne(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${o.vars.textScale})`}:{}}}}]}}),Mt=({title:e,showTitle:n,showSubtitle:r,subtitle:u})=>{const{dispatch:i}=o.useGraphCommands(),c=o.useEditorStore(),l=(0,h.useMemo)(()=>Ke({titlePlaceholder:o.TITLE_PLACEHOLDER,subtitlePlaceholder:o.TITLE_PLACEHOLDER,showTitle:n,showSubtitle:r}),[n,r]),d=X({content:(0,h.useMemo)(()=>o.buildTitleEditorDoc({title:e,showTitle:n,subtitle:u,showSubtitle:r}),[e,n,u,r]),extensions:l,editable:!0,onUpdate:p=>{const x=o.splitTitleEditorDoc(p,n);n&&i(new m.SetContentTitleCommand({title:x.title})),r&&i(new m.SetContentSubtitleCommand({subtitle:x.subtitle}))}});return(0,h.useLayoutEffect)(()=>{d!==null&&ue(d,c.getState().takePendingTextCaret("header"))},[d,c]),(0,t.jsx)("div",{className:o.textStyleEditor,"data-testid":"title-editor",children:d===null?(0,t.jsx)(o.HeaderTextSurface,{title:e,showTitle:n,showSubtitle:r,subtitle:u}):(0,t.jsx)(Te,{editor:d,ariaLabel:"Chart title and subtitle"})})};exports.CaptionEditor=Et;exports.TextAnnotationEditor=Nt;exports.TextToolbar=qe;exports.TitleEditor=Mt;
|