metanorma-document 0.2.9 → 0.2.12
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.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +164 -66
- data/CLAUDE.md +26 -0
- data/README.adoc +144 -0
- data/Rakefile +14 -2
- data/TODO.finalize/01-split-multi-class-files.md +8 -0
- data/TODO.finalize/02-remove-data-dist-iso-document-frontend.md +6 -0
- data/TODO.finalize/03-align-frontend-iife-and-gha-build.md +11 -0
- data/TODO.finalize/04-theme-per-flavor-config-driven.md +9 -0
- data/TODO.finalize/05-migrate-all-html-to-liquid.md +16 -0
- data/TODO.finalize/06-integrate-pubid-library.md +16 -0
- data/TODO.finalize/07-replace-relaton-models-with-relaton-bib.md +39 -0
- data/TODO.finalize/08-refactor-renderer-architecture.md +25 -0
- data/TODO.finalize/09-eliminate-code-smells.md +14 -0
- data/TODO.finalize/10-comprehensive-spec-coverage.md +24 -0
- data/TODO.finalize/11-config-driven-flavor-metadata.md +20 -0
- data/TODO.finalize/12-add-frozen-string-literal.md +6 -0
- data/TODO.finalize/13-extract-composition-from-god-class.md +96 -0
- data/TODO.finalize/14-config-driven-section-ordering.md +31 -0
- data/TODO.finalize/15-theme-directories-per-flavor.md +46 -0
- data/TODO.finalize/16-theme-lutaml-model-schema.md +44 -0
- data/data/javascripts/components/mn-footnotes.js +68 -0
- data/data/javascripts/components/mn-lightbox.js +18 -2
- data/data/javascripts/components/mn-shortcuts.js +2 -0
- data/data/javascripts/core/mn-navigation.js +8 -0
- data/data/javascripts/core/mn-theme.js +9 -9
- data/data/logos/oiml-logo-full-dark.svg +1 -0
- data/data/logos/oiml-logo-full-light.svg +1 -0
- data/data/logos/oiml-logo-icon-dark.svg +1 -0
- data/data/logos/oiml-logo-icon-light.svg +1 -0
- data/data/logos/oiml-logo.svg +1 -0
- data/data/logos/pdfa-logo.svg +31 -94
- data/data/stylesheets/base/_layout.css +3 -0
- data/data/stylesheets/base/_reset.css +3 -3
- data/data/stylesheets/base/_typography.css +0 -5
- data/data/stylesheets/components/bibliography.css +3 -3
- data/data/stylesheets/components/cover.css +3 -1
- data/data/stylesheets/components/figure.css +13 -1
- data/data/stylesheets/components/footnote.css +65 -5
- data/data/stylesheets/components/formula.css +44 -0
- data/data/stylesheets/components/header.css +17 -2
- data/data/stylesheets/components/inline.css +1 -1
- data/data/stylesheets/components/table.css +15 -2
- data/data/stylesheets/components/term.css +0 -1
- data/data/themes/bipm.yaml +60 -0
- data/data/themes/cc.yaml +43 -0
- data/data/themes/icc.yaml +39 -0
- data/data/themes/iec.yaml +44 -0
- data/data/themes/ieee.yaml +43 -0
- data/data/themes/ietf.yaml +45 -0
- data/data/themes/iho.yaml +46 -0
- data/data/themes/iso.yaml +40 -0
- data/data/themes/itu.yaml +45 -0
- data/data/themes/ogc.yaml +51 -0
- data/data/themes/oiml.yaml +56 -0
- data/data/themes/pdfa.yaml +44 -0
- data/data/themes/ribose.yaml +43 -0
- data/exe/metanorma-document +11 -0
- data/frontend/e2e/sample-html.test.ts +256 -0
- data/frontend/index.html +12 -0
- data/frontend/package-lock.json +4725 -0
- data/frontend/package.json +32 -0
- data/frontend/postcss.config.js +6 -0
- data/frontend/src/App.vue +79 -0
- data/frontend/src/app.ts +21 -0
- data/frontend/src/components/AppSidebar.vue +77 -0
- data/frontend/src/components/DocumentReader.vue +180 -0
- data/frontend/src/components/MirrorRenderer.vue +23 -0
- data/frontend/src/components/ReadingProgressBar.vue +29 -0
- data/frontend/src/components/TextRenderer.vue +131 -0
- data/frontend/src/components/TocItem.vue +57 -0
- data/frontend/src/components/TopBar.vue +49 -0
- data/frontend/src/components/__tests__/MirrorRenderer.test.ts +178 -0
- data/frontend/src/components/blocks/AdmonitionBlock.vue +74 -0
- data/frontend/src/components/blocks/ClauseBlock.vue +53 -0
- data/frontend/src/components/blocks/ExampleBlock.vue +21 -0
- data/frontend/src/components/blocks/FallbackBlock.vue +18 -0
- data/frontend/src/components/blocks/FigureBlock.vue +26 -0
- data/frontend/src/components/blocks/FootnotesBlock.vue +25 -0
- data/frontend/src/components/blocks/ListBlocks.vue +62 -0
- data/frontend/src/components/blocks/NoteBlock.vue +21 -0
- data/frontend/src/components/blocks/ParagraphBlock.vue +25 -0
- data/frontend/src/components/blocks/QuoteBlock.vue +25 -0
- data/frontend/src/components/blocks/ReviewBlock.vue +39 -0
- data/frontend/src/components/blocks/SourcecodeBlock.vue +52 -0
- data/frontend/src/components/blocks/TableBlock.vue +48 -0
- data/frontend/src/components/blocks/index.ts +36 -0
- data/frontend/src/stores/__tests__/documentStore.fixture.test.ts +272 -0
- data/frontend/src/stores/__tests__/documentStore.test.ts +143 -0
- data/frontend/src/stores/__tests__/ebookStore.test.ts +145 -0
- data/frontend/src/stores/__tests__/uiStore.test.ts +42 -0
- data/frontend/src/stores/documentStore.ts +153 -0
- data/frontend/src/stores/ebookStore.ts +179 -0
- data/frontend/src/stores/uiStore.ts +32 -0
- data/frontend/src/styles.css +156 -0
- data/frontend/src/types/__tests__/rendering-contract.test.ts +172 -0
- data/frontend/src/types/rendering-contract.ts +209 -0
- data/frontend/src/utils/__tests__/typeMetadata.test.ts +102 -0
- data/frontend/src/utils/typeMetadata.ts +121 -0
- data/frontend/tailwind.config.js +18 -0
- data/frontend/test/fixtures/iso-document.json +271 -0
- data/frontend/tmp/debug_e2e.cjs +46 -0
- data/frontend/tsconfig.json +25 -0
- data/frontend/tsconfig.node.json +11 -0
- data/frontend/vite.config.ts +37 -0
- data/frontend/vitest.e2e.config.ts +9 -0
- data/lib/metanorma/bipm_document/metadata/bipm_bibliographic_item.rb +0 -14
- data/lib/metanorma/bipm_document/metadata/depiction_element.rb +18 -0
- data/lib/metanorma/bipm_document/metadata.rb +1 -1
- data/lib/metanorma/document/cli.rb +116 -0
- data/lib/metanorma/document/components/ancillary_blocks/callout_annotation.rb +27 -0
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_block.rb +0 -65
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_body.rb +18 -0
- data/lib/metanorma/document/components/ancillary_blocks.rb +4 -0
- data/lib/metanorma/document/components/bib_data/bib_data.rb +7 -0
- data/lib/metanorma/document/components/blocks/classification_value.rb +21 -0
- data/lib/metanorma/document/components/blocks/permission_model.rb +28 -0
- data/lib/metanorma/document/components/blocks/recommendation_model.rb +28 -0
- data/lib/metanorma/document/components/blocks/requirement_base.rb +30 -0
- data/lib/metanorma/document/components/blocks/requirement_classification.rb +20 -0
- data/lib/metanorma/document/components/blocks/requirement_description.rb +43 -0
- data/lib/metanorma/document/components/blocks/requirement_inherit.rb +24 -0
- data/lib/metanorma/document/components/blocks/requirement_model.rb +0 -131
- data/lib/metanorma/document/components/blocks.rb +8 -7
- data/lib/metanorma/document/components/id_elements/image.rb +2 -0
- data/lib/metanorma/document/components/inline/asciimath_element.rb +2 -0
- data/lib/metanorma/document/components/inline/attribution_element.rb +2 -0
- data/lib/metanorma/document/components/inline/bcp14_element.rb +2 -0
- data/lib/metanorma/document/components/inline/biblio_tag_element.rb +2 -0
- data/lib/metanorma/document/components/inline/br_element.rb +2 -0
- data/lib/metanorma/document/components/inline/comma_element.rb +2 -0
- data/lib/metanorma/document/components/inline/concept_element.rb +2 -0
- data/lib/metanorma/document/components/inline/display_text_element.rb +2 -0
- data/lib/metanorma/document/components/inline/em_raw_element.rb +2 -0
- data/lib/metanorma/document/components/inline/enum_comma_element.rb +2 -0
- data/lib/metanorma/document/components/inline/eref_element.rb +2 -0
- data/lib/metanorma/document/components/inline/fmt_admitted_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_annotation_body_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_annotation_end_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_annotation_start_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_concept_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_definition_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_fn_body_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_fn_label_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_footnote_container_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_identifier_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_name_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_preferred_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_sourcecode_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_stem_element.rb +10 -0
- data/lib/metanorma/document/components/inline/fmt_termsource_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_title_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_xref_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fmt_xref_label_element.rb +4 -0
- data/lib/metanorma/document/components/inline/fn_element.rb +2 -0
- data/lib/metanorma/document/components/inline/link_element.rb +2 -0
- data/lib/metanorma/document/components/inline/localized_string_element.rb +2 -0
- data/lib/metanorma/document/components/inline/localized_strings_element.rb +2 -0
- data/lib/metanorma/document/components/inline/location_element.rb +24 -0
- data/lib/metanorma/document/components/inline/math_element.rb +2 -0
- data/lib/metanorma/document/components/inline/name_with_id_element.rb +4 -0
- data/lib/metanorma/document/components/inline/rendered_display.rb +23 -0
- data/lib/metanorma/document/components/inline/rendered_math_element.rb +21 -0
- data/lib/metanorma/document/components/inline/semantic_content.rb +51 -0
- data/lib/metanorma/document/components/inline/semantic_math_element.rb +20 -0
- data/lib/metanorma/document/components/inline/semx_child_element.rb +2 -0
- data/lib/metanorma/document/components/inline/semx_element.rb +13 -1
- data/lib/metanorma/document/components/inline/small_cap_element.rb +2 -0
- data/lib/metanorma/document/components/inline/span_element.rb +10 -15
- data/lib/metanorma/document/components/inline/stem_inline_element.rb +7 -1
- data/lib/metanorma/document/components/inline/strong_raw_element.rb +2 -0
- data/lib/metanorma/document/components/inline/sub_element.rb +2 -0
- data/lib/metanorma/document/components/inline/sup_element.rb +2 -0
- data/lib/metanorma/document/components/inline/tab_element.rb +2 -0
- data/lib/metanorma/document/components/inline/title_with_annotation_element.rb +4 -0
- data/lib/metanorma/document/components/inline/tt_element.rb +2 -0
- data/lib/metanorma/document/components/inline/variant_title_element.rb +2 -0
- data/lib/metanorma/document/components/inline/vocabulary.rb +184 -0
- data/lib/metanorma/document/components/inline/xref_element.rb +10 -0
- data/lib/metanorma/document/components/inline.rb +12 -0
- data/lib/metanorma/document/components/multi_paragraph/quote_author_element.rb +20 -0
- data/lib/metanorma/document/components/multi_paragraph/quote_block.rb +0 -29
- data/lib/metanorma/document/components/multi_paragraph.rb +2 -0
- data/lib/metanorma/document/components/reference_elements/source_element.rb +0 -31
- data/lib/metanorma/document/components/reference_elements/source_modification.rb +21 -0
- data/lib/metanorma/document/components/reference_elements/source_origin.rb +28 -0
- data/lib/metanorma/document/components/reference_elements.rb +2 -2
- data/lib/metanorma/document/components/tables/col_element.rb +18 -0
- data/lib/metanorma/document/components/tables/col_group_element.rb +18 -0
- data/lib/metanorma/document/components/tables/table_block.rb +0 -22
- data/lib/metanorma/document/components/tables/table_body_section.rb +16 -0
- data/lib/metanorma/document/components/tables/table_foot_section.rb +16 -0
- data/lib/metanorma/document/components/tables/table_head_section.rb +16 -0
- data/lib/metanorma/document/components/tables/table_section.rb +0 -25
- data/lib/metanorma/document/components/tables.rb +5 -3
- data/lib/metanorma/document/relaton/address.rb +0 -27
- data/lib/metanorma/document/relaton/bib_item_locality.rb +3 -12
- data/lib/metanorma/document/relaton/copyright_association.rb +0 -10
- data/lib/metanorma/document/relaton/copyright_owner.rb +16 -0
- data/lib/metanorma/document/relaton/edition.rb +4 -7
- data/lib/metanorma/document/relaton/formatted_address.rb +29 -0
- data/lib/metanorma/document/relaton/logo_element.rb +18 -0
- data/lib/metanorma/document/relaton/organization.rb +0 -14
- data/lib/metanorma/document/relaton/phone.rb +3 -9
- data/lib/metanorma/document/relaton/place_type.rb +0 -13
- data/lib/metanorma/document/relaton/price_type.rb +3 -9
- data/lib/metanorma/document/relaton/region_element.rb +18 -0
- data/lib/metanorma/document/relaton.rb +6 -1
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/document.rb +2 -0
- data/lib/metanorma/html/asset_pipeline.rb +1 -0
- data/lib/metanorma/html/base_renderer.rb +261 -1008
- data/lib/metanorma/html/bipm_renderer.rb +15 -144
- data/lib/metanorma/html/cc_renderer.rb +1 -45
- data/lib/metanorma/html/component/base.rb +2 -7
- data/lib/metanorma/html/component/index_section.rb +41 -43
- data/lib/metanorma/html/drops/admonition_drop.rb +1 -4
- data/lib/metanorma/html/drops/biblio_entry_drop.rb +50 -0
- data/lib/metanorma/html/drops/block_element_drop.rb +7 -2
- data/lib/metanorma/html/drops/example_drop.rb +1 -4
- data/lib/metanorma/html/drops/figure_drop.rb +31 -22
- data/lib/metanorma/html/drops/footnote_drop.rb +1 -1
- data/lib/metanorma/html/drops/formula_drop.rb +45 -16
- data/lib/metanorma/html/drops/note_drop.rb +9 -7
- data/lib/metanorma/html/drops/sourcecode_drop.rb +12 -5
- data/lib/metanorma/html/drops.rb +2 -0
- data/lib/metanorma/html/generator.rb +2 -2
- data/lib/metanorma/html/icc_renderer.rb +0 -39
- data/lib/metanorma/html/iec_renderer.rb +1 -44
- data/lib/metanorma/html/ieee_renderer.rb +1 -45
- data/lib/metanorma/html/ietf_renderer.rb +1 -48
- data/lib/metanorma/html/iho_renderer.rb +1 -46
- data/lib/metanorma/html/iso_renderer.rb +290 -343
- data/lib/metanorma/html/itu_renderer.rb +1 -45
- data/lib/metanorma/html/ogc_renderer.rb +15 -76
- data/lib/metanorma/html/oiml_renderer.rb +18 -38
- data/lib/metanorma/html/pdfa_renderer.rb +0 -39
- data/lib/metanorma/html/renderers/block_renderer.rb +372 -0
- data/lib/metanorma/html/renderers/inline_renderer.rb +655 -0
- data/lib/metanorma/html/renderers/pubid_renderer.rb +69 -0
- data/lib/metanorma/html/renderers/section_renderer.rb +193 -0
- data/lib/metanorma/html/renderers.rb +8 -0
- data/lib/metanorma/html/ribose_renderer.rb +1 -45
- data/lib/metanorma/html/standard_renderer.rb +341 -229
- data/lib/metanorma/html/templates/_audio.html.liquid +1 -0
- data/lib/metanorma/html/templates/_biblio_entry.html.liquid +1 -0
- data/lib/metanorma/html/templates/_bipm_cover.html.liquid +27 -0
- data/lib/metanorma/html/templates/_boilerplate.html.liquid +1 -0
- data/lib/metanorma/html/templates/_bookmark.html.liquid +1 -0
- data/lib/metanorma/html/templates/_br.html.liquid +1 -0
- data/lib/metanorma/html/templates/_definition_list.html.liquid +6 -0
- data/lib/metanorma/html/templates/_element.html.liquid +1 -0
- data/lib/metanorma/html/templates/_fn_marker.html.liquid +1 -0
- data/lib/metanorma/html/templates/_footnotes.html.liquid +6 -6
- data/lib/metanorma/html/templates/_formula.html.liquid +1 -1
- data/lib/metanorma/html/templates/_header.html.liquid +1 -1
- data/lib/metanorma/html/templates/_heading.html.liquid +1 -0
- data/lib/metanorma/html/templates/_image.html.liquid +1 -0
- data/lib/metanorma/html/templates/_inline_span.html.liquid +1 -0
- data/lib/metanorma/html/templates/_iso_cover.html.liquid +1 -1
- data/lib/metanorma/html/templates/_link.html.liquid +1 -0
- data/lib/metanorma/html/templates/_list.html.liquid +3 -0
- data/lib/metanorma/html/templates/_list_item.html.liquid +1 -0
- data/lib/metanorma/html/templates/_main_content.html.liquid +1 -0
- data/lib/metanorma/html/templates/_math_container.html.liquid +1 -0
- data/lib/metanorma/html/templates/_paragraph.html.liquid +1 -0
- data/lib/metanorma/html/templates/_prefatory_section.html.liquid +1 -0
- data/lib/metanorma/html/templates/_pubid_identifier.html.liquid +1 -0
- data/lib/metanorma/html/templates/_quote.html.liquid +4 -0
- data/lib/metanorma/html/templates/_ref_date.html.liquid +1 -0
- data/lib/metanorma/html/templates/_ref_title.html.liquid +1 -0
- data/lib/metanorma/html/templates/_section.html.liquid +5 -0
- data/lib/metanorma/html/templates/_standard_cover.html.liquid +31 -0
- data/lib/metanorma/html/templates/_standard_doc_title.html.liquid +3 -0
- data/lib/metanorma/html/templates/_stem_span.html.liquid +1 -0
- data/lib/metanorma/html/templates/_table.html.liquid +9 -0
- data/lib/metanorma/html/templates/_term_domain.html.liquid +1 -0
- data/lib/metanorma/html/templates/_term_example.html.liquid +1 -0
- data/lib/metanorma/html/templates/_term_note.html.liquid +1 -0
- data/lib/metanorma/html/templates/_term_number.html.liquid +1 -0
- data/lib/metanorma/html/templates/_term_source.html.liquid +1 -0
- data/lib/metanorma/html/templates/_term_text_note.html.liquid +1 -0
- data/lib/metanorma/html/templates/_video.html.liquid +1 -0
- data/lib/metanorma/html/templates/_wrapped_preface.html.liquid +1 -0
- data/lib/metanorma/html/templates/document.html.liquid +4 -0
- data/lib/metanorma/html/theme.rb +180 -107
- data/lib/metanorma/html.rb +13 -0
- data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +0 -25
- data/lib/metanorma/ietf_document/metadata/pi_settings.rb +32 -0
- data/lib/metanorma/ietf_document/metadata.rb +2 -0
- data/lib/metanorma/iso_document/metadata/doctype_element.rb +20 -0
- data/lib/metanorma/iso_document/metadata/iso_bib_data_extension_type.rb +0 -48
- data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +0 -72
- data/lib/metanorma/iso_document/metadata/iso_document_status.rb +0 -30
- data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +4 -1
- data/lib/metanorma/iso_document/metadata/language_element.rb +18 -0
- data/lib/metanorma/iso_document/metadata/project_number.rb +22 -0
- data/lib/metanorma/iso_document/metadata/script_element.rb +18 -0
- data/lib/metanorma/iso_document/metadata/stage_element.rb +26 -0
- data/lib/metanorma/iso_document/metadata/stagename_element.rb +18 -0
- data/lib/metanorma/iso_document/metadata/structured_identifier.rb +0 -17
- data/lib/metanorma/iso_document/metadata/title_collection.rb +1 -0
- data/lib/metanorma/iso_document/metadata.rb +9 -4
- data/lib/metanorma/iso_document/terms/iso_term.rb +0 -13
- data/lib/metanorma/iso_document/terms/term_domain_element.rb +18 -0
- data/lib/metanorma/iso_document/terms.rb +1 -0
- data/lib/metanorma/itu_document/metadata/itu_bib_data_extension_type.rb +0 -37
- data/lib/metanorma/itu_document/metadata/meeting_date.rb +18 -0
- data/lib/metanorma/itu_document/metadata/meeting_element.rb +18 -0
- data/lib/metanorma/itu_document/metadata/study_period.rb +18 -0
- data/lib/metanorma/itu_document/metadata.rb +3 -4
- data/lib/metanorma/mirror/default_registry.rb +170 -0
- data/lib/metanorma/mirror/handler_registry.rb +60 -0
- data/lib/metanorma/mirror/handler_result.rb +37 -0
- data/lib/metanorma/mirror/handlers/admonition.rb +18 -0
- data/lib/metanorma/mirror/handlers/example.rb +21 -0
- data/lib/metanorma/mirror/handlers/figure.rb +53 -0
- data/lib/metanorma/mirror/handlers/formula.rb +35 -0
- data/lib/metanorma/mirror/handlers/inline/rich_html_renderer.rb +159 -0
- data/lib/metanorma/mirror/handlers/inline/text_extractor.rb +116 -0
- data/lib/metanorma/mirror/handlers/inline.rb +225 -0
- data/lib/metanorma/mirror/handlers/list.rb +110 -0
- data/lib/metanorma/mirror/handlers/note.rb +26 -0
- data/lib/metanorma/mirror/handlers/paragraph.rb +19 -0
- data/lib/metanorma/mirror/handlers/quote.rb +16 -0
- data/lib/metanorma/mirror/handlers/review.rb +19 -0
- data/lib/metanorma/mirror/handlers/section.rb +149 -0
- data/lib/metanorma/mirror/handlers/sourcecode.rb +27 -0
- data/lib/metanorma/mirror/handlers/structural.rb +68 -0
- data/lib/metanorma/mirror/handlers/table.rb +81 -0
- data/lib/metanorma/mirror/handlers/term.rb +100 -0
- data/lib/metanorma/mirror/handlers.rb +60 -0
- data/lib/metanorma/mirror/id_strategy/positional.rb +166 -0
- data/lib/metanorma/mirror/id_strategy/preserve.rb +12 -0
- data/lib/metanorma/mirror/id_strategy.rb +34 -0
- data/lib/metanorma/mirror/math_util.rb +53 -0
- data/lib/metanorma/mirror/metadata.rb +37 -0
- data/lib/metanorma/mirror/metanorma_to_mirror.rb +101 -0
- data/lib/metanorma/mirror/model/container.rb +47 -0
- data/lib/metanorma/mirror/model/factory.rb +52 -0
- data/lib/metanorma/mirror/model/guide.rb +25 -0
- data/lib/metanorma/mirror/model/leaf.rb +17 -0
- data/lib/metanorma/mirror/model/mark.rb +53 -0
- data/lib/metanorma/mirror/model/node.rb +47 -0
- data/lib/metanorma/mirror/model/soft_break.rb +33 -0
- data/lib/metanorma/mirror/model/text.rb +34 -0
- data/lib/metanorma/mirror/model.rb +16 -0
- data/lib/metanorma/mirror/output/builder.rb +39 -0
- data/lib/metanorma/mirror/output/formats/base_format.rb +90 -0
- data/lib/metanorma/mirror/output/formats/inline_format.rb +81 -0
- data/lib/metanorma/mirror/output/formats.rb +53 -0
- data/lib/metanorma/mirror/output/html_renderer.rb +95 -0
- data/lib/metanorma/mirror/output/html_renderers/block_renderers.rb +178 -0
- data/lib/metanorma/mirror/output/html_renderers/inline_renderer.rb +61 -0
- data/lib/metanorma/mirror/output/html_renderers/list_renderers.rb +96 -0
- data/lib/metanorma/mirror/output/html_renderers/mark_renderers.rb +64 -0
- data/lib/metanorma/mirror/output/html_renderers/section_renderers.rb +129 -0
- data/lib/metanorma/mirror/output/html_renderers/structural_renderers.rb +80 -0
- data/lib/metanorma/mirror/output/html_renderers/table_renderers.rb +87 -0
- data/lib/metanorma/mirror/output/html_renderers.rb +76 -0
- data/lib/metanorma/mirror/output/pipeline.rb +92 -0
- data/lib/metanorma/mirror/output/pipeline_context.rb +22 -0
- data/lib/metanorma/mirror/output.rb +14 -0
- data/lib/metanorma/mirror/rewriter.rb +121 -0
- data/lib/metanorma/mirror/safe_attr.rb +16 -0
- data/lib/metanorma/mirror/serialization/json_serializer.rb +25 -0
- data/lib/metanorma/mirror/serialization/yaml_serializer.rb +20 -0
- data/lib/metanorma/mirror/serialization.rb +10 -0
- data/lib/metanorma/mirror/transformer.rb +22 -0
- data/lib/metanorma/mirror.rb +32 -0
- data/lib/metanorma/standard_document/annotation.rb +37 -0
- data/lib/metanorma/standard_document/block_attributes.rb +15 -2
- data/lib/metanorma/standard_document/blocks/block_source.rb +0 -23
- data/lib/metanorma/standard_document/blocks/source_origin_element.rb +23 -0
- data/lib/metanorma/standard_document/blocks.rb +1 -1
- data/lib/metanorma/standard_document/terms/term_expression.rb +0 -31
- data/lib/metanorma/standard_document/terms/term_name_element.rb +29 -0
- data/lib/metanorma/standard_document/terms.rb +1 -0
- data/script/render_both.rb +18 -0
- metadata +262 -13
- data/.github/workflows/rake.yml +0 -21
- data/.github/workflows/release.yml +0 -25
- data/.github/workflows/roundtrip-samples.yml +0 -132
- data/.gitignore +0 -19
- data/.rspec +0 -3
- data/.rubocop.yml +0 -22
- data/Gemfile +0 -28
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/metanorma-document.gemspec +0 -35
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest'
|
|
2
|
+
import { nextTick } from 'vue'
|
|
3
|
+
import { setActivePinia, createPinia } from 'pinia'
|
|
4
|
+
import { useEbookStore } from '../ebookStore'
|
|
5
|
+
|
|
6
|
+
describe('useEbookStore', () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
localStorage.clear()
|
|
9
|
+
setActivePinia(createPinia())
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('has correct defaults', () => {
|
|
13
|
+
const store = useEbookStore()
|
|
14
|
+
expect(store.fontSize).toBe(18)
|
|
15
|
+
expect(store.fontFamily).toBe('sans')
|
|
16
|
+
expect(store.contentWidth).toBe('default')
|
|
17
|
+
expect(store.theme).toBe('day')
|
|
18
|
+
expect(store.lineHeight).toBe('comfortable')
|
|
19
|
+
expect(store.showProgress).toBe(true)
|
|
20
|
+
expect(store.readingMode).toBe('scroll')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('sets font size with clamping', () => {
|
|
24
|
+
const store = useEbookStore()
|
|
25
|
+
store.setFontSize(20)
|
|
26
|
+
expect(store.fontSize).toBe(20)
|
|
27
|
+
store.setFontSize(5)
|
|
28
|
+
expect(store.fontSize).toBe(12)
|
|
29
|
+
store.setFontSize(100)
|
|
30
|
+
expect(store.fontSize).toBe(32)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('sets font family', () => {
|
|
34
|
+
const store = useEbookStore()
|
|
35
|
+
store.setFontFamily('serif')
|
|
36
|
+
expect(store.fontFamily).toBe('serif')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('sets content width', () => {
|
|
40
|
+
const store = useEbookStore()
|
|
41
|
+
store.setContentWidth('wide')
|
|
42
|
+
expect(store.contentWidth).toBe('wide')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('sets theme', () => {
|
|
46
|
+
const store = useEbookStore()
|
|
47
|
+
store.setTheme('night')
|
|
48
|
+
expect(store.theme).toBe('night')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('cycles through themes', () => {
|
|
52
|
+
const store = useEbookStore()
|
|
53
|
+
expect(store.theme).toBe('day')
|
|
54
|
+
store.cycleTheme()
|
|
55
|
+
expect(store.theme).toBe('sepia')
|
|
56
|
+
store.cycleTheme()
|
|
57
|
+
expect(store.theme).toBe('night')
|
|
58
|
+
store.cycleTheme()
|
|
59
|
+
expect(store.theme).toBe('oled')
|
|
60
|
+
store.cycleTheme()
|
|
61
|
+
expect(store.theme).toBe('day')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('sets line height', () => {
|
|
65
|
+
const store = useEbookStore()
|
|
66
|
+
store.setLineHeight('spacious')
|
|
67
|
+
expect(store.lineHeight).toBe('spacious')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('toggles focus mode', () => {
|
|
71
|
+
const store = useEbookStore()
|
|
72
|
+
store.setFocusMode(true)
|
|
73
|
+
expect(store.focusMode).toBe(true)
|
|
74
|
+
store.toggleFocusMode()
|
|
75
|
+
expect(store.focusMode).toBe(false)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('toggles settings panel', () => {
|
|
79
|
+
const store = useEbookStore()
|
|
80
|
+
expect(store.settingsOpen).toBe(false)
|
|
81
|
+
store.toggleSettings()
|
|
82
|
+
expect(store.settingsOpen).toBe(true)
|
|
83
|
+
expect(store.tocOpen).toBe(false)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('toggles toc panel', () => {
|
|
87
|
+
const store = useEbookStore()
|
|
88
|
+
store.toggleToc()
|
|
89
|
+
expect(store.tocOpen).toBe(true)
|
|
90
|
+
expect(store.settingsOpen).toBe(false)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('closeAll closes both panels', () => {
|
|
94
|
+
const store = useEbookStore()
|
|
95
|
+
store.toggleSettings()
|
|
96
|
+
store.closeAll()
|
|
97
|
+
expect(store.settingsOpen).toBe(false)
|
|
98
|
+
expect(store.tocOpen).toBe(false)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('returns theme class', () => {
|
|
102
|
+
const store = useEbookStore()
|
|
103
|
+
expect(store.getThemeClass()).toBe('theme-day')
|
|
104
|
+
store.setTheme('night')
|
|
105
|
+
expect(store.getThemeClass()).toBe('theme-night')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('returns CSS variables', () => {
|
|
109
|
+
const store = useEbookStore()
|
|
110
|
+
const vars = store.getCssVariables()
|
|
111
|
+
expect(vars['--ebook-font-size']).toBe('18px')
|
|
112
|
+
expect(vars['--ebook-max-width']).toBe('58rem')
|
|
113
|
+
expect(vars['--ebook-line-height']).toBe('1.6')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('CSS variables reflect focus mode', () => {
|
|
117
|
+
const store = useEbookStore()
|
|
118
|
+
store.setFocusMode(true)
|
|
119
|
+
const vars = store.getCssVariables()
|
|
120
|
+
expect(vars['--ebook-max-width']).toBe('100%')
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('persists preferences to localStorage', async () => {
|
|
124
|
+
const store = useEbookStore()
|
|
125
|
+
store.setTheme('night')
|
|
126
|
+
store.setFontSize(24)
|
|
127
|
+
await nextTick()
|
|
128
|
+
|
|
129
|
+
const stored = JSON.parse(localStorage.getItem('metanorma_ebook_preferences')!)
|
|
130
|
+
expect(stored.theme).toBe('night')
|
|
131
|
+
expect(stored.fontSize).toBe(24)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('loads preferences from localStorage', () => {
|
|
135
|
+
localStorage.setItem('metanorma_ebook_preferences', JSON.stringify({
|
|
136
|
+
theme: 'sepia',
|
|
137
|
+
fontSize: 22,
|
|
138
|
+
}))
|
|
139
|
+
|
|
140
|
+
setActivePinia(createPinia())
|
|
141
|
+
const store = useEbookStore()
|
|
142
|
+
expect(store.theme).toBe('sepia')
|
|
143
|
+
expect(store.fontSize).toBe(22)
|
|
144
|
+
})
|
|
145
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest'
|
|
2
|
+
import { setActivePinia, createPinia } from 'pinia'
|
|
3
|
+
import { useUiStore } from '../uiStore'
|
|
4
|
+
|
|
5
|
+
describe('useUiStore', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
setActivePinia(createPinia())
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('has correct defaults', () => {
|
|
11
|
+
const store = useUiStore()
|
|
12
|
+
expect(store.sidebarOpen).toBe(false)
|
|
13
|
+
expect(store.activeSectionId).toBeNull()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('opens sidebar', () => {
|
|
17
|
+
const store = useUiStore()
|
|
18
|
+
store.openSidebar()
|
|
19
|
+
expect(store.sidebarOpen).toBe(true)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('closes sidebar', () => {
|
|
23
|
+
const store = useUiStore()
|
|
24
|
+
store.openSidebar()
|
|
25
|
+
store.closeSidebar()
|
|
26
|
+
expect(store.sidebarOpen).toBe(false)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('toggles sidebar', () => {
|
|
30
|
+
const store = useUiStore()
|
|
31
|
+
store.toggleSidebar()
|
|
32
|
+
expect(store.sidebarOpen).toBe(true)
|
|
33
|
+
store.toggleSidebar()
|
|
34
|
+
expect(store.sidebarOpen).toBe(false)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('sets active section', () => {
|
|
38
|
+
const store = useUiStore()
|
|
39
|
+
store.setActiveSection('scope')
|
|
40
|
+
expect(store.activeSectionId).toBe('scope')
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref, shallowRef, computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
// ============================================================
|
|
5
|
+
// MetanormaMirror (ProseMirror-style) Types
|
|
6
|
+
// ============================================================
|
|
7
|
+
|
|
8
|
+
export interface MirrorMark {
|
|
9
|
+
type: 'emphasis' | 'strong' | 'subscript' | 'superscript' | 'code'
|
|
10
|
+
| 'underline' | 'strike' | 'smallcap' | 'link' | 'xref'
|
|
11
|
+
| 'eref' | 'footnote' | 'stem' | 'concept' | 'bcp14' | 'span'
|
|
12
|
+
attrs?: Record<string, any>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MirrorTextNode {
|
|
16
|
+
type: 'text'
|
|
17
|
+
text: string
|
|
18
|
+
marks?: MirrorMark[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MirrorBlockNode {
|
|
22
|
+
type: string
|
|
23
|
+
attrs?: Record<string, any>
|
|
24
|
+
content?: (MirrorTextNode | MirrorBlockNode)[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MirrorDocument {
|
|
28
|
+
type: 'doc'
|
|
29
|
+
attrs?: Record<string, any>
|
|
30
|
+
content?: MirrorBlockNode[]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ============================================================
|
|
34
|
+
// TOC Types
|
|
35
|
+
// ============================================================
|
|
36
|
+
|
|
37
|
+
export interface TocItem {
|
|
38
|
+
id: string
|
|
39
|
+
title: string
|
|
40
|
+
type: string
|
|
41
|
+
children: TocItem[]
|
|
42
|
+
number?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface DocumentMeta {
|
|
46
|
+
title?: string
|
|
47
|
+
flavor?: string
|
|
48
|
+
docType?: string
|
|
49
|
+
schemaVersion?: string
|
|
50
|
+
sections: TocItem[]
|
|
51
|
+
numbering: Record<string, string>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ============================================================
|
|
55
|
+
// Document Store
|
|
56
|
+
// ============================================================
|
|
57
|
+
|
|
58
|
+
export const useDocumentStore = defineStore('document', () => {
|
|
59
|
+
const documentMeta = ref<DocumentMeta | null>(null)
|
|
60
|
+
const mirrorDocument = shallowRef<MirrorDocument | null>(null)
|
|
61
|
+
const loadError = ref<string | null>(null)
|
|
62
|
+
|
|
63
|
+
function processMetanormaData(data: any): void {
|
|
64
|
+
if (data.type === 'doc' && Array.isArray(data.content)) {
|
|
65
|
+
mirrorDocument.value = data as MirrorDocument
|
|
66
|
+
|
|
67
|
+
if (data.toc?.sections) {
|
|
68
|
+
documentMeta.value = {
|
|
69
|
+
title: data.meta?.title || data.attrs?.title,
|
|
70
|
+
flavor: data.meta?.flavor || data.attrs?.flavor,
|
|
71
|
+
docType: data.meta?.type || data.attrs?.type,
|
|
72
|
+
schemaVersion: data.meta?.schema_version || data.attrs?.schema_version,
|
|
73
|
+
sections: data.toc.sections,
|
|
74
|
+
numbering: data.toc.numbering || {},
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
documentMeta.value = {
|
|
78
|
+
title: data.meta?.title || data.attrs?.title,
|
|
79
|
+
flavor: data.meta?.flavor || data.attrs?.flavor,
|
|
80
|
+
docType: data.meta?.type || data.attrs?.type,
|
|
81
|
+
schemaVersion: data.meta?.schema_version || data.attrs?.schema_version,
|
|
82
|
+
sections: extractToc(data.content),
|
|
83
|
+
numbering: {},
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function extractToc(nodes: any[]): TocItem[] {
|
|
90
|
+
const sectionTypes = new Set([
|
|
91
|
+
'clause', 'annex', 'terms', 'definitions', 'references',
|
|
92
|
+
'abstract', 'foreword', 'introduction', 'acknowledgements',
|
|
93
|
+
])
|
|
94
|
+
const items: TocItem[] = []
|
|
95
|
+
for (const node of nodes) {
|
|
96
|
+
if (sectionTypes.has(node.type) && node.attrs?.id) {
|
|
97
|
+
items.push({
|
|
98
|
+
id: node.attrs.id,
|
|
99
|
+
title: node.attrs.title || node.type,
|
|
100
|
+
type: node.type,
|
|
101
|
+
children: node.content ? extractToc(node.content) : [],
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return items
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function loadFromWindow(): void {
|
|
109
|
+
loadError.value = null
|
|
110
|
+
const data = (window as any).METANORMA_DATA
|
|
111
|
+
if (data) {
|
|
112
|
+
processMetanormaData(data)
|
|
113
|
+
delete (window as any).METANORMA_DATA
|
|
114
|
+
} else {
|
|
115
|
+
fetch('metanorma.data.json')
|
|
116
|
+
.then(res => {
|
|
117
|
+
if (!res.ok) throw new Error('Failed to load metanorma.data.json')
|
|
118
|
+
return res.json()
|
|
119
|
+
})
|
|
120
|
+
.then(data => processMetanormaData(data))
|
|
121
|
+
.catch(err => {
|
|
122
|
+
console.error('Failed to load document data:', err)
|
|
123
|
+
loadError.value = err instanceof Error ? err.message : 'Failed to load document'
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const title = computed(() => {
|
|
129
|
+
return documentMeta.value?.title || mirrorDocument.value?.attrs?.title || 'Metanorma Document'
|
|
130
|
+
})
|
|
131
|
+
const flavor = computed(() => documentMeta.value?.flavor || '')
|
|
132
|
+
const docType = computed(() => documentMeta.value?.docType || '')
|
|
133
|
+
const sections = computed(() => documentMeta.value?.sections || [])
|
|
134
|
+
const numbering = computed(() => documentMeta.value?.numbering || {})
|
|
135
|
+
|
|
136
|
+
function getNumbering(id: string): string {
|
|
137
|
+
return numbering.value[id] || ''
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
documentMeta,
|
|
142
|
+
mirrorDocument,
|
|
143
|
+
loadError,
|
|
144
|
+
loadFromWindow,
|
|
145
|
+
processMetanormaData,
|
|
146
|
+
title,
|
|
147
|
+
flavor,
|
|
148
|
+
docType,
|
|
149
|
+
sections,
|
|
150
|
+
numbering,
|
|
151
|
+
getNumbering,
|
|
152
|
+
}
|
|
153
|
+
})
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
export type Theme = 'day' | 'sepia' | 'night' | 'oled'
|
|
5
|
+
export type FontFamily = 'sans' | 'serif'
|
|
6
|
+
export type ContentWidth = 'narrow' | 'default' | 'wide'
|
|
7
|
+
export type LineHeight = 'compact' | 'comfortable' | 'relaxed' | 'spacious'
|
|
8
|
+
export type ReadingMode = 'scroll' | 'paged'
|
|
9
|
+
|
|
10
|
+
const STORAGE_KEY = 'metanorma_ebook_preferences'
|
|
11
|
+
|
|
12
|
+
export const CONTENT_WIDTHS: Record<ContentWidth, string> = {
|
|
13
|
+
narrow: '38rem',
|
|
14
|
+
default: '58rem',
|
|
15
|
+
wide: '82rem',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const LINE_HEIGHTS: Record<LineHeight, string> = {
|
|
19
|
+
compact: '1.4',
|
|
20
|
+
comfortable: '1.6',
|
|
21
|
+
relaxed: '1.8',
|
|
22
|
+
spacious: '2.0',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const DEFAULTS = {
|
|
26
|
+
fontSize: 18,
|
|
27
|
+
fontFamily: 'sans' as FontFamily,
|
|
28
|
+
contentWidth: 'default' as ContentWidth,
|
|
29
|
+
theme: 'day' as Theme,
|
|
30
|
+
lineHeight: 'comfortable' as LineHeight,
|
|
31
|
+
readingMode: 'scroll' as ReadingMode,
|
|
32
|
+
showProgress: true,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function loadPreferences(): Partial<typeof DEFAULTS> {
|
|
36
|
+
try {
|
|
37
|
+
const stored = localStorage.getItem(STORAGE_KEY)
|
|
38
|
+
if (stored) return JSON.parse(stored)
|
|
39
|
+
} catch {}
|
|
40
|
+
return {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function savePreferences(prefs: Record<string, unknown>) {
|
|
44
|
+
try {
|
|
45
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(prefs))
|
|
46
|
+
} catch {}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function applyThemeClass(theme: Theme) {
|
|
50
|
+
const html = document.documentElement
|
|
51
|
+
html.classList.remove('theme-day', 'theme-sepia', 'theme-night', 'theme-oled')
|
|
52
|
+
html.classList.add(`theme-${theme}`)
|
|
53
|
+
const isDark = theme === 'night' || theme === 'oled'
|
|
54
|
+
html.classList.toggle('dark', isDark)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const THEME_ORDER: Theme[] = ['day', 'sepia', 'night', 'oled']
|
|
58
|
+
|
|
59
|
+
export const useEbookStore = defineStore('ebook', () => {
|
|
60
|
+
const prefs = loadPreferences()
|
|
61
|
+
|
|
62
|
+
const fontSize = ref(prefs.fontSize ?? DEFAULTS.fontSize)
|
|
63
|
+
const fontFamily = ref<FontFamily>(prefs.fontFamily ?? DEFAULTS.fontFamily)
|
|
64
|
+
const contentWidth = ref<ContentWidth>(prefs.contentWidth ?? DEFAULTS.contentWidth)
|
|
65
|
+
const theme = ref<Theme>(prefs.theme ?? DEFAULTS.theme)
|
|
66
|
+
const lineHeight = ref<LineHeight>(prefs.lineHeight ?? DEFAULTS.lineHeight)
|
|
67
|
+
const showProgress = ref(prefs.showProgress ?? DEFAULTS.showProgress)
|
|
68
|
+
const readingMode = ref<ReadingMode>(prefs.readingMode ?? DEFAULTS.readingMode)
|
|
69
|
+
|
|
70
|
+
const uiVisible = ref(true)
|
|
71
|
+
const tocOpen = ref(false)
|
|
72
|
+
const settingsOpen = ref(false)
|
|
73
|
+
const focusMode = ref(false)
|
|
74
|
+
|
|
75
|
+
applyThemeClass(theme.value)
|
|
76
|
+
|
|
77
|
+
if (typeof document !== 'undefined') {
|
|
78
|
+
document.body.classList.toggle('font-serif', fontFamily.value === 'serif')
|
|
79
|
+
document.body.classList.toggle('font-sans', fontFamily.value === 'sans')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
watch(
|
|
83
|
+
[fontSize, fontFamily, contentWidth, theme, lineHeight, showProgress, readingMode],
|
|
84
|
+
() => {
|
|
85
|
+
savePreferences({
|
|
86
|
+
fontSize: fontSize.value,
|
|
87
|
+
fontFamily: fontFamily.value,
|
|
88
|
+
contentWidth: contentWidth.value,
|
|
89
|
+
theme: theme.value,
|
|
90
|
+
lineHeight: lineHeight.value,
|
|
91
|
+
showProgress: showProgress.value,
|
|
92
|
+
readingMode: readingMode.value,
|
|
93
|
+
})
|
|
94
|
+
},
|
|
95
|
+
{ immediate: true }
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
watch(() => theme.value, (t) => applyThemeClass(t))
|
|
99
|
+
|
|
100
|
+
function setFontSize(size: number) {
|
|
101
|
+
fontSize.value = Math.max(12, Math.min(32, size))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function setFontFamily(f: FontFamily) {
|
|
105
|
+
fontFamily.value = f
|
|
106
|
+
document.body.classList.toggle('font-serif', f === 'serif')
|
|
107
|
+
document.body.classList.toggle('font-sans', f === 'sans')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function setContentWidth(w: ContentWidth) {
|
|
111
|
+
contentWidth.value = w
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function setTheme(t: Theme) {
|
|
115
|
+
theme.value = t
|
|
116
|
+
applyThemeClass(t)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function cycleTheme() {
|
|
120
|
+
const nextIndex = (THEME_ORDER.indexOf(theme.value) + 1) % THEME_ORDER.length
|
|
121
|
+
setTheme(THEME_ORDER[nextIndex])
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function setLineHeight(lh: LineHeight) {
|
|
125
|
+
lineHeight.value = lh
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function setFocusMode(fm: boolean) {
|
|
129
|
+
focusMode.value = fm
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function toggleFocusMode() {
|
|
133
|
+
focusMode.value = !focusMode.value
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function toggleToc() {
|
|
137
|
+
tocOpen.value = !tocOpen.value
|
|
138
|
+
if (tocOpen.value) settingsOpen.value = false
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function toggleSettings() {
|
|
142
|
+
settingsOpen.value = !settingsOpen.value
|
|
143
|
+
if (settingsOpen.value) tocOpen.value = false
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function closeAll() {
|
|
147
|
+
tocOpen.value = false
|
|
148
|
+
settingsOpen.value = false
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function applyTheme() {
|
|
152
|
+
applyThemeClass(theme.value)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getThemeClass(): string {
|
|
156
|
+
return `theme-${theme.value}`
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function getCssVariables(): Record<string, string> {
|
|
160
|
+
return {
|
|
161
|
+
'--ebook-font-size': `${fontSize.value}px`,
|
|
162
|
+
'--ebook-max-width': focusMode.value ? '100%' : CONTENT_WIDTHS[contentWidth.value],
|
|
163
|
+
'--ebook-line-height': LINE_HEIGHTS[lineHeight.value],
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
fontSize, fontFamily, contentWidth, theme,
|
|
169
|
+
lineHeight, showProgress, readingMode,
|
|
170
|
+
uiVisible, tocOpen, settingsOpen, focusMode,
|
|
171
|
+
|
|
172
|
+
setFontSize, setFontFamily, setContentWidth, setTheme,
|
|
173
|
+
cycleTheme, setLineHeight, setFocusMode, toggleFocusMode,
|
|
174
|
+
toggleToc, toggleSettings, closeAll, applyTheme,
|
|
175
|
+
|
|
176
|
+
getThemeClass, getCssVariables,
|
|
177
|
+
CONTENT_WIDTHS, LINE_HEIGHTS,
|
|
178
|
+
}
|
|
179
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
export const useUiStore = defineStore('ui', () => {
|
|
5
|
+
const sidebarOpen = ref(false)
|
|
6
|
+
const activeSectionId = ref<string | null>(null)
|
|
7
|
+
|
|
8
|
+
function openSidebar() {
|
|
9
|
+
sidebarOpen.value = true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function closeSidebar() {
|
|
13
|
+
sidebarOpen.value = false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function toggleSidebar() {
|
|
17
|
+
sidebarOpen.value = !sidebarOpen.value
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function setActiveSection(id: string) {
|
|
21
|
+
activeSectionId.value = id
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
sidebarOpen,
|
|
26
|
+
activeSectionId,
|
|
27
|
+
openSidebar,
|
|
28
|
+
closeSidebar,
|
|
29
|
+
toggleSidebar,
|
|
30
|
+
setActiveSection,
|
|
31
|
+
}
|
|
32
|
+
})
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
* { box-sizing: border-box; }
|
|
6
|
+
html { scroll-behavior: smooth; }
|
|
7
|
+
|
|
8
|
+
@media (prefers-reduced-motion: reduce) {
|
|
9
|
+
html { scroll-behavior: auto; }
|
|
10
|
+
*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
body { font-family: 'Inter', system-ui, sans-serif; -webkit-font-smoothing: antialiased; background-color: var(--ebook-bg, #ffffff); color: var(--ebook-text, #1a1a1a); transition: background-color 0.25s ease, color 0.25s ease; }
|
|
14
|
+
body.font-serif { font-family: 'Merriweather', Georgia, serif; }
|
|
15
|
+
body.font-sans { font-family: 'Inter', system-ui, sans-serif; }
|
|
16
|
+
.font-mono { font-family: ui-monospace, monospace; }
|
|
17
|
+
|
|
18
|
+
.dark { color-scheme: dark; }
|
|
19
|
+
|
|
20
|
+
/* ============================================================
|
|
21
|
+
Theme: Day (default)
|
|
22
|
+
============================================================ */
|
|
23
|
+
:root, .theme-day {
|
|
24
|
+
--chrome-bg: #ffffff;
|
|
25
|
+
--chrome-bg-glass: rgba(255, 255, 255, 0.85);
|
|
26
|
+
--chrome-bg-hover: #f1f5f9;
|
|
27
|
+
--chrome-border: #e2e8f0;
|
|
28
|
+
--chrome-text: #1a1a1a;
|
|
29
|
+
--chrome-text-dim: #64748b;
|
|
30
|
+
--chrome-accent: #0d9488;
|
|
31
|
+
|
|
32
|
+
--ebook-bg: #ffffff;
|
|
33
|
+
--ebook-bg-secondary: #f8fafc;
|
|
34
|
+
--ebook-text: #1e293b;
|
|
35
|
+
--ebook-text-heading: #0f172a;
|
|
36
|
+
--ebook-text-muted: #64748b;
|
|
37
|
+
--ebook-border: #e2e8f0;
|
|
38
|
+
--ebook-accent: #0d9488;
|
|
39
|
+
--ebook-link-color: #0d9488;
|
|
40
|
+
--ebook-inline-code-bg: #f1f5f9;
|
|
41
|
+
--ebook-inline-code-text: #1e293b;
|
|
42
|
+
--ebook-inline-code-border: #e2e8f0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* ============================================================
|
|
46
|
+
Theme: Sepia
|
|
47
|
+
============================================================ */
|
|
48
|
+
.theme-sepia {
|
|
49
|
+
--chrome-bg: #faf8f0;
|
|
50
|
+
--chrome-bg-glass: rgba(250, 248, 240, 0.85);
|
|
51
|
+
--chrome-bg-hover: #f0ead6;
|
|
52
|
+
--chrome-border: #d6cdb6;
|
|
53
|
+
--chrome-text: #3d3529;
|
|
54
|
+
--chrome-text-dim: #7a7060;
|
|
55
|
+
--chrome-accent: #b8860b;
|
|
56
|
+
|
|
57
|
+
--ebook-bg: #faf8f0;
|
|
58
|
+
--ebook-bg-secondary: #f0ead6;
|
|
59
|
+
--ebook-text: #3d3529;
|
|
60
|
+
--ebook-text-heading: #2d2519;
|
|
61
|
+
--ebook-text-muted: #7a7060;
|
|
62
|
+
--ebook-border: #d6cdb6;
|
|
63
|
+
--ebook-accent: #b8860b;
|
|
64
|
+
--ebook-link-color: #b8860b;
|
|
65
|
+
--ebook-inline-code-bg: #f0ead6;
|
|
66
|
+
--ebook-inline-code-text: #3d3529;
|
|
67
|
+
--ebook-inline-code-border: #d6cdb6;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ============================================================
|
|
71
|
+
Theme: Night
|
|
72
|
+
============================================================ */
|
|
73
|
+
.theme-night {
|
|
74
|
+
--chrome-bg: #1a1a2e;
|
|
75
|
+
--chrome-bg-glass: rgba(26, 26, 46, 0.85);
|
|
76
|
+
--chrome-bg-hover: #25253e;
|
|
77
|
+
--chrome-border: #333355;
|
|
78
|
+
--chrome-text: #e2e8f0;
|
|
79
|
+
--chrome-text-dim: #94a3b8;
|
|
80
|
+
--chrome-accent: #5eead4;
|
|
81
|
+
|
|
82
|
+
--ebook-bg: #1a1a2e;
|
|
83
|
+
--ebook-bg-secondary: #25253e;
|
|
84
|
+
--ebook-text: #cbd5e1;
|
|
85
|
+
--ebook-text-heading: #e2e8f0;
|
|
86
|
+
--ebook-text-muted: #94a3b8;
|
|
87
|
+
--ebook-border: #333355;
|
|
88
|
+
--ebook-accent: #5eead4;
|
|
89
|
+
--ebook-link-color: #5eead4;
|
|
90
|
+
--ebook-inline-code-bg: #25253e;
|
|
91
|
+
--ebook-inline-code-text: #cbd5e1;
|
|
92
|
+
--ebook-inline-code-border: #333355;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ============================================================
|
|
96
|
+
Theme: OLED Black
|
|
97
|
+
============================================================ */
|
|
98
|
+
.theme-oled {
|
|
99
|
+
--chrome-bg: #000000;
|
|
100
|
+
--chrome-bg-glass: rgba(0, 0, 0, 0.85);
|
|
101
|
+
--chrome-bg-hover: #1a1a1a;
|
|
102
|
+
--chrome-border: #333333;
|
|
103
|
+
--chrome-text: #e2e8f0;
|
|
104
|
+
--chrome-text-dim: #94a3b8;
|
|
105
|
+
--chrome-accent: #5eead4;
|
|
106
|
+
|
|
107
|
+
--ebook-bg: #000000;
|
|
108
|
+
--ebook-bg-secondary: #1a1a1a;
|
|
109
|
+
--ebook-text: #cbd5e1;
|
|
110
|
+
--ebook-text-heading: #e2e8f0;
|
|
111
|
+
--ebook-text-muted: #94a3b8;
|
|
112
|
+
--ebook-border: #333333;
|
|
113
|
+
--ebook-accent: #5eead4;
|
|
114
|
+
--ebook-link-color: #5eead4;
|
|
115
|
+
--ebook-inline-code-bg: #1a1a1a;
|
|
116
|
+
--ebook-inline-code-text: #cbd5e1;
|
|
117
|
+
--ebook-inline-code-border: #333333;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* ============================================================
|
|
121
|
+
Content Typography
|
|
122
|
+
============================================================ */
|
|
123
|
+
.mn-content { position: relative; }
|
|
124
|
+
|
|
125
|
+
.mn-content h1 { font-size: 1.875rem; font-weight: 700; margin-bottom: 1rem; color: var(--ebook-text-heading); letter-spacing: -0.01em; padding-bottom: 0.5rem; border-bottom: 1px solid var(--ebook-border); }
|
|
126
|
+
.mn-content h2 { font-size: 1.25rem; font-weight: 600; margin-top: 2.5rem; margin-bottom: 0.75rem; color: var(--ebook-text-heading); letter-spacing: -0.005em; }
|
|
127
|
+
.mn-content h3 { font-size: 1.125rem; font-weight: 600; margin-top: 1.75rem; margin-bottom: 0.5rem; color: var(--ebook-text-heading); }
|
|
128
|
+
.mn-content h4 { font-size: 1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.4rem; color: var(--ebook-text); }
|
|
129
|
+
.mn-content p { margin-bottom: 1.1rem; line-height: var(--ebook-line-height, 1.6); color: var(--ebook-text); font-size: var(--ebook-font-size, 18px); }
|
|
130
|
+
.mn-content ul, .mn-content ol { margin-bottom: 1rem; }
|
|
131
|
+
.mn-content li { margin-bottom: 0.3rem; line-height: 1.65; }
|
|
132
|
+
.mn-content code { font-family: ui-monospace, monospace; font-size: 0.85em; background: var(--ebook-inline-code-bg); padding: 0.15em 0.45em; border-radius: 4px; }
|
|
133
|
+
.mn-content a { color: var(--ebook-link-color); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ebook-link-color) 40%, transparent); text-underline-offset: 2px; }
|
|
134
|
+
.mn-content a:hover { text-decoration-color: var(--ebook-link-color); }
|
|
135
|
+
.mn-content img { max-width: 100%; height: auto; border-radius: 6px; }
|
|
136
|
+
.mn-content blockquote { border-left: 3px solid var(--ebook-accent); padding: 0.75rem 1.25rem; margin: 1.5rem 0; font-style: italic; color: var(--ebook-text-muted); }
|
|
137
|
+
.mn-content dl { margin: 1rem 0; }
|
|
138
|
+
.mn-content dt { font-weight: 600; color: var(--ebook-text-heading); margin-top: 1rem; }
|
|
139
|
+
.mn-content dd { margin-left: 1.5rem; margin-bottom: 0.5rem; color: var(--ebook-text); line-height: 1.65; }
|
|
140
|
+
|
|
141
|
+
/* Print */
|
|
142
|
+
@media print {
|
|
143
|
+
.lg\:translate-x-0, #sidebar, .sticky { display: none !important; }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Scrollbar */
|
|
147
|
+
::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
148
|
+
::-webkit-scrollbar-track { background: transparent; }
|
|
149
|
+
::-webkit-scrollbar-thumb { background: var(--chrome-border); border-radius: 4px; }
|
|
150
|
+
::-webkit-scrollbar-thumb:hover { background: var(--chrome-text-dim); }
|
|
151
|
+
|
|
152
|
+
/* Sidebar layout helpers */
|
|
153
|
+
@media (min-width: 1024px) {
|
|
154
|
+
.lg\:pl-\[280px\] { padding-left: 280px; }
|
|
155
|
+
.lg\:translate-x-0 { --tw-translate-x: 0px; transform: translate(var(--tw-translate-x), var(--tw-translate-y)); }
|
|
156
|
+
}
|