timApp.document.editing package
Contents
timApp.document.editing package#
Submodules#
timApp.document.editing.clipboard module#
- class timApp.document.editing.clipboard.Clipboard[source]#
Bases:
object
- class UserClipboard(parent: timApp.document.editing.clipboard.Clipboard, user: timApp.user.user.User)[source]#
Bases:
object
- copy_pars(doc: timApp.document.document.Document, par_start: str, par_end: str, area_name: Optional[str] = None, disable_ref: bool = False) list[timApp.document.docparagraph.DocParagraph] [source]#
- cut_pars(doc: timApp.document.document.Document, par_start: str, par_end: str, area_name: Optional[str] = None) list[timApp.document.docparagraph.DocParagraph] [source]#
- paste_after(doc: timApp.document.document.Document, par_id: str, as_ref: bool = False) list[timApp.document.docparagraph.DocParagraph] [source]#
- paste_before(doc: timApp.document.document.Document, par_id: str, as_ref: bool = False) list[timApp.document.docparagraph.DocParagraph] [source]#
- read(as_ref: bool | None = False, force_parrefs: bool | None = False) list[dict[str, str]] | None [source]#
- write_refs(pars: list[timApp.document.docparagraph.DocParagraph], area_name: str | None)[source]#
- get(user: timApp.user.user.User)[source]#
timApp.document.editing.documenteditresult module#
- class timApp.document.editing.documenteditresult.DocumentEditResult(added: Optional[list[timApp.document.docparagraph.DocParagraph]] = None, deleted: Optional[list[timApp.document.docparagraph.DocParagraph]] = None, changed: Optional[list[timApp.document.docparagraph.DocParagraph]] = None)[source]#
Bases:
object
- property empty#
- property new_par_ids#
- property pars_added_or_deleted#
timApp.document.editing.editrequest module#
- class timApp.document.editing.editrequest.EditRequest(doc: timApp.document.document.Document, area_start: str | None = None, area_end: str | None = None, par: str | None = None, text: str | None = None, next_par_id: str | None = None, preview: bool = False, forced_classes: list[str] = <factory>, mark_translated: bool | None = None, viewname: timApp.document.viewcontext.ViewRoute | None = None)[source]#
Bases:
object
- area_end: str | None = None#
- area_start: str | None = None#
- context_par: timApp.document.docparagraph.DocParagraph | None#
- property editing_area: bool#
- editor_pars: list[timApp.document.docparagraph.DocParagraph] | None#
- forced_classes: list[str]#
- static from_request(doc: timApp.document.document.Document, text: Optional[str] = None, preview: bool = False) timApp.document.editing.editrequest.EditRequest [source]#
- get_context_par() timApp.document.docparagraph.DocParagraph [source]#
- get_last_of_preamble() timApp.document.docparagraph.DocParagraph | None [source]#
- get_original_par() timApp.document.docparagraph.DocParagraph | None [source]#
- property is_adding#
- mark_translated: bool | None = None#
- next_par_id: str | None = None#
- old_doc_version: tuple[int, int]#
- original_par: timApp.document.docparagraph.DocParagraph | None#
- par: str | None = None#
- preview: bool = False#
- text: str | None = None#
- viewname: timApp.document.viewcontext.ViewRoute | None = None#
- timApp.document.editing.editrequest.get_pars_from_editor_text(doc: timApp.document.document.Document, text: str, break_on_elements: bool = False, skip_access_check: bool = False) list[timApp.document.docparagraph.DocParagraph] [source]#
timApp.document.editing.globalparid module#
timApp.document.editing.proofread module#
- class timApp.document.editing.proofread.SpellCheckResult(words: list[timApp.document.editing.proofread.Word], new_html: str)[source]#
Bases:
object
- new_html: str#
- words: list[timApp.document.editing.proofread.Word]#
- class timApp.document.editing.proofread.VoikkoClient(data: list[str])[source]#
Bases:
object
Provides an API to libvoikko that exists in another container as an HTTP service. The API is intended to be identical to libvoikko.
- data: list[str]#
- phrase_data: dict[str, list[timApp.document.editing.proofread.VoikkoToken]]#
- spelling: dict[str, tuple[bool, list[str]]]#
- tokens(s: str) list[timApp.document.editing.proofread.VoikkoToken] [source]#
- class timApp.document.editing.proofread.VoikkoToken(tokenType: int, tokenText: str)[source]#
Bases:
object
- tokenText: str#
- tokenType: int#
- class timApp.document.editing.proofread.Word(word: str, suggestions: list[str])[source]#
Bases:
object
- suggestions: list[str]#
- word: str#
- timApp.document.editing.proofread.process_spelling_errors(s: str) timApp.document.editing.proofread.SpellCheckResult [source]#
- timApp.document.editing.proofread.proofread_pars(pars: list[timApp.document.prepared_par.PreparedPar]) list[timApp.document.editing.proofread.SpellCheckResult] [source]#
timApp.document.editing.routes module#
Routes for editing a document.
- class timApp.document.editing.routes.DrawIODataModel(data: str, par_id: str, doc_id: int)[source]#
Bases:
object
- data: str#
- doc_id: int#
- par_id: str#
- timApp.document.editing.routes.abort_if_duplicate_ids(doc: timApp.document.document.Document, pars_to_add: list[timApp.document.docparagraph.DocParagraph])[source]#
- timApp.document.editing.routes.add_paragraph()[source]#
Route for adding a new paragraph to a document.
- Returns
A JSON object containing the paragraphs in HTML form along with JS, CSS and Angular module dependencies.
- timApp.document.editing.routes.add_paragraph_common(md: str, doc_id: int, par_next_id: str | None)[source]#
- timApp.document.editing.routes.check_and_rename_pluginnamehere(blocks: list[timApp.document.docparagraph.DocParagraph], doc: timApp.document.document.Document)[source]#
- timApp.document.editing.routes.delete_paragraph(doc_id)[source]#
Route for deleting a paragraph from a document.
- Parameters
doc_id – The id of the document.
- Returns
A JSON object containing the version of the new document.
- timApp.document.editing.routes.get_next_available_task_id(attrs, old_pars, duplicates, par_id)[source]#
- timApp.document.editing.routes.get_updated_pars(doc_id)[source]#
Gets updated paragraphs that were changed e.g. as the result of adding headings or modifying macros.
- Parameters
doc_id – The document id.
- timApp.document.editing.routes.is_area_start_or_end(p: timApp.document.prepared_par.PreparedPar)[source]#
- timApp.document.editing.routes.manage_response(docentry: timApp.document.docinfo.DocInfo, pars: list[timApp.document.docparagraph.DocParagraph], timdb, ver_before: tuple[int, int])[source]#
- timApp.document.editing.routes.mark_all_checked_route(doc_id: int) flask.wrappers.Response [source]#
Marks all the paragraphs in a translation document checked.
- Parameters
doc_id – The id of the translation document to be handled.
- Returns
OK response if successful
- timApp.document.editing.routes.mark_as_translated(p: timApp.document.docparagraph.DocParagraph)[source]#
- timApp.document.editing.routes.mark_checked_route(doc_id: int, par_id: str) flask.wrappers.Response [source]#
Marks a paragraph checked.
- Parameters
doc_id – The id of the document the paragraph belongs to.
par_id – The id of the paragraph to be marked checked.
- Returns
The modified paragraph.
- timApp.document.editing.routes.mark_pars_as_read_if_chosen(pars, doc)[source]#
Marks the specified paragraphs as read if tags.markread is true in request’s JSON data.
- Parameters
pars (list[DocParagraph]) – The paragraphs to be marked as read
doc (Document) – The document to which the paragraphs belong.
- timApp.document.editing.routes.mark_translation_as_checked(p: timApp.document.docparagraph.DocParagraph) None [source]#
Mark a paragraph as checked by removing its mt-attribute.
- Parameters
p – The paragraph to mark as checked.
- Returns
None.
- timApp.document.editing.routes.modify_paragraph()[source]#
Route for modifying a paragraph in a document.
- Returns
A JSON object containing the paragraphs in HTML form along with JS, CSS and Angular module dependencies.
- timApp.document.editing.routes.modify_paragraph_common(doc_id: int, md: str, par_id: str, par_next_id: str | None)[source]#
- timApp.document.editing.routes.modify_paragraph_q()[source]#
Route for modifying a question editor paragraph in a document.
- Returns
A JSON object containing the paragraphs in HTML form along with JS, CSS and Angular module dependencies.
- timApp.document.editing.routes.par_response(pars: list[timApp.document.docparagraph.DocParagraph], docu: timApp.document.docinfo.DocInfo, spellcheck=False, update_cache=False, edit_request: Optional[timApp.document.editing.editrequest.EditRequest] = None, edit_result: Optional[timApp.document.editing.documenteditresult.DocumentEditResult] = None, filter_return: Optional[timApp.document.editing.globalparid.GlobalParId] = None, partial_doc_pars: bool = False, extra_doc_settings: Optional[timApp.document.yamlblock.YamlBlock] = None)[source]#
Return a JSON response containing updated paragraphs and updated HTMLs.
..note:: Applies additional processing to the paragraphs (e.g. spellchecking, filtering).
- Parameters
pars – Paragraphs to process.
docu – Document to which the paragraphs belong.
spellcheck – If True, spellcheck the paragraph texts and return HTML with spellcheck suggestions.
update_cache – If True, updates the HTML cache for the paragraphs.
edit_request – Full edit request.
edit_result – Result of the document edit request.
filter_return – Return only paragraphs with this document and paragraph id.
partial_doc_pars – If True, assumes that pars list includes partial document (e.g. areas may be incomplete). The option disables some checks that would be otherwise done for full paragraphs.
extra_doc_settings – Extra settings to apply to the paragraph.
- Returns
JSON object containing HTMLs, JS and CSS dependencies of changed paragraphs.
- timApp.document.editing.routes.preview_paragraphs(doc_id)[source]#
Route for previewing paragraphs.
- Parameters
doc_id – The id of the document in which the preview will be rendered.
- Returns
A JSON object containing the paragraphs in HTML form along with JS, CSS and Angular module dependencies.
- timApp.document.editing.routes.set_drawio_base(args: timApp.document.editing.routes.DrawIODataModel)[source]#
- timApp.document.editing.routes.update_associated_uploads(pars: list[timApp.document.docparagraph.DocParagraph], doc: timApp.document.docinfo.DocInfo)[source]#
- timApp.document.editing.routes.update_document(doc_id)[source]#
Route for updating a document as a whole.
- Parameters
doc_id – The id of the document to be modified.
- Returns
A JSON object containing the versions of the document.
- timApp.document.editing.routes.verify_par_edit_access(par: timApp.document.docparagraph.DocParagraph)[source]#
Verifies that the current user has edit access to the specified DocParagraph.
timApp.document.editing.routes_clipboard module#
Routes for the clipboard.
- class timApp.document.editing.routes_clipboard.WithDocData(doc_id: int, docentry: timApp.document.docinfo.DocInfo)[source]#
Bases:
object
- doc_id: int#
- docentry: timApp.document.docinfo.DocInfo#
- timApp.document.editing.routes_clipboard.copy_to_clipboard(doc_id, from_par, to_par, area_name: str | None = None)[source]#
- timApp.document.editing.routes_clipboard.cut_to_clipboard(doc_id, from_par, to_par, area_name: str | None = None)[source]#